@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&family=Figtree:wght@600;700&family=Roboto+Mono&display=swap');

:root {
    --primary: #0095f6;
    --primary-hover: #1877f2;
    --gradient-brand: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    
    --bg-color: #ffffff;
    --surface: #fafafa;
    
    --success: #34D399;
    --warning: #FBBF24;
    --error: #EF4444;
    --info: #0095f6;
    
    --border: #dbdbdb;
    --border-hover: #c7c7c7;
    
    --text-primary: #262626;
    --text-secondary: #8e8e8e;
    
    --shadow-subtle: 0 1px 3px rgba(0, 0, 0, 0.03);
    --shadow-medium: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Dark Mode (Explicit Toggle) */
[data-theme="dark"] {
    --bg-color: #000000;
    --surface: #121212;
    --border: #262626;
    --border-hover: #363636;
    --text-primary: #fafafa;
    --text-secondary: #a8a8a8;
    --shadow-subtle: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-medium: 0 10px 15px rgba(0, 0, 0, 0.4);
}
[data-theme="dark"] .badge { background: rgba(59, 130, 246, 0.2); color: #60A5FA; }
[data-theme="dark"] .btn-secondary { background: #374151; color: #60A5FA; }
[data-theme="dark"] .btn-secondary:hover { background: #4B5563; }
[data-theme="dark"] .btn-outline:hover { background: var(--surface); color: var(--text-primary); }
[data-theme="dark"] .error-message { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.2); color: #FCA5A5; }
[data-theme="dark"] .positive { background: rgba(52, 211, 153, 0.15); color: #6EE7B7; }
[data-theme="dark"] .negative { background: rgba(239, 68, 68, 0.15); color: #FCA5A5; }
[data-theme="dark"] .neutral { background: rgba(251, 191, 36, 0.15); color: #FCD34D; }
[data-theme="dark"] .na { background: var(--border); color: var(--text-secondary); }

/* Dark Mode (System Preference Fallback) */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-color: #000000;
        --surface: #121212;
        --border: #262626;
        --border-hover: #363636;
        --text-primary: #fafafa;
        --text-secondary: #a8a8a8;
        --shadow-subtle: 0 4px 6px rgba(0, 0, 0, 0.3);
        --shadow-medium: 0 10px 15px rgba(0, 0, 0, 0.4);
    }
    :root:not([data-theme="light"]) body .badge { background: rgba(59, 130, 246, 0.2); color: #60A5FA; }
    :root:not([data-theme="light"]) body .btn-secondary { background: #374151; color: #60A5FA; }
    :root:not([data-theme="light"]) body .btn-secondary:hover { background: #4B5563; }
    :root:not([data-theme="light"]) body .btn-outline:hover { background: var(--surface); color: var(--text-primary); }
    :root:not([data-theme="light"]) body .error-message { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.2); color: #FCA5A5; }
    :root:not([data-theme="light"]) body .positive { background: rgba(52, 211, 153, 0.15); color: #6EE7B7; }
    :root:not([data-theme="light"]) body .negative { background: rgba(239, 68, 68, 0.15); color: #FCA5A5; }
    :root:not([data-theme="light"]) body .neutral { background: rgba(251, 191, 36, 0.15); color: #FCD34D; }
    :root:not([data-theme="light"]) body .na { background: var(--border); color: var(--text-secondary); }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
}

.container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
}
/* =============================================
   Header & Nav
   ============================================= */
.app-header {
    background: var(--bg-color);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
    background: rgba(255,255,255,0.85);
}
.app-header {
    position: -webkit-sticky;
    position: sticky;
}
[data-theme="dark"] .app-header,
@media (prefers-color-scheme: dark) { .app-header { background: rgba(0,0,0,0.85); } }

.app-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 14px;
    padding-bottom: 14px;
    margin-top: 0;
    position: relative;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.logo-img {
    width: 36px;
    height: 36px;
    border-radius: 8px;
}

.logo-wordmark {
    font-weight: 700;
    font-size: 18px;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 24px;
}

.nav-link {
    text-decoration: none;
    color: #000000 !important;
    font-size: 15px;
    font-weight: 600;
    transition: color 0.2s;
}
.nav-link:hover { color: var(--text-primary); }

.theme-toggle-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 9999px;
    padding: 6px 10px;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    min-height: auto;
    transition: border-color 0.2s, color 0.2s;
}
.theme-toggle-btn:hover { border-color: var(--text-secondary); color: var(--text-primary); }

/* Show sun in dark, moon in light */
.sun-icon { display: none; }
.moon-icon { display: block; }
[data-theme="dark"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .sun-icon { display: block; }
    :root:not([data-theme="light"]) .moon-icon { display: none; }
}

/* =============================================
   Hero
   ============================================= */
.hero-tagline {
    text-align: center;
    padding: 32px 20px 40px;
}
.hero-tagline h1 {
    font-size: clamp(28px, 5vw, 48px);
    line-height: 1.15;
    margin-bottom: 16px;
    -webkit-text-fill-color: var(--text-primary);
    background: none;
}
.gradient-text {
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero-desc {
    font-size: 16px;
    color: var(--text-secondary);
    max-width: 520px;
    margin: 0 auto 32px;
    line-height: 1.65;
}
.hero-cta {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    padding: 13px 28px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 15px;
    transition: background 0.2s, transform 0.1s;
}
.hero-cta:hover { background: var(--primary-hover); transform: translateY(-1px); }

/* =============================================
   Features
   ============================================= */
.features-section {
    padding: 32px 20px;
}

.section-header {
    text-align: center;
    margin-bottom: 40px;
}
.section-header h2 { margin-bottom: 8px; }
.section-desc {
    color: var(--text-secondary);
    font-size: 15px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

@media (max-width: 600px) {
    .features-grid {
        grid-template-columns: 1fr;
    }
}

.feature-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px 24px;
    transition: border-color 0.2s, transform 0.15s;
}
.feature-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }

.feature-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}
.feature-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.feature-card p { font-size: 13px; color: var(--text-secondary); line-height: 1.6; margin: 0; }
.feature-card code { font-size: 12px; background: var(--border); padding: 1px 5px; border-radius: 4px; }

/* =============================================
   App section spacing
   ============================================= */
#app {
    padding: 32px 20px;
    max-width: 800px;
    margin: 0 auto;
}
#app .card { margin-bottom: 28px; }

/* =============================================
   FAQ
   ============================================= */
.faq-section {
    padding: 32px 20px;
}

.faq-container {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.faq-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--surface);
}

.faq-question {
    width: 100%;
    background: none;
    border: none;
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    text-align: left;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    min-height: auto;
    border-radius: 0;
}
.faq-question:hover { background: var(--bg-color); }

.faq-chevron {
    flex-shrink: 0;
    margin-left: 12px;
    transition: transform 0.25s ease;
    color: var(--text-secondary);
}
.faq-question[aria-expanded="true"] .faq-chevron { transform: rotate(180deg); }

.faq-answer {
    display: none;
    padding: 0 20px 18px;
    border-top: 1px solid var(--border);
}
.faq-answer p { margin: 12px 0 0; font-size: 14px; color: var(--text-secondary); line-height: 1.65; }
.faq-item.open .faq-answer { display: block; }
.faq-item.open .faq-chevron { transform: rotate(180deg); }

/* =============================================
   Footer
   ============================================= */
.site-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    margin-top: 40px;
    padding: 48px 0 0;
}

.footer-inner {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 40px;
    padding-bottom: 40px;
}

@media (max-width: 680px) {
    .footer-inner { grid-template-columns: 1fr 1fr; }
    .footer-brand { grid-column: 1 / -1; }
    .nav-links { gap: 14px; }
    .nav-link { display: none; }
    .theme-toggle-btn { display: flex; }
}

.footer-logo-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.footer-logo-img {
    width: 32px;
    height: 32px;
    border-radius: 6px;
}
.footer-brand-name {
    font-weight: 700;
    font-size: 16px;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.footer-tagline {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.6;
    margin: 0;
}

.footer-col-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-primary);
    margin-bottom: 14px;
    margin-top: 0;
}

.footer-links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.footer-links a {
    text-decoration: none;
    color: var(--text-primary);
    font-size: 13px;
    transition: color 0.2s;
}
.footer-links a:hover { color: var(--primary); }

.footer-bottom {
    border-top: 1px solid var(--border);
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    flex-wrap: wrap;
    gap: 8px;
}
.footer-bottom p {
    margin: 0;
    font-size: 12px;
    color: var(--text-primary);
}

h1, h2, h3 {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-primary);
    margin-top: 0;
}

h1 {
    font-size: 32px;
    line-height: 40px;
    font-weight: 700;
    margin-bottom: 6px;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle-text, header p {
    font-size: 17px;
    line-height: 26px;
    color: var(--text-secondary);
    margin: 0 0 18px 0;
}

h2 {
    font-size: 24px;
    line-height: 32px;
    font-weight: 700;
    margin-bottom: 6px;
}

h3 {
    font-size: 20px;
    line-height: 28px;
    font-weight: 600;
}

.card {
    background: var(--surface);
    border-radius: 8px;
    border: 1px solid var(--border);
    padding: 24px;
    margin-bottom: 36px;
    box-shadow: none;
}

.card.results-area {
    background: var(--bg-color);
    box-shadow: var(--shadow-medium);
}

form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

input[type="text"],
input[type="file"] {
    min-height: 44px;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    width: 100%;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

input[type="text"]:hover,
input[type="file"]:hover {
    border-color: var(--border-hover);
}

input[type="text"]:focus,
input[type="file"]:focus {
    background: var(--bg-color);
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

button {
    min-height: 44px;
    padding: 10px 14px;
    border-radius: 8px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    border: none;
    text-align: center;
}

button:active {
    transform: scale(0.98);
}

#scrape-btn, #analyze-btn {
    background: var(--primary);
    color: var(--bg-color);
}

#scrape-btn:hover, #analyze-btn:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: #F3F4F6;
    color: var(--primary);
}

.btn-secondary:hover {
    background: #E5E7EB;
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
}

.btn-outline:hover {
    background: var(--surface);
}

.results-area {
    display: none;
}

/* Badges for Sentiment (Summary) */
.sentiment-summary {
    display: flex;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.badge {
    padding: 6px 14px;
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 500;
    background: #EFF6FF;
    color: var(--primary);
    min-height: 36px;
    display: flex;
    align-items: center;
    box-sizing: border-box;
}

/* Tags for Sentiment (Table) */
.tag {
    padding: 6px 14px;
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 500;
    display: inline-block;
}

/* Colors for semantic tags */
.positive {
    background: rgba(52, 211, 153, 0.12);
    color: #059669;
}

.negative {
    background: rgba(239, 68, 68, 0.12);
    color: #DC2626;
}

.neutral {
    background: rgba(251, 191, 36, 0.2);
    color: #D97706;
}

.na {
    background: #F3F4F6;
    color: var(--text-secondary);
}

/* Actions */
.actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Spinner adjustment */
.loading {
    display: none;
    text-align: center;
    margin: 24px 0;
}

.spinner {
    border: 3px solid var(--border);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: var(--primary);
    animation: spin 1s linear infinite;
    display: inline-block;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-message {
    color: var(--error);
    background: #FEF2F2;
    border: 1px solid #FECACA;
    padding: 12px 18px;
    border-radius: 12px;
    display: none;
    margin-top: 18px;
    font-size: 13px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 18px;
    font-size: 15px;
    table-layout: fixed;
}

th, td {
    text-align: left;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    word-break: break-word;
}

th {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 13px;
}

th:nth-child(1) { width: 30%; }
th:nth-child(2) { width: 50%; }
th:nth-child(3) { width: 20%; }

/* -------------------------------------
   Utility & Structural Classes 
   ------------------------------------- */

.table-container {
    max-height: 400px;
    overflow-y: auto;
    margin-top: 12px;
}

summary {
    cursor: pointer;
    color: var(--primary);
    font-weight: 500;
    font-size: 15px;
    padding: 12px 0;
}

.mb-20 {
    margin-bottom: 24px;
}

.mt-15 {
    margin-top: 18px;
}

.affiliation-warning {
    background-color: #262626;
    color: #a8a8a8;
    text-align: center;
    padding: 14px 20px;
    font-size: 12px;
    width: 100%;
    box-sizing: border-box;
}