/* HEADER */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

#root {
    flex: 1;
    width: 100%;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(180deg, var(--bg-overlay-heavy), var(--bg-overlay));
    backdrop-filter: blur(16px) saturate(150%);
    -webkit-backdrop-filter: blur(16px) saturate(150%);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: grid;
    grid-template-columns: minmax(max-content, 1fr) minmax(0, 760px) minmax(max-content, 1fr);
    align-items: center;
    gap: 1.25rem;
    white-space: nowrap;
    box-shadow: 0 18px 36px -24px var(--bg-scrim-heavy);
    transition: padding 0.2s ease, gap 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

body.is-scrolled .app-header {
    padding: 0.34rem 1.35rem;
    gap: 0.72rem;
    box-shadow: 0 8px 18px -18px var(--bg-scrim-heavy);
}

@media (max-width: 900px) {
    .app-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr) max-content;
        grid-template-areas:
            'logo actions'
            'tabs tabs';
        padding: 1rem;
        gap: 0.9rem 0.85rem;
        align-items: center;
    }

    body.is-scrolled .app-header {
        padding: 0.44rem 0.82rem;
        gap: 0.52rem 0.65rem;
    }

    .logo {
        grid-area: logo;
        width: auto;
        justify-content: flex-start;
        justify-self: start;
        text-align: left;
    }

    .header-actions {
        grid-area: actions;
        width: auto;
        min-width: 0;
        justify-content: flex-end;
        justify-self: end;
        text-align: right;
    }

    .nav-tabs {
        grid-area: tabs;
        width: 100%;
        max-width: none;
        justify-content: stretch;
        justify-self: stretch;
        text-align: center;
    }
}

/* MAIN LAYOUT CENTERED */
.main-layout-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* RESTORED: Centers Home Page Content */
    padding: 2.5rem 1.5rem;
    gap: 2rem;
    max-width: 1320px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.wide-layout {
    max-width: 75vw !important;
}

.wide-layout.agent-open-layout {
    max-width: 82vw !important;
}

@media (max-width: 1100px) {
    .wide-layout.agent-open-layout {
        max-width: 92vw !important;
    }
}

/* SCIENCE / ADVICE GRID */
.science-grid {
    display: grid;
    grid-template-columns: 1fr;
    /* Mobile: 1 column */
    gap: 1.5rem;
    margin-top: 1rem;
    align-items: flex-start;
}

@media (min-width: 768px) {
    .science-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        /* Strict 2x2 Enforced */
    }
}

/* HELP NOTIFICATION STYLES */
/* Moved from components.css for reliability */

#helpToolbar {
    width: 100%;
    padding: 0.5rem 2rem;
    display: flex;
    justify-content: flex-end;
    box-sizing: border-box;
    position: relative;
    z-index: 90;
}

.help-card {
    background: linear-gradient(135deg, var(--bg-surface-alt-heavy), var(--bg-overlay-heavy));
    border: 1px solid var(--border);
    border-top: 4px solid var(--warning-amber);
    border-radius: 8px;
    padding: 1.5rem 2.5rem 1.5rem 1.5rem;
    margin-bottom: 0;
    /* Fixed Gap Issue: Parent flex gap handles it */
    position: relative;
    box-shadow: var(--shadow-card);
    animation: slideIn 0.3s ease-out;
    width: 100%;
    box-sizing: border-box;
    overflow-wrap: break-word;
    /* Fix text wrapping */
}

.help-content h4 {
    color: var(--warning-amber);
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.help-content p {
    color: var(--text-secondary);
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.6;
    /* Better reading */
    white-space: normal;
    /* Force wrap */
    width: 100%;
    max-width: none !important;
}

.help-content {
    width: 100% !important;
}

#helpText {
    max-width: none !important;
    width: 100%;
    white-space: normal;
}

.btn-close-help {
    position: absolute;
    top: 1rem;
    right: 1rem;
    left: auto;
    /* Override previous left positioning */
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.2s;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.btn-close-help:hover {
    opacity: 1;
    background: var(--border-white-subtle);
    color: var(--text-primary);
}

#helpToolbar {
    position: absolute;
    top: 6rem;
    right: 0;
    width: auto;
    padding: 0 2rem;
    z-index: 50;
    pointer-events: none;
    margin: 0;
}

#helpToolbar button {
    pointer-events: auto;
}

/* FOOTER */
.app-footer {
    width: 100%;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 2rem 1.5rem;
    box-sizing: border-box;
}

.app-footer .footer-content {
    max-width: 1320px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
}

.app-footer .footer-brand {
    font-weight: 800;
    font-size: 1.15rem;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-footer .footer-links {
    display: flex;
    gap: 2rem;
}

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

.app-footer .footer-links a:hover {
    color: var(--text-primary);
}

.app-footer .footer-copy {
    color: var(--text-secondary);
    font-size: 0.9rem;
    opacity: 0.8;
}

.app-footer.mini {
    padding: 1rem 2rem;
    background: transparent;
    border-top: 1px solid transparent;
}

.app-footer.mini .footer-content {
    flex-direction: row;
    justify-content: center;
    gap: 1rem;
    max-width: 100%;
}

.app-footer.mini .footer-brand,
.app-footer.mini .footer-links {
    display: none;
}

.app-footer.mini .footer-copy {
    width: 100%;
    text-align: center;
    font-size: 0.8rem;
    opacity: 0.65;
}

@media (max-width: 700px) {
    .app-footer .footer-links {
        gap: 1rem;
    }
}
