/* --- Global Styles & Variables --- */
:root {
    --primary-color: #005a9c;
    --secondary-color: #e6f0f7;
    --dark-color: #222;
    --medium-color: #555;
    --light-color: #fff;
    --bg-color: #fcfdff;
    --bg-color-accent: #f9f9f9;
    --bg-color-hero: #e6f0f7;
    --border-color: #e0e0e0;
    --shadow-color: rgba(0, 0, 0, 0.05);

    --font-family: 'Poppins', sans-serif;
    --container-width: 1140px;
    --border-radius: 8px;
    --transition-speed: 0.3s ease;
}

html.dark-mode {
    --primary-color: #4dabf7;
    /* Lighter blue for dark bg */
    --secondary-color: #1a1a1a;
    --dark-color: #f0f0f0;
    /* Light text */
    --medium-color: #aaa;
    /* Lighter grey text */
    --light-color: #2c2c2c;
    /* Dark card bg */
    --bg-color: #1f1f1f;
    /* Main dark bg */
    --bg-color-accent: #252525;
    --bg-color-hero: #1a1a1a;
    --border-color: #444;
    --shadow-color: rgba(0, 0, 0, 0.2);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* --- GLOBAL RESET (Fixes the width issue) --- */
html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    /* CRITICAL: Cuts off anything sticking out */
}

body {
    font-family: var(--font-family);
    line-height: 1.6;
    color: var(--medium-color);
    background-color: var(--bg-color);
    transition: background-color var(--transition-speed), color var(--transition-speed);
    position: relative;
    /* Ensures header/footer positioning works */
}

/* --- Force Full Width on Bars --- */
.main-header,
.main-footer {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
    /* Includes padding in width */
    margin: 0;
}

.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 20px;
}

h1,
h2,
h3 {
    color: var(--dark-color);
    line-height: 1.2;
    font-weight: 700;
}

h1 {
    font-size: 3rem;
}

h2 {
    font-size: 2.25rem;
    margin-bottom: 1rem;
}

h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

p {
    margin-bottom: 1rem;
}

a {
    color: var(--primary-color);
    text-decoration: none;
}

img {
    max-width: 100%;
}

section {
    padding: 60px 0;
}

.section-subtitle {
    font-size: 1.1rem;
    color: var(--medium-color);
    max-width: 600px;
    margin: 0 auto 30px auto;
    text-align: center;
}

.text-center {
    text-align: center;
}

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 12px 28px;
    border-radius: var(--border-radius);
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition-speed);
    border: 2px solid transparent;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--light-color);
}

.btn-primary:hover {
    background-color: #004a80;
}

html.dark-mode .btn-primary {
    color: #000;
}

html.dark-mode .btn-primary:hover {
    background-color: #74c0fc;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-secondary:hover {
    background-color: var(--primary-color);
    color: var(--light-color);
}

html.dark-mode .btn-secondary {
    background-color: var(--light-color);
}

html.dark-mode .btn-secondary:hover {
    color: #000;
    background-color: var(--primary-color);
}


/* --- Header & Navigation --- */
.main-header .container {
    max-width: 100%;
    /* Makes the header's container span the full width */
    padding: 0 20px;
    /* Adds 20px of space so the logo/buttons don't touch the screen edge */
}

.main-header {
    background: var(--light-color);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background-color var(--transition-speed);
}

.main-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 300;
    color: var(--dark-color);
}

.nav-links {
    display: flex;
    list-style: none;
    margin-left: 0px;
    align-items: center;
}

.nav-links li {
    margin-left: 30px;
}

.nav-links a {
    color: var(--medium-color);
    font-weight: 600;
    transition: var(--transition-speed);
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary-color);
}

#theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--medium-color);
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    margin-left: 20px;
    transition: var(--transition-speed);
}

#theme-toggle:hover {
    background-color: var(--bg-color-accent);
    color: var(--dark-color);
}

.menu-toggle {
    display: none;
}

/* For mobile */

/* Hides elements */
.nav-hidden {
    display: none;
}

.nav-auth #nav-link-admin-dashboard a.btn-primary {
    color: #fff !important;
    /* Force white text on the blue button */
}

/* * START: ADD THIS MISSING CODE 
 * This is the anti-flash code that fixes your bug.
*/
html.user-is-logged-in #nav-link-login {
    display: none !important;
}

html.user-is-logged-in #nav-link-signup {
    display: none !important;
}

/* Auth links section */
.nav-auth {
    margin-left: auto;
    /* Pushes auth links to the right */
    gap: 10px;
}

.nav-auth li {
    margin-left: 0;
    /* This removes the 30px margin */
}

.nav-auth #nav-link-signup a.btn-primary {
    color: #ededed;
}

.nav-auth #nav-link-login a.btn-secondary:hover {
    color: #ededed;
}

.nav-auth #nav-link-dashboard a.btn-primary {
    color: #ededed;
}



