/* =========================================
   CSS Variables & Theme
========================================= */
:root {
    --primary-color: #4361EE;
    --primary-dark: #324edb;
    --primary-glow: rgba(67, 97, 238, 0.25);
    --secondary-color: #F72585;
    --success-color: #10B981;
    --bg-color: #F4F7FE;
    --bg-alt: #EEF2FC;
    --card-bg: #FFFFFF;
    --text-main: #2B2D42;
    --text-muted: #8D99AE;
    --border-color: rgba(141, 153, 174, 0.2);
    --border-radius: 20px;
    --border-radius-sm: 12px;
    --box-shadow: 0 4px 24px rgba(67, 97, 238, 0.08);
    --box-shadow-hover: 0 8px 32px rgba(67, 97, 238, 0.16);
    --transition: 0.25s ease;
}

body.dark-mode {
    --bg-color: #0F172A;
    --bg-alt: #162032;
    --card-bg: #1E293B;
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --border-color: rgba(148, 163, 184, 0.15);
    --box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --box-shadow-hover: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* =========================================
   Reset & Base
========================================= */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Nunito', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    font-size: 16px;
}

a {
    text-decoration: none;
    color: inherit;
}

ul { list-style: none; }

/* =========================================
   Navbar
========================================= */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 5%;
    background: var(--card-bg);
    box-shadow: var(--box-shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color var(--transition);
}

.logo {
    font-size: 18px;
    font-weight: 800;
}

.logo a:hover .highlight {
    text-decoration: underline;
}

.highlight { color: var(--primary-color); }

