/* ============================================================================
   CSS Variables - Light and Dark Themes
   ============================================================================ */
:root {
    /* Light Theme Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #010307;
    --text-secondary: #16a34a;
    --text-tertiary: #4b5563;
    --border-color: #e2e8f0;
    --accent-primary: #16a34a;
    --accent-secondary: #15803d;
    --accent-hover: #15803d;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);
    --gradient: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    --success: #16a34a;
    --error: #ef4444;
    --warning: #f59e0b;
    --font-size-base: clamp(1rem, 0.4vw + 0.875rem, 1.125rem);
    --container-max-width: 1200px;
}

[data-theme="dark"] {
    /* Dark Theme Colors */
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-tertiary: #1a1a1a;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #a3f8b8;
    --border-color: #2a2a2a;
    --accent-primary: #22863b;
    --accent-secondary: #67c089;
    --accent-hover: #22d631;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.6);
}

/* ============================================================================
   Reset and Base Styles
   ============================================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: var(--font-size-base);
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh;
}

/* ============================================================================
   Theme Toggle Button
   ============================================================================ */
.theme-toggle {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: var(--text-secondary);
}

.theme-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
    transform: rotate(15deg);
}

.sun-icon {
    display: block;
}

.moon-icon {
    display: none;
}

[data-theme="dark"] .sun-icon {
    display: none;
}

[data-theme="dark"] .moon-icon {
    display: block;
}

/* ============================================================================
   Container
   ============================================================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================================
   Navbar & Header
   ============================================================================ */
.navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    transition: background-color 0.3s ease;
    margin-bottom: 2rem;
}

/* Glass effect support */
@supports (backdrop-filter: blur(10px)) {
    .navbar {
        background: color-mix(in srgb, var(--bg-primary) 80%, transparent);
        backdrop-filter: blur(12px);
    }
}

.navbar-container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 clamp(1rem, 5vw, 2rem);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
}

.logo {
    height: 48px;
    width: auto;
    object-fit: contain;
}

.brand-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 800;
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
    line-height: 1;
}

.logo-subtitle {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    font-weight: 500;
    letter-spacing: 0.5px;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.divider {
    width: 1px;
    height: 24px;
    background-color: var(--border-color);
}

/* Auth Buttons */
.auth-buttons {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn {
    padding: 0.5rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    border: none;
}

.btn-login {
    background: transparent;
    color: var(--text-secondary);
}

.btn-login:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.btn-register {
    background: var(--gradient);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-register:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    opacity: 0.95;
}

.btn-register:active {
    transform: translateY(0);
}

.btn-logout {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border-color: var(--error);
}

/* ============================================================================
   Hamburger Menu & Mobile
   ============================================================================ */
.hamburger-menu {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
}

.hamburger-menu:hover {
    background: var(--bg-secondary);
}

.mobile-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 999;
}

.mobile-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.mobile-menu-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.btn-login-mobile,
.btn-register-mobile {
    width: 100%;
    padding: 0.75rem;
    text-align: center;
    border-radius: 0.5rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-login-mobile {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-register-mobile {
    background: var(--gradient);
    color: white;
}

.btn-logout-mobile {
    width: 100%;
    padding: 0.75rem;
    text-align: center;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-logout-mobile:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border-color: var(--error);
}

/* ============================================================================
   Hero Section
   ============================================================================ */
.hero {
    text-align: center;
    margin-bottom: clamp(2rem, 8vw, 4rem);
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
}

.greeting-message {
    font-size: clamp(1.1rem, 2.5vw, 1.4rem);
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-weight: 500;
    animation: slideUp 0.8s ease-out 0.1s both;
}

.user-name {
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
}

.hero-title {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 800;
    margin-bottom: 1rem;
    line-height: 1.2;
    animation: slideUp 0.8s ease-out 0.2s both;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gradient-text {

    background: var(--gradient);
    text-shadow:
        0 0 10px cyan 0 0 20px cyan 0 0 40px cyan 0 0 80px cyan,
    ;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

/* ============================================================================
   Research Form
   ============================================================================ */
.research-form {
    margin-bottom: 0.5rem;
    animation: slideUp 0.8s ease-out 0.6s both;
}

.input-wrapper {
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 3rem;
    padding: 0.5rem 0.5rem 0.5rem clamp(1rem, 3vw, 1.5rem);
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 0.7rem;
    max-width: 1000px;
    margin: 0 auto;
}

.input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-lg), 0 0 0 4px rgba(99, 102, 241, 0.1);
    transform: translateY(-2px);
}

.query-input {
    flex: 1;
    width: 100%;
    background: transparent;
    border: none;
    font-size: 1rem;
    color: var(--text-primary);
    font-family: inherit;
    resize: none;
    min-height: unset;
    height: 24px;
    margin-bottom: 0;
    padding: 0;
}

.query-input:focus {
    outline: none;
}

.query-input:read-only {
    opacity: 0.7;
    cursor: not-allowed;
}

.query-input::placeholder {
    color: var(--text-tertiary);
}

.input-footer {
    display: flex;
    align-items: center;
    margin: 0;
}

.char-count {
    font-size: 0.875rem;
    color: var(--text-tertiary);
}

.submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient);
    color: white;
    border: none;
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.submit-btn:active {
    transform: translateY(0);
}

.btn-icon {
    transition: transform 0.3s ease;
}

.submit-btn:hover .btn-icon {
    transform: translateX(4px);
}

/* ============================================================================
   Messages
   ============================================================================ */
.messages-container {
    margin-top: 1.5rem;
}

.message {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 0.75rem;
    margin-bottom: 0.75rem;
    animation: slideIn 0.4s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.message-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    color: var(--error);
}

.message-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--success);
    color: var(--success);
}

/* ============================================================================
   Features Section
   ============================================================================ */
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: clamp(1rem, 4vw, 2rem);
    margin-bottom: clamp(2rem, 8vw, 4rem);
}

.feature-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: clamp(1.5rem, 5vw, 2.5rem);
    text-align: center;
    transition: all 0.3s ease;
    animation: fadeIn 0.8s ease-out;
}

.feature-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-xl);
    border-color: var(--accent-primary);
}

.feature-icon {
    width: 4rem;
    height: 4rem;
    background: var(--gradient);
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    color: white;
}

.feature-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.feature-description {
    color: var(--text-secondary);
    line-height: 1.7;
}

/* ============================================================================
   Footer
   ============================================================================ */
.footer {
    text-align: center;
    padding: 2rem 0;
    border-top: 1px solid var(--border-color);
}

.footer-text {
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

/* ============================================================================
   Responsive Design
   ============================================================================ */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .navbar {
        margin-bottom: 1rem;
    }

    .logo {
        height: 40px;
    }

    .logo-text {
        font-size: 1.25rem;
    }

    .logo-subtitle {
        font-size: 0.75rem;
    }

    .desktop-only {
        display: none !important;
    }

    .hamburger-menu {
        display: block;
    }

    .input-wrapper {
        padding: 0.5rem 0.5rem 0.5rem 1rem;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 1.75rem;
    }

    .query-input {
        min-height: unset;
        height: 24px;
        font-size: 0.9375rem;
    }

    .feature-card {
        padding: 1.5rem 1.25rem;
    }
}