/* Mobile responsive rules for new links */
@media (max-width: 768px) {

    .nav-links {
        margin-top: 20px;
    }

    .service-grid,
    .steps-grid {
        grid-template-columns: 1fr !important;
    }

    /* Stack auth links inside the mobile menu */
    .nav-auth {
        margin-left: 0px;
        flex-direction: column;
        width: 100%;
        gap: 1px;
        margin-top: 225px;
        border-top: 1px solid var(--border-color);
        padding-top: 0px;
    }

    .nav-auth .btn {
        text-align: center;
    }

    #signup-options-container {
        /* Force layout to be Flex Column (Vertical) */
        display: flex !important;
        flex-direction: column !important;
        gap: 20px !important;

        /* Reset any Grid properties that might cause overflow */
        grid-template-columns: 1fr !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Ensure the cards inside don't have fixed widths */
    #signup-options-container .service-card {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        box-sizing: border-box;
    }

    .service-grid,
    .steps-grid,
    .insights-grid {
        display: flex !important;
        flex-direction: column;
        gap: 20px;
        width: 100%;
    }

    /* 2. Make cards fit the screen */
    .service-card,
    .step-card,
    .insight-card {
        width: 100%;
        min-width: 0;
        /* Allows flex item to shrink below content size */
        box-sizing: border-box;
        /* Include padding in width */

        /* Reduce padding so it fits on small screens */
        padding: 25px 20px !important;
    }

    /* 3. Ensure Container doesn't push them out */
    .container {
        padding: 0 15px;
        /* Reduce global side padding on mobile */
        width: 100%;
        overflow: hidden;
        /* Contain children */
    }

    /* 4. Fix Hero Text wrapping */
    h1 {
        font-size: 2rem;
        /* Smaller font to prevent overflow */
        word-wrap: break-word;
    }

}

/* --- Hero Section --- */
.hero {
    background-color: var(--bg-color-hero);
    padding: 80px 0;
    text-align: center;
    transition: background-color var(--transition-speed);
}

.hero h1 {
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-size: 1.2rem;
    max-width: 700px;
    margin: 0 auto 30px auto;
    color: var(--dark-color);
}

.hero-cta .btn {
    margin: 0 10px;
}

/* --- Services Overview --- */
.services-overview {
    background: var(--light-color);
    text-align: center;
    transition: background-color var(--transition-speed);
}

.service-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.service-card {
    background: var(--light-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 30px;
    text-align: left;
    box-shadow: 0 4px 12px var(--shadow-color);
    transition: var(--transition-speed);
}

.service-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px var(--shadow-color);
}

.learn-more {
    font-weight: 600;
}

/* --- How It Works --- */
.how-it-works {
    background: var(--bg-color-accent);
    text-align: center;
    transition: background-color var(--transition-speed);
}

.steps-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    margin-top: 40px;
    margin-bottom: 40px;
}

.step-card {
    padding: 20px;
}

.step-card span {
    display: block;
    width: 50px;
    height: 50px;
    line-height: 50px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 auto 20px auto;
}

html.dark-mode .step-card span {
    color: #000;
}

.step-card h3 {
    color: var(--primary-color);
}

/* --- Join Experts Section --- */
.join-experts {
    background: var(--light-color);
    transition: background-color var(--transition-speed);
}

.join-experts .container {
    display: flex;
    align-items: center;
    gap: 50px;
}

.join-content {
    flex: 1;
}

.join-content h2 {
    color: var(--primary-color);
}

.join-content ul {
    list-style: '✓';
    padding-left: 20px;
    margin-bottom: 30px;
}

.join-content li {
    margin-bottom: 10px;
    padding-left: 10px;
}

.join-image {
    flex: 1;
}

.join-image img {
    border-radius: var(--border-radius);
    box-shadow: 0 10px 20px var(--shadow-color);
}

/* --- Featured Insights (Blog Preview) --- */
.featured-insights {
    background: var(--bg-color-hero);
    text-align: center;
    transition: background-color var(--transition-speed);
}

.insights-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
    margin-top: 40px;
}