.theme-btn {
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    transition: transform 0.3s ease, background var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-btn:hover {
    transform: scale(1.15) rotate(20deg);
}



/* =========================================
   Tool Container & Card
========================================= */
.tool-container {
    display: flex;
    justify-content: center;
    padding: 40px 5% 20px;
}

.calculator-card {
    background: var(--card-bg);
    width: 100%;
    max-width: 540px;
    padding: 44px 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: background-color var(--transition), box-shadow var(--transition);
}

.card-header {
    text-align: center;
    margin-bottom: 28px;
}

.tool-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.calculator-card h1 {
    font-size: 1.9rem;
    font-weight: 900;
    color: var(--text-main);
    margin-bottom: 6px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.92rem;
}

/* =========================================
   Error Message
========================================= */
.error-msg {
    background: #FEF2F2;
    border: 1.5px solid #FCA5A5;
    color: #DC2626;
    border-radius: var(--border-radius-sm);
    padding: 12px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

body.dark-mode .error-msg {
    background: rgba(220, 38, 38, 0.12);
    border-color: rgba(220, 38, 38, 0.4);
    color: #F87171;
}

/* =========================================
   Input Group
========================================= */
.input-group {
    text-align: left;
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-weight: 700;
    margin-bottom: 8px;
    font-size: 0.92rem;
    color: var(--text-main);
}

.input-group input[type="date"] {
    width: 100%;
    padding: 14px 16px;
    font-size: 1rem;
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    background-color: var(--bg-color);
    color: var(--text-main);
    border: 2px solid transparent;
    border-radius: var(--border-radius-sm);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    cursor: pointer;
}

.input-group input[type="date"]:hover {
    border-color: var(--border-color);
}

.input-group input[type="date"]:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* =========================================
   Action Button
========================================= */
.action-btn {
    width: 100%;
    padding: 15px;
    font-size: 1.1rem;
    font-weight: 800;
    font-family: 'Nunito', sans-serif;
    background: linear-gradient(135deg, var(--primary-color), #6C63FF);
    color: white;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    box-shadow: 0 6px 20px var(--primary-glow);
    margin-top: 6px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
}

.action-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 28px rgba(67, 97, 238, 0.38);
    filter: brightness(1.05);
}

.action-btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.action-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Loading Spinner */
.loader {
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =========================================
   Result Box
========================================= */
.result-box {
    margin-top: 28px;
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: all 0.4s ease;
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Highlight pulse animation on new result */
.result-box.highlight-pulse {
    animation: highlightPulse 0.6s ease;
}

@keyframes highlightPulse {
    0%   { box-shadow: 0 0 0 0 var(--primary-glow); }
    50%  { box-shadow: 0 0 0 10px rgba(67, 97, 238, 0.1); }
    100% { box-shadow: 0 0 0 0 transparent; }
}

/* Result Hero */
.result-hero {
    background: linear-gradient(135deg, var(--primary-color) 0%, #6C63FF 100%);
    color: white;
    padding: 28px 24px;
    text-align: center;
}

.result-label {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    opacity: 0.85;
    margin-bottom: 16px;
}

.main-age {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.age-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.age-unit strong {
    font-size: 2.6rem;
    font-weight: 900;
    line-height: 1;
}

.age-unit em {
    font-style: normal;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.8;
    margin-top: 4px;
}

.age-sep {
    font-size: 1.8rem;
    opacity: 0.4;
    margin-top: -4px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--border-color);
    border-top: 1px solid var(--border-color);
}

.stat-card {
    background: var(--card-bg);
    padding: 18px 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: background var(--transition);
}

.stat-card:hover {
    background: var(--bg-color);
}

.stat-icon {
    font-size: 1.4rem;
    line-height: 1;
}

.stat-card strong {
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--primary-color);
    display: block;
    word-break: break-all;
}

.stat-card span {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

/* Info Row */
.info-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1px;
    background: var(--border-color);
    border-top: 1px solid var(--border-color);
}

.info-chip {
    background: var(--bg-color);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.info-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.info-chip strong {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text-main);
}

/* =========================================
   Content Sections
========================================= */
.content-section {
    max-width: 800px;
    margin: 0 auto 28px;
    padding: 36px 40px;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: background-color var(--transition);
}

.content-section h2 {
    font-size: 1.45rem;
    font-weight: 900;
    color: var(--primary-color);
    margin-bottom: 16px;
}

.content-section p {
    color: var(--text-muted);
    margin-bottom: 14px;
    font-size: 0.95rem;
}

.content-section ol,
.content-section ul {
    margin-bottom: 14px;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.content-section ol {
    padding-left: 22px;
}

.content-section ol li,
.content-section ul li {
    margin-bottom: 10px;
}

.content-section ol li strong,
.content-section p strong {
    color: var(--text-main);
}

.content-section a {
    color: var(--primary-color);
    font-weight: 700;
}

.content-section a:hover {
    text-decoration: underline;
}

/* Feature List */
.feature-list {
    list-style: none;
    padding: 0;
}

.feature-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
    color: var(--text-muted);
}

.feature-list li:last-child { border-bottom: none; }
.feature-list li strong { color: var(--text-main); }

/* =========================================
   Examples Grid
========================================= */
.example-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 18px;
}

.example-card {
    background: var(--bg-color);
    border-radius: var(--border-radius-sm);
    padding: 18px;
    text-align: center;
}

.example-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 4px !important;
}

.example-val {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 10px !important;
}

/* =========================================
   Related Tools
========================================= */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
    margin-top: 20px;
}

.tool-card-link {
    text-decoration: none;
    color: inherit;
}

.tool-card-mini {
    background: var(--bg-color);
    border-radius: var(--border-radius-sm);
    padding: 20px 14px;
    text-align: center;
    transition: transform var(--transition), box-shadow var(--transition);
    border: 1.5px solid transparent;
    cursor: pointer;
}

.tool-card-mini:hover {
    transform: translateY(-4px);
    box-shadow: var(--box-shadow-hover);
    border-color: var(--primary-color);
}

.tool-card-mini span {
    font-size: 1.8rem;
    display: block;
    margin-bottom: 8px;
}

.tool-card-mini strong {
    display: block;
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 4px;
}

.tool-card-mini p {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin: 0;
}

/* =========================================
   FAQ Accordion
========================================= */
.faq-item {
    border-bottom: 1px solid var(--border-color);
}

.faq-item:last-child { border-bottom: none; }

.faq-question {
    width: 100%;
    background: none;
    border: none;
    padding: 18px 0;
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    text-align: left;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: color var(--transition);
}

.faq-question::after {
    content: '＋';
    font-size: 1.2rem;
    color: var(--primary-color);
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.faq-question[aria-expanded="true"] {
    color: var(--primary-color);
}

.faq-question[aria-expanded="true"]::after {
    content: '－';
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.3s ease;
}

.faq-answer.open {
    max-height: 300px;
    padding-bottom: 16px;
}

.faq-answer p {
    color: var(--text-muted);
    font-size: 0.92rem;
    margin: 0;
}

/* =========================================
   Privacy Note
========================================= */
.privacy-note {
    border-left: 4px solid var(--primary-color);
}

/* =========================================
   Rich Footer
========================================= */
footer { 
    background: #1A1A2E; 
    color: #E2E8F0; 
    padding: 60px 5% 20px; 
    margin-top: 60px; 
}

.footer-grid {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1.6fr repeat(4, 1fr);
    gap: 30px;
}

.footer-brand p { 
    color: #9AA5C4; 
    font-size: 0.95rem; 
    margin-top: 14px; 
    max-width: 280px; 
    text-align: left;
    line-height: 1.6;
}

.footer-logo { 
    color: #fff; 
    font-size: 1.5rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 6px;
}

.footer-col h4 { 
    font-family: 'Nunito', sans-serif; 
    font-size: 1.1rem; 
    font-weight: 800; 
    margin-bottom: 18px; 
    color: #fff; 
    text-align: left;
}

.footer-col ul { 
    list-style: none; 
    display: flex; 
    flex-direction: column; 
    gap: 12px; 
    padding: 0; 
    align-items: flex-start;
}

.footer-col ul a { 
    color: #9AA5C4; 
    font-size: 0.92rem; 
    font-weight: 600;
    transition: color 0.3s ease, transform 0.3s ease; 
    text-decoration: none; 
    display: inline-block;
}

.footer-col ul a:hover { 
    color: var(--secondary-color); 
    text-decoration: none;
    transform: translateX(4px);
}

.footer-bottom {
    max-width: 1200px;
    margin: 50px auto 0;
    padding-top: 24px;
    border-top: 1px solid rgba(255,255,255,0.08);
    text-align: center;
    color: #8D99AE;
    font-size: 0.9rem;
    font-weight: 600;
}

/* =========================================
   Footer Responsive (Mobile & Tablet)
========================================= */
@media (max-width: 1024px) {
    .footer-grid { 
        grid-template-columns: repeat(3, 1fr); 
        gap: 40px 20px; 
    }
    .footer-brand { 
        grid-column: 1 / -1; 
    }
    .footer-brand p {
        max-width: 500px;
    }
}

@media (max-width: 768px) {
    .footer-grid { 
        grid-template-columns: repeat(2, 1fr); 
    }
}

@media (max-width: 500px) {
    footer {
        padding: 50px 6% 20px;
    }
    .footer-grid { 
        grid-template-columns: 1fr; 
        text-align: center; 
        gap: 36px;
    }
    .footer-logo { 
        justify-content: center; 
    }
    .footer-brand p { 
        margin: 14px auto 0; 
        text-align: center; 
    }
    .footer-col h4 { 
        text-align: center; 
    }
    .footer-col ul { 
        align-items: center; 
    }
    .footer-col ul a:hover {
        transform: translateY(-2px); /* Vertical hover for mobile instead of horizontal */
    }
}
/* =========================================
   Cookie Banner
========================================= */
.cookie-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 800px;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 9999;
    border: 2px solid var(--primary-color);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.5s ease;
}

.cookie-banner.hidden {
    transform: translate(-50%, 150px);
    opacity: 0;
    pointer-events: none;
}

.cookie-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.cookie-icon { font-size: 35px; }

.cookie-content p {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.5;
}

.cookie-content a {
    color: var(--primary-color);
    font-weight: 800;
    text-decoration: underline;
}

.cookie-btn {
    background: linear-gradient(135deg, var(--primary-color), #6C63FF);
    padding: 12px 25px;
    font-size: 1.05rem;
    width: auto;
    white-space: nowrap;
    margin-left: 20px;
    margin-top: 0;
    border: none;
    border-radius: 30px;
    color: white;
    font-weight: 800;
    cursor: pointer;
}

/* =========================================
   Utility
========================================= */
.hidden { display: none !important; }

/* =========================================
   Responsive
========================================= */
@media (max-width: 700px) {
    .calculator-card {
        padding: 28px 20px;
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .info-row {
        grid-template-columns: 1fr 1fr;
    }

    .age-unit strong { font-size: 2rem; }

    .content-section {
        padding: 24px 20px;
    }

    .example-grid {
        grid-template-columns: 1fr;
    }

    .tools-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Cookie Banner Mobile */
    .cookie-banner {
        flex-direction: column;
        gap: 6px;
        padding: 10px 14px;
        bottom: 0;
        border-radius: 16px 16px 0 0;
        border-bottom: none;
        width: 100%;
    }

    .cookie-content {
        flex-direction: row;
        align-items: flex-start;
        text-align: left;
        gap: 8px;
    }

    .cookie-icon { font-size: 18px; margin-top: 2px; }
    .cookie-content p { font-size: 0.75rem; line-height: 1.2; }

    .cookie-btn {
        width: 100%;
        margin-left: 0;
        padding: 8px;
        font-size: 0.88rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .main-age {
        gap: 10px;
    }

    .age-sep { display: none; }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
