/* =========================================
   1. VARIABLES & BASE STYLES
   ========================================= */
:root {
    /* Exact SEC / USWDS Colors */
    --sec-dark-blue: #112e51;
    --sec-med-blue: #005ea2;
    --sec-light-blue: #e1f3f8;
    --sec-bg-gray: #f1f1f1;
    --sec-border-gray: #565c65;
    --sec-text-main: #1b1b1b;
    --sec-white: #ffffff;
    
    /* NEW: Dedicated variables to fix Dark Mode visibility */
    --btn-text-color: #ffffff;
    --addon-bg-color: #e4e2e0;
    
    /* Chart Colors */
    --chart-principal: #005ea2;
    --chart-contributions: #73b3e7;
    --chart-interest: #2e8540;
    --chart-upper: #00a6d2;
    --chart-lower: #d83933;
}

body {
    font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    color: var(--sec-text-main);
    background-color: var(--sec-white);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

.container {
    max-width: 1200px; /* Widened to accommodate both layouts */
    margin: 40px auto;
    padding: 0 20px;
}

h1 {
    color: var(--sec-dark-blue);
    font-size: 2.5rem;
    margin-top: 0;
    margin-bottom: 20px;
    font-weight: 700;
}

/* =========================================
   2. HEADER & NAVIGATION (WITH DROPDOWN)
   ========================================= */
header {
    background-color: var(--sec-white);
    border-bottom: 2px solid var(--sec-bg-gray);
    padding: 15px 20px;
}
nav {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 20px;
}
nav a {
    color: var(--sec-med-blue);
    text-decoration: none;
    font-weight: 700;
}
nav a:hover { text-decoration: underline; }

/* Dropdown */
.dropdown { position: relative; display: inline-block; }
.dropdown .dropbtn { cursor: pointer; font-weight: 700; color: var(--sec-med-blue); }
.dropdown-content {
    display: none; 
    position: absolute; 
    background-color: var(--sec-white);
    min-width: 260px; 
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.1); 
    z-index: 100;
    border: 1px solid var(--sec-border-gray); 
    border-top: 3px solid var(--sec-med-blue);
    top: 100%; 
    left: 0; 
    margin-top: 0; /* <-- This fixes the dead zone */
}
.dropdown-content a {
    color: var(--sec-text-main); padding: 12px 16px; display: block;
    font-weight: 400; border-bottom: 1px solid var(--sec-bg-gray);
}
.dropdown-content a:hover { background-color: var(--sec-light-blue); text-decoration: none; color: var(--sec-dark-blue); }
.dropdown:hover .dropdown-content { display: block; }

/* =========================================
   3. SHARED FORM ELEMENTS (INPUTS & BUTTONS)
   ========================================= */
.form-panel {
    background-color: var(--sec-bg-gray);
    padding: 25px 30px;
    border-top: 4px solid var(--sec-med-blue);
    margin-bottom: 30px;
}

.form-group { margin-bottom: 20px; }
label { display: block; font-weight: 700; margin-bottom: 8px; color: var(--sec-text-main); }