.insight-card {
    background: var(--light-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 4px 12px var(--shadow-color);
    text-align: left;
    transition: var(--transition-speed);
}

.insight-card:hover {
    box-shadow: 0 8px 16px var(--shadow-color);
    transform: translateY(-5px);
}

.insight-card img {
    width: 100%;
    height: 250px;
    object-fit: cover;
}

.insight-content {
    padding: 25px;
}

.insight-category {
    display: inline-block;
    padding: 5px 10px;
    background: var(--bg-color-accent);
    border-radius: 5px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 10px;
}

html.dark-mode .insight-category {
    background: var(--bg-color);
}

/* --- Footer --- */
.main-footer {
    background: #333;
    color: #ccc;
    padding: 60px 0 20px 0;
}

html.dark-mode .main-footer {
    background: #1a1a1a;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 40px;
    margin-bottom: 40px;
}

.footer-about h3 {
    color: #fff;
}

.footer-about p {
    color: #ccc;
}

.footer-links h4 {
    color: #fff;
    margin-bottom: 15px;
}

.footer-links ul {
    list-style: none;
}

.footer-links li {
    margin-bottom: 10px;
}

.footer-links a {
    color: #ccc;
    transition: var(--transition-speed);
}

.footer-links a:hover {
    color: var(--light-color);
}

.social-icons a {
    color: #ccc;
    margin-right: 15px;
    font-size: 1.2rem;
}

.social-icons a:hover {
    color: #fff;
}

.footer-bottom {
    text-align: center;
    border-top: 1px solid #555;
    padding-top: 20px;
    font-size: 0.9rem;
}

/* --- Responsive Design --- */
@media (max-width: 992px) {

    .service-grid,
    .steps-grid {
        grid-template-columns: 1fr;
    }

    .insights-grid {
        grid-template-columns: 1fr;
    }

    .join-experts .container {
        flex-direction: column;
    }

    .join-image {
        order: -1;
    }

    /* Put image on top */

    .footer-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    h1 {
        font-size: 2.5rem;
    }

    h2 {
        font-size: 1.75rem;
    }

    /* Mobile Nav */
    .nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        position: absolute;
        top: 80px;
        left: 0;
        background: var(--light-color);
        padding: 20px;
        border-bottom: 1px solid var(--border-color);
    }

    .nav-links.active {
        display: flex;
    }

    .nav-links li {
        margin: 10px 0;
    }

    .nav-auth li {
        margin: 7px 0;
    }

    #theme-toggle {
        margin-left: auto;
        /* Push to the right before menu */
        margin-right: 15px;
    }

    .menu-toggle {
        display: block;
        background: none;
        border: 1px solid #ccc;
        padding: 8px 12px;
        border-radius: 5px;
        cursor: pointer;
        color: var(--medium-color);
    }

    .footer-grid {
        grid-template-columns: 1fr;
    }
}

/* Logo Styling for Theme Switch */

.main-nav .logo img {
    height: 60px;
    width: auto;
    display: none;
    /* Hide all logos by default */
    margin-left: 20px;
}

/* Show light logo by default */
.main-nav .logo .logo {
    display: block;
}

/* --- New Dashboard Content Header --- */
.dashboard-content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 20px;

    /* NEW: Add wrapping and gap for buttons */
    flex-wrap: wrap;
    gap: 15px;
}

.dashboard-content-header h2 {
    color: var(--dark-color);
    margin: 0;
    /* NEW: Reduced font size */
    font-size: 1.8rem;
}

/* This targets the <div> holding the buttons */
.dashboard-content-header>div {
    display: flex;
    flex-wrap: nowrap;
    /* Keep buttons on one line together */
    gap: 10px;
    /* This adds space *between* the buttons */
    margin-left: auto;
    /* Push to the right */
}

/* Make the button smaller on this header */
.dashboard-content-header .btn {
    padding: 10px 20px;
    font-size: 0.9rem;
    white-space: nowrap;
    /* Stop text like "Submit New Project" from breaking */
}

/* On small screens, stack the header items */
@media (max-width: 500px) {
    .dashboard-content-header {
        flex-direction: column;
        /* Stack h2 and button div */
        align-items: flex-start;
        /* Align to the left */
    }

    .dashboard-content-header>div {
        width: 100%;
        margin-left: 0;
    }

    .dashboard-content-header .btn {
        flex-grow: 1;
        /* Make buttons fill the space */
        text-align: center;
    }
}

/* --- Mobile Responsive Table Scroll --- */
@media (max-width: 768px) {

    /* This is the new wrapper div */
    .table-scroll-wrapper {
        width: 100%;
        overflow-x: auto;
        /* This adds the horizontal scrollbar */
        -webkit-overflow-scrolling: touch;
        /* Smooth scrolling on iOS */
    }

    /* This forces the table to be as wide as its content */
    .table-scroll-wrapper .dashboard-table {
        min-width: 600px;
        /* Force it to be wide, or use "auto" */
    }

    /* This stops text from wrapping, which helps the scroll */
    .dashboard-table th,
    .dashboard-table td {
        white-space: nowrap;

    }
}

/* --- Terms & Conditions Modal Styles --- */
/* --- Terms & Conditions Modal Styles --- */
.terms-content {
    text-align: left !important;
    color: #333 !important;
    /* Force dark text color */
}

.terms-content h3,
.terms-content h4 {
    text-align: left !important;
    margin-bottom: 10px;
    color: #111 !important;
    /* Force darker headers */
}

.terms-content p,
.terms-content ul,
.terms-content li {
    text-align: left !important;
    margin-bottom: 10px;
    color: #333 !important;
    /* Force dark text */
}

.terms-content ul {
    padding-left: 20px;
    list-style-type: disc;
}

/* Optional: Ensure Dark Mode readability if the modal background changes */
html.dark-mode .terms-content,
html.dark-mode .terms-content h3,
html.dark-mode .terms-content h4,
html.dark-mode .terms-content p,
html.dark-mode .terms-content li {
    color: #eee !important;
    /* Light text for dark mode */
}

.terms-content ul {
    padding-left: 20px;
    list-style-type: disc;
}