/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Dark Mode (Default) - Academic Theme */
    --bg-color: #0f1115;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --panel-bg: #1e222b;
    --panel-border: #333a45;
    --accent-primary: #3b82f6; /* Trust Blue */
    --accent-hover: #60a5fa;
    --gradient-start: #3b82f6;
    --gradient-end: #8b5cf6;
    
    /* UI Elements */
    --input-bg: #15181e;
    --input-border: #333a45;
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    
    /* Result Box */
    --result-bg: #0b0c0f;
}

body.light-mode {
    /* Light Mode - Academic Clean Theme */
    --bg-color: #f8fafc;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --panel-bg: #ffffff;
    --panel-border: #e2e8f0;
    --input-bg: #f1f5f9;
    --input-border: #cbd5e1;
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    --result-bg: #ffffff;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh;
}

h1, h2, h3, h4 {
    font-family: 'Outfit', sans-serif;
    line-height: 1.2;
}

.serif-font {
    font-family: 'Merriweather', serif;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Navigation */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 0;
    border-bottom: 1px solid var(--panel-border);
    margin-bottom: 30px;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    color: var(--accent-primary);
}

.logo-text h1 {
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: -4px;
}

.logo-text span {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

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

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: color 0.2s ease;
}

.nav-links a:hover {
    color: var(--accent-hover);
}

.theme-toggle {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: transform 0.2s ease, background 0.2s ease;
}

.theme-toggle:hover {
    transform: scale(1.1);
    background: var(--input-bg);
}

/* Hero Section */
.hero-section {
    text-align: center;
    margin-bottom: 40px;
    padding: 20px 0;
}

.hero-title {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 16px;
    letter-spacing: -1px;
}

.highlight {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
}

/* Glassmorphism Panels */
.glass-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 30px;
    box-shadow: var(--shadow-md);
}

/* Tool Wrapper and Tabs */
.tool-wrapper {
    margin-bottom: 50px;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: -1px; /* Overlap border */
    position: relative;
    z-index: 2;
}

.tab-btn {
    background: var(--input-bg);
    border: 1px solid var(--panel-border);
    border-bottom: none;
    color: var(--text-secondary);
    padding: 12px 24px;
    font-size: 1rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    border-radius: 12px 12px 0 0;
    transition: all 0.2s ease;
}

.tab-btn.active {
    background: var(--panel-bg);
    color: var(--accent-primary);
    border-top: 3px solid var(--accent-primary);
}

.tab-btn:hover:not(.active) {
    color: var(--text-primary);
    background: var(--panel-bg);
}

/* Calculator Grid */
.calculator-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 30px;
    position: relative;
    z-index: 1;
}

.input-panel {
    border-top-left-radius: 0; /* Attach to tabs */
}

@media (max-width: 900px) {
    .calculator-grid {
        grid-template-columns: 1fr;
    }
    .input-panel {
        border-top-left-radius: 12px;
        border-top-right-radius: 0;
    }
}

/* Form Content */
.form-content {
    display: none;
}

.form-content.active-form {
    display: block;
}

/* Inputs */
.input-row {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.input-group {
    margin-bottom: 20px;
    width: 100%;
}

.input-group.half {
    width: 50%;
    margin-bottom: 0;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-primary);
}

input[type="text"], input[type="number"] {
    width: 100%;
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 14px 16px;
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.2s ease;
}

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

/* Buttons */
.primary-btn {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
    margin-top: 10px;
    margin-bottom: 12px;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px -3px rgba(59, 130, 246, 0.4);
}

.secondary-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--input-border);
    padding: 12px 28px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.secondary-btn:hover {
    background: var(--input-bg);
    color: var(--text-primary);
}

/* Results Panel */
.results-panel h3 {
    margin-bottom: 24px;
    font-size: 1.5rem;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 12px;
}

.citation-box {
    margin-bottom: 24px;
}

.citation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.citation-label {
    font-weight: 700;
    font-size: 1rem;
    color: var(--accent-primary);
    font-family: 'Outfit', sans-serif;
}

.copy-btn {
    background: var(--input-bg);
    border: 1px solid var(--panel-border);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.citation-content {
    background-color: var(--result-bg);
    border: 1px solid var(--panel-border);
    border-left: 4px solid var(--accent-primary);
    padding: 20px;
    border-radius: 8px;
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-primary);
    min-height: 80px;
    word-wrap: break-word;
}

/* For em tags inside citations */
.citation-content em {
    font-style: italic;
}
.citation-content .smallcaps {
    font-variant: small-caps;
}

.recommendation-box {
    background: var(--input-bg);
    border-left: 4px solid #f59e0b; /* Warning Yellow */
    padding: 16px;
    border-radius: 0 8px 8px 0;
    margin-top: 20px;
}

.recommendation-box h4 {
    margin-bottom: 4px;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.recommendation-box p {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* AdSense Containers */
.ad-container {
    background: var(--panel-bg);
    border: 1px dashed var(--input-border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 40px auto;
    color: var(--text-secondary);
    font-size: 0.85rem;
    overflow: hidden;
}

.top-ad, .bottom-ad {
    width: 100%;
    max-width: 728px;
    height: 90px;
}

.middle-ad {
    width: 100%;
    height: 250px;
}

/* Documentation */
.docs-section {
    margin-top: 60px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.full-width {
    grid-column: 1 / -1;
}

@media (max-width: 768px) {
    .docs-section {
        grid-template-columns: 1fr;
    }
}

.doc-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 30px;
}

.doc-card h3 {
    color: var(--accent-primary);
    margin-bottom: 20px;
    font-size: 1.4rem;
}

.doc-card h4 {
    color: var(--text-primary);
    margin: 20px 0 10px 0;
    font-size: 1.1rem;
}

.doc-list {
    padding-left: 20px;
    color: var(--text-secondary);
}

.doc-list li {
    margin-bottom: 12px;
}

.doc-list strong {
    color: var(--text-primary);
}

.doc-card p {
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* Footer */
.site-footer {
    border-top: 1px solid var(--panel-border);
    padding: 40px 0;
    margin-top: 60px;
    text-align: center;
}

.footer-content p {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: var(--accent-hover);
}