.input-group {
    display: flex; align-items: stretch; background: var(--sec-white);
    border: 1px solid var(--sec-border-gray); border-radius: 0;
}
.input-group:focus-within { outline: 4px solid #2491ff; }

.input-addon {
    background-color: var(--addon-bg-color); /* This fixes the invisible $ and % */
    color: var(--sec-text-main); 
    padding: 10px 15px;
    font-weight: 700; 
    display: flex; 
    align-items: center; 
    border-right: 1px solid var(--sec-border-gray);
}

.input-addon.right { border-right: none; border-left: 1px solid var(--sec-border-gray); }

input[type="number"], input[type="text"], select {
    flex: 1; border: none; padding: 10px 15px; font-size: 1.1rem;
    font-family: inherit; color: var(--sec-text-main); width: 100%;
    outline: none; background: transparent;
}
input[readonly] { background-color: var(--sec-light-blue); font-weight: 700; color: var(--sec-dark-blue); }

.calculate-btn {
    background-color: var(--sec-med-blue); 
    color: var(--btn-text-color); /* This fixes the dark button text */
    border: none;
    padding: 12px 25px; 
    font-size: 1.1rem; 
    font-weight: 700; 
    cursor: pointer;
    text-align: center; 
    transition: background-color 0.2s; 
    width: 100%; 
    height: 46px;
}
.calculate-btn:hover { background-color: var(--sec-dark-blue); }

/* =========================================
   4. INDEX.HTML SPECIFIC STYLES
   ========================================= */
.subtitle { font-size: 1.1rem; color: var(--sec-border-gray); margin-bottom: 40px; }
.calc-row { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-end; }
.edu-section { margin-top: 50px; padding-top: 30px; border-top: 2px solid var(--sec-bg-gray); }
.tools-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin-top: 20px; }
.tool-card { background: var(--sec-white); border: 1px solid var(--sec-border-gray); padding: 20px; border-top: 4px solid var(--sec-med-blue); }

/* =========================================
   5. COMPOUND INTEREST SPECIFIC STYLES
   ========================================= */
.calculator-grid { display: flex; flex-wrap: wrap; gap: 40px; align-items: flex-start; }
.calculator-grid .form-panel { flex: 1; min-width: 320px; }
.step-section { margin-bottom: 30px; }
.step-section h2 { font-size: 1.25rem; color: var(--sec-dark-blue); margin-top: 0; margin-bottom: 15px; }

.results-panel { flex: 1.5; min-width: 400px; display: none; }
.results-header { margin-bottom: 30px; }
.results-header p { font-size: 1.25rem; margin: 0 0 5px 0; }
.results-header h2 { font-size: 3rem; color: var(--sec-dark-blue); margin: 0; line-height: 1.1; }

.chart-container { position: relative; height: 400px; width: 100%; margin-bottom: 40px; }

.table-container h3 { font-size: 1.5rem; color: var(--sec-dark-blue); margin-bottom: 15px; }
table { width: 100%; border-collapse: collapse; font-size: 1rem; }
th, td { border: 1px solid var(--sec-border-gray); padding: 12px; text-align: right; }
th { background-color: var(--sec-bg-gray); color: var(--sec-dark-blue); text-align: center; }
td:first-child, th:first-child { text-align: center; }

/* =========================================
   6. FOOTER & DARK MODE OVERRIDES
   ========================================= */
footer { text-align: center; margin: 50px 0 20px 0; font-size: 0.9rem; color: var(--sec-border-gray); }
footer a { color: var(--sec-med-blue); text-decoration: none; margin: 0 10px; }
footer a:hover { text-decoration: underline; }

body.dark-mode {
    --sec-white: #121212;         /* Dark page background */
    --sec-bg-gray: #1e1e1e;       /* Dark form panels */
    --sec-text-main: #f1f1f1;     /* Bright white text for readability */
    --sec-border-gray: #444444;   
    
    --sec-dark-blue: #90caf9;     /* Light blue for headings */
    --sec-med-blue: #1976d2;      /* Medium blue for links and buttons */
    --sec-light-blue: #0d47a1;    /* Darker blue for hover states */

    /* NEW: Keep button text white, and make addon boxes dark */
    --btn-text-color: #ffffff;    
    --addon-bg-color: #2c2c2c;    
}

.theme-toggle {
    background: transparent; border: 1px solid var(--sec-border-gray);
    color: var(--sec-text-main); padding: 6px 12px; cursor: pointer;
    border-radius: 4px; font-weight: bold; margin-left: auto; transition: 0.3s;
}
.theme-toggle:hover { background: var(--sec-bg-gray); }

/* Responsive Adjustments */

/* =========================================
   11. HAMBURGER MENU BUTTON
   ========================================= */
.mobile-menu-toggle {
    display: none; /* Hidden on desktop */
    background: transparent;
    color: var(--sec-dark-blue);
    border: 2px solid var(--sec-border-gray);
    padding: 8px 15px;
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 4px;
    font-weight: 700;
    width: 100%;
    text-align: left;
    transition: background 0.2s;
}

body.dark-mode .mobile-menu-toggle {
    color: var(--sec-text-main);
}

@media (max-width: 768px) {
    .calc-row, .calculator-grid { flex-direction: column; align-items: stretch; }
    .results-panel { min-width: 100%; }
}

/* =========================================
   7. TEXT PAGES & CONTACT FORM 
   ========================================= */
.content-panel {
    background-color: var(--sec-white);
    padding: 40px;
    border-top: 4px solid var(--sec-med-blue);
    border: 1px solid var(--sec-border-gray);
    margin-bottom: 30px;
}

.content-panel h2, .content-panel h3 {
    color: var(--sec-dark-blue);
    margin-top: 30px;
}

.content-panel p, .content-panel li {
    font-size: 1.1rem;
    line-height: 1.8;
    margin-bottom: 15px;
}

.content-panel a {
    color: var(--sec-med-blue);
    font-weight: 700;
}

/* Contact Form Specifics */
textarea.standard-input {
    width: 100%;
    padding: 12px 15px;
    font-size: 1.1rem;
    border: 1px solid var(--sec-border-gray);
    font-family: inherit;
    color: var(--sec-text-main);
    background: var(--sec-white);
    resize: vertical;
    min-height: 150px;
    box-sizing: border-box;
    margin-bottom: 20px;
}
textarea.standard-input:focus {
    outline: 4px solid #2491ff;
}
input.standard-input {
    width: 100%;
    padding: 12px 15px;
    font-size: 1.1rem;
    border: 1px solid var(--sec-border-gray);
    font-family: inherit;
    color: var(--sec-text-main);
    background: var(--sec-white);
    box-sizing: border-box;
    margin-bottom: 20px;
}
input.standard-input:focus {
    outline: 4px solid #2491ff;
}

/* =========================================
   8. BLOG POSTS & GUIDES GRID
   ========================================= */
.blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 30px;
    margin-bottom: 50px;
}

.post-card {
    background-color: var(--sec-white);
    border: 1px solid var(--sec-border-gray);
    border-top: 4px solid var(--sec-dark-blue);
    padding: 30px;
    border-radius: 4px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.post-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
}

.post-card h2 {
    color: var(--sec-dark-blue);
    font-size: 1.4rem;
    margin-top: 0;
    margin-bottom: 15px;
}

.post-card a {
    color: var(--sec-med-blue);
    text-decoration: none;
    font-weight: 700;
}

.post-card a:hover {
    text-decoration: underline;
}

.post-card p {
    color: var(--sec-text-main);
    font-size: 1.1rem;
    margin-bottom: 20px;
    line-height: 1.6;
}

.post-date {
    font-size: 0.9rem;
    color: var(--sec-border-gray);
    margin-bottom: 10px;
    display: block;
    font-weight: 600;
}
/* =========================================
   9. ALERT & TROUBLESHOOTING BOXES
   ========================================= */
.alert-box {
    background-color: #fdf2f2;
    border-left: 5px solid #d9534f;
    padding: 20px;
    margin: 20px 0;
    border-radius: 5px;
    color: #1b1b1b; /* Forces dark text in light mode */
}

.alert-box strong {
    color: #d9534f;
}

/* Dark Mode Overrides for the Alert Box */
body.dark-mode .alert-box {
    background-color: #2a0a0a; /* Very dark red so white text is readable */
    border-left-color: #ff6b6b; /* Brighter red border for contrast */
    color: var(--sec-text-main); /* Uses your bright white text */
}

body.dark-mode .alert-box strong {
    color: #ff6b6b; /* Brighter red text for the bold part */
}


/* =========================================
   10. MOBILE RESPONSIVE NAVIGATION
   ========================================= */
@media (max-width: 768px) {
    /* Stack the navigation vertically */
   /* Show the hamburger button on mobile */
    .mobile-menu-toggle {
        display: block; 
        margin-bottom: 15px;
    }

    /* Hide the navigation by default on mobile */
    header nav {
        display: none !important; /* Overrides the inline HTML style */
        flex-direction: column;
        align-items: flex-start !important; 
        gap: 10px;
    }

    /* Show the navigation when the 'active' class is added via JavaScript */
    header nav.active {
        display: flex !important;
    }

    /* Make links larger for thumb tapping */
    nav a {
        padding: 8px 0;
        display: block;
        width: 100%;
        border-bottom: 1px solid var(--sec-bg-gray);
    }

    nav a:last-of-type {
        border-bottom: none;
    }

    /* Adjust the dropdown to push content down instead of floating over it */
    .dropdown {
        width: 100%;
    }

    .dropdown .dropbtn {
        width: 100%;
        padding: 8px 0;
        display: block;
        border-bottom: 1px solid var(--sec-bg-gray);
    }

    .dropdown-content {
        position: static; /* Removes the floating behavior */
        box-shadow: none;
        border: none;
        border-left: 4px solid var(--sec-med-blue); /* Creates a nice indent */
        margin-top: 5px;
        padding-left: 10px;
        background-color: transparent;
    }

    .dropdown-content a {
        padding: 10px 15px;
    }

    /* Make the Dark Mode button full width at the bottom */
    .theme-toggle {
        margin-left: 0;
        margin-top: 15px;
        width: 100%;
        padding: 12px;
    }
}

.word-helper {
    font-size: 0.85rem;
    color: #8898aa; /* Medium-light gray that contrasts well against both white and dark backgrounds */
    margin-top: 4px;
    font-style: italic;
    font-weight: 600;
    min-height: 18px; /* Keeps the spacing consistent even when empty */
    display: block;
}

/* =========================================
   12. NESTED DROPDOWN (MUTUAL FUNDS)
   ========================================= */
.nested-dropdown {
    position: relative;
}

.nested-dropbtn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-weight: 600;
}

/* The sub-menu box */
.nested-dropdown-content {
    display: none;
    position: absolute;
    left: 100%; /* Opens to the right of the main dropdown */
    top: 0;
    min-width: 200px;
    background-color: var(--primary-bg, #ffffff);
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.1);
    z-index: 3;
    border-radius: 4px;
}

/* Keep formatting identical to main dropdown links */
.nested-dropdown-content a {
    padding: 12px 16px;
    display: block;
    text-decoration: none;
}

/* Show the nested menu when hovered (Desktop) */
@media (min-width: 769px) {
    .nested-dropdown:hover .nested-dropdown-content {
        display: block;
    }
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .nested-dropdown-content {
        position: static;
        box-shadow: none;
        padding-left: 15px; /* Indent it slightly on mobile */
        border-left: 3px solid var(--sec-med-blue);
        background-color: transparent;
    }
    
    /* On mobile, tapping shows the menu */
    .nested-dropdown:hover .nested-dropdown-content,
    .nested-dropdown:focus-within .nested-dropdown-content {
        display: block;
    }
}

/* =========================================
   13. SEO CONTENT SECTIONS
   ========================================= */
.seo-article {
    margin-top: 50px;
    padding-top: 40px;
    border-top: 2px solid var(--sec-bg-gray);
    line-height: 1.7;
    color: var(--sec-text-main);
    max-width: 900px; /* Keeps text at a comfortable reading width */
    margin-left: auto;
    margin-right: auto;
}

.seo-article h2 {
    color: var(--sec-dark-blue);
    margin-top: 35px;
    margin-bottom: 15px;
    font-size: 1.8rem;
}

.seo-article h3 {
    color: var(--sec-med-blue);
    margin-top: 25px;
    margin-bottom: 10px;
    font-size: 1.4rem;
}

.seo-article p {
    margin-bottom: 15px;
}

.seo-article ul {
    margin-left: 20px;
    margin-bottom: 20px;
}

.seo-article li {
    margin-bottom: 8px;
}