/* ============================================================
   components.css — header, nav/dropdown, sidebar, cards,
   info card, option tabs, buttons, modal.
   ============================================================ */

/* --- Sticky brand header --- */
header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--sl-navy);
    color: #fff;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #fff;
}

.brand img.brand-logo {
    height: 42px;
    width: auto;
    display: block;
}

.brand-text {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    white-space: nowrap;
}

/* --- Top navigation (right-aligned, next to the user menu) --- */
nav.top-nav {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-left: auto;   /* push the nav (and the user menu after it) to the right */
    margin-right: 24px;  /* space between the nav and the user chip */
}

.top-nav a, .dropbtn {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 8px 16px;
    border-radius: 4px;
    transition: 0.2s;
    text-transform: uppercase;
    border: none;
    background: transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    font-family: inherit;
}

.top-nav a:hover, .dropdown:hover .dropbtn {
    color: #fff;
    background: rgba(255, 255, 255, 0.10);
}

.top-nav a.active, .dropdown.active .dropbtn {
    color: #fff;
    background: rgba(255, 255, 255, 0.20);
}

/* --- Dropdown menu --- */
.dropdown { position: relative; display: inline-block; }

.dropdown-content {
    display: none;
    position: absolute;
    background: #fff;
    min-width: 210px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
    border-radius: 6px;
    z-index: 1050;
    top: 100%;
    left: 0;
    border: 1px solid var(--border);
    overflow: visible;
    margin-top: 5px;
}

/* Transparent "bridge" over the 5px gap between the button and the menu so
   moving the cursor down into the menu never crosses a non-hovered dead zone
   (which would close the menu before you could click an item). */
.dropdown-content::before {
    content: "";
    position: absolute;
    top: -7px;
    left: 0;
    right: 0;
    height: 7px;
    background: transparent;
}

.dropdown-content a {
    color: var(--text-dark);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: none;
    border-bottom: 1px solid #F1F5F9;
    transition: background 0.2s;
}
.dropdown-content a:last-child { border-bottom: none; }
.dropdown-content a:hover { background: #F1F5F9; color: var(--sl-navy); }
.dropdown:hover .dropdown-content,
.dropdown:focus-within .dropdown-content { display: block; }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: 0.2s;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.2;
    border: 1.5px solid transparent;
    appearance: none;
}

.btn-primary {
    background: var(--sl-navy);
    color: #fff;
    border-color: var(--sl-navy);
}
.btn-primary:hover { background: var(--sl-navy-accent); border-color: var(--sl-navy-accent); }

.btn-outline {
    background: transparent;
    color: #fff;
    border-color: rgba(255, 255, 255, 0.55);
}
.btn-outline:hover { background: rgba(255, 255, 255, 0.10); border-color: #fff; }

/* --- Home hero --- */
.hero-banner {
    background-color: var(--sl-navy);
    background-image:
        linear-gradient(135deg, #001227 0%, var(--sl-navy-accent) 100%),
        linear-gradient(to right, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 100% 100%, 24px 24px, 24px 24px;
    border-radius: 12px;
    padding: 50px;
    color: #fff;
    border-bottom: 5px solid var(--sl-silver);
    margin-bottom: 40px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}
.hero-banner h1 {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 20px;
    letter-spacing: -0.5px;
}
.hero-banner p {
    font-size: 1rem;
    color: #CBD5E1;
    max-width: 800px;
    margin-bottom: 30px;
    line-height: 1.6;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* --- Home grade cards --- */
.edu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}
.edu-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 200px;
    cursor: pointer;
    transition: 0.2s;
    text-decoration: none;
    color: inherit;
}
.edu-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.06);
    border-color: var(--border-strong);
}
.card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.card-icon-box {
    background: #F1F5F9;
    color: var(--sl-slate);
    padding: 10px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.card-icon-box.active-navy { background: #E6EDF6; color: var(--sl-navy); }
.card-icon-box svg { width: 24px; height: 24px; }

.card-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}
.card-badge.badge-active { background: #E6EDF6; color: var(--sl-navy); }
.card-badge.badge-ready { background: #F1F5F9; color: var(--sl-slate); }

.card-content h3 { font-size: 1.1rem; font-weight: 700; color: var(--text-dark); margin-bottom: 8px; }
.card-content p { font-size: 0.88rem; color: var(--text-muted); line-height: 1.5; }

/* --- Sidebar (space types / systems / material divisions) --- */
aside.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 30px 20px;
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
}
.sidebar-title {
    font-size: 0.7rem;
    color: var(--sl-slate);
    text-transform: uppercase;
    margin-bottom: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.side-nav { list-style: none; }
.side-nav li { margin-bottom: 6px; }
.side-nav a {
    display: block;
    padding: 10px 14px;
    color: var(--sl-slate);
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.88rem;
    transition: 0.2s;
    cursor: pointer;
}
.side-nav a:hover { background: var(--bg-light); color: var(--sl-navy); }
.side-nav a.active {
    background: #F1F5F9;
    color: var(--sl-navy);
    font-weight: 600;
    border-left: 3px solid var(--sl-navy);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* Inert "+ Add" placeholder — hidden in P0, revealed for admins in a later phase. */
.side-add-placeholder {
    margin-top: 14px;
    padding: 10px 14px;
    border: 1px dashed var(--border-strong);
    border-radius: 6px;
    color: var(--sl-slate);
    font-size: 0.82rem;
    font-weight: 600;
    text-align: center;
    opacity: 0.55;
    display: none;              /* inert for P0 */
}

/* --- Option tab bar --- */
.options-tab-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 8px;
    flex-wrap: wrap;
}
.option-tab-btn {
    background: #F1F5F9;
    color: var(--sl-slate);
    border: 1px solid var(--border-strong);
    padding: 8px 18px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
    text-transform: uppercase;
    font-family: inherit;
}
.option-tab-btn:hover { background: var(--border); color: var(--text-dark); }
.option-tab-btn.active { background: var(--sl-navy); color: #fff; border-color: var(--sl-navy); }

/* --- Workspace grid (info card + visuals) --- */
.workspace-grid {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

/* --- Info card (spec rows) --- */
.info-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
    align-self: start;
}
.info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    border-bottom: 1.5px solid #F1F5F9;
    padding-bottom: 12px;
}
.info-header h3 { font-size: 1.25rem; color: var(--sl-navy); font-weight: 700; }

.metrics-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
    border-bottom: 1.5px solid #F1F5F9;
    padding-bottom: 18px;
}
.metric-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.88rem; gap: 12px; }
.metric-label {
    color: var(--sl-slate);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.3px;
}
.metric-val { color: var(--text-dark); font-weight: 700; text-align: right; }

.schools-section h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--sl-slate);
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}
.schools-section ul { list-style: none; padding-left: 0; }
.schools-section li {
    position: relative;
    padding-left: 14px;
    font-size: 0.85rem;
    color: #334155;
    font-weight: 500;
    margin-bottom: 4px;
}
.schools-section li::before {
    content: "\2022";
    color: var(--sl-silver);
    font-weight: 700;
    position: absolute;
    left: 0;
    top: 0;
}

/* --- Visuals stack (axon + floor plan) --- */
.visuals-stack { display: flex; flex-direction: column; gap: 24px; }
.img-container {
    background: #F1F5F9;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 480px;
    border: 1px dashed var(--border-strong);
    padding: 16px;
    position: relative;
}
.img-container img {
    width: var(--axon-image-scale);
    height: auto;
    max-height: 440px;
    object-fit: contain;
    display: block;
}
.img-tag {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(15, 23, 42, 0.72);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    z-index: 10;
}

/* Styled placeholder fallback (replaces legacy handleImageError). */
.img-fallback-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--sl-slate);
}
.img-fallback-box svg { width: 56px; height: 56px; color: var(--border-strong); margin-bottom: 12px; }
.img-fallback-box .fallback-label { font-weight: 600; font-size: 0.95rem; margin-bottom: 4px; }
.img-fallback-box .fallback-path {
    font-family: monospace;
    font-size: 0.72rem;
    color: var(--sl-slate);
    max-width: 320px;
    word-wrap: break-word;
}

/* --- Technical spec sections (the 5 legacy cards, rendered inline) --- */
.standards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-top: 30px;
}
/* Stacked variant: sections run full-width, one below another (Building Systems). */
.standards-grid--stack {
    grid-template-columns: 1fr;
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}
.card h2 { margin-bottom: 20px; font-size: 1.05rem; color: var(--sl-navy); font-weight: 700; }
.std-item { margin-bottom: 16px; }
.std-item h3 {
    font-size: 0.75rem;
    color: var(--sl-slate);
    text-transform: uppercase;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}
.std-item p { font-size: 0.9rem; color: var(--text-dark); font-weight: 500; }

.card-fire { border-top: 3.5px solid var(--fire); }
.card-fire h2 { color: var(--fire); }

/* --- Directory pages (Building Systems / Standard Materials detail panes) --- */
.doc-directory-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 30px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 30px;
    min-height: 500px;
}
.doc-dir-nav { border-right: 1.5px solid #F1F5F9; padding-right: 20px; }
.doc-dir-nav h3 {
    font-size: 0.8rem;
    color: var(--sl-slate);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 15px;
}
.doc-dir-group { margin-bottom: 20px; }
.doc-dir-group > .group-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--sl-navy);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.doc-dir-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.doc-dir-list a {
    display: block;
    padding: 10px 14px;
    color: var(--text-dark);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    border-radius: 6px;
    transition: 0.2s;
    cursor: pointer;
}
.doc-dir-list a:hover { background: var(--bg-light); color: var(--sl-navy); }
.doc-dir-list a.active { background: #F1F5F9; color: var(--sl-navy); font-weight: 600; }

.doc-pane-content { padding: 10px; }
.doc-pane-content h2 { font-size: 1.5rem; color: var(--sl-navy); margin-bottom: 12px; font-weight: 700; }
.doc-pane-content h3 { font-size: 1rem; color: var(--text-dark); margin-top: 20px; margin-bottom: 8px; font-weight: 600; }
.doc-pane-content p { font-size: 0.92rem; color: var(--sl-slate); margin-bottom: 15px; line-height: 1.6; }
.doc-pane-content .csi-tag {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--sl-navy);
    background: #E6EDF6;
    padding: 3px 8px;
    border-radius: 4px;
    margin: 0 6px 6px 0;
}
.empty-state {
    padding: 30px;
    text-align: center;
    color: var(--sl-slate);
    font-size: 0.95rem;
}

/* --- Not-found view --- */
.notfound {
    max-width: 640px;
    margin: 80px auto;
    text-align: center;
    padding: 40px;
}
.notfound h1 { font-size: 2rem; color: var(--sl-navy); margin-bottom: 12px; }
.notfound p { color: var(--sl-slate); margin-bottom: 24px; }

/* --- Modal (retained shell; P0 renders spec sections inline instead) --- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.55); }
.modal-content {
    position: relative;
    background: #fff;
    border-radius: 12px;
    max-width: 640px;
    width: calc(100% - 40px);
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1.1rem; color: var(--sl-navy); }
.close-modal { cursor: pointer; font-size: 1.5rem; color: var(--sl-slate); line-height: 1; }
.modal-body { padding: 24px; }

/* ============================================================
   P2 additions — login gate, header user menu, content blocks.
   ============================================================ */

/* --- Header user menu (right side of the sticky header) --- */
.user-menu {
    display: flex;
    align-items: center;
    gap: 14px;
}
.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    font-size: 0.85rem;
    max-width: 220px;
}
.user-chip .user-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}
.user-chip .user-role {
    background: var(--sl-silver);
    color: var(--sl-navy);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 2px 6px;
    border-radius: 4px;
}
.user-admin-link {
    color: #fff;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0.9;
}
.user-admin-link:hover { opacity: 1; text-decoration: underline; }
.btn-signout {
    padding: 6px 14px;
    font-size: 0.8rem;
    color: #fff;
    border-color: rgba(255, 255, 255, 0.55);
    background: transparent;
}
.btn-signout:hover { background: rgba(255, 255, 255, 0.12); }

@media (max-width: 768px) {
    .user-chip .user-name { max-width: 90px; }
    .user-admin-link { display: none; }
}

/* --- Login view --- */
.login-view {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background:
        radial-gradient(1200px 600px at 50% -10%, rgba(10, 61, 115, 0.25), transparent),
        var(--sl-navy);
}
.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: 16px;
    padding: 36px 32px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
}
.login-logo { width: 52px; height: 52px; object-fit: contain; }
.login-brand-text { display: flex; flex-direction: column; }
.login-title { font-size: 1.15rem; font-weight: 700; color: var(--sl-navy); }
.login-subtitle { font-size: 0.85rem; color: var(--sl-slate); }

.login-form { display: flex; flex-direction: column; }
.login-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--sl-slate);
    margin: 12px 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.login-input {
    font-family: inherit;
    font-size: 0.95rem;
    padding: 11px 13px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--bg-light);
    color: var(--text-dark);
}
.login-input:focus {
    outline: none;
    border-color: var(--sl-navy-accent);
    box-shadow: 0 0 0 3px rgba(10, 61, 115, 0.15);
    background: #fff;
}
.login-submit { margin-top: 22px; width: 100%; justify-content: center; }
.login-submit:disabled { opacity: 0.6; cursor: default; }
.login-forgot {
    margin-top: 14px;
    background: none;
    border: none;
    color: var(--sl-navy-accent);
    font-size: 0.83rem;
    cursor: pointer;
    align-self: center;
    text-decoration: underline;
}
.login-error {
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #FEF2F2;
    color: #991B1B;
    font-size: 0.85rem;
    border: 1px solid #FECACA;
}
.login-notice {
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--ok-bg);
    color: var(--ok-fg);
    font-size: 0.85rem;
    border: 1px solid #A7F3D0;
}

/* --- Content blocks (rich_text / callout / image_pair) --- */
.rich-text p { margin-bottom: 10px; }
.rich-text p:last-child { margin-bottom: 0; }
.doc-blocks { margin-top: 14px; display: flex; flex-direction: column; gap: 14px; }
.option-prose { margin: 20px 0; display: flex; flex-direction: column; gap: 12px; }
.callout {
    padding: 12px 16px;
    border-radius: 8px;
    border-left: 4px solid var(--sl-silver);
    background: var(--bg-light);
    font-size: 0.9rem;
}
.callout-warn { border-left-color: var(--fire); background: #FEF2F2; }
.callout-info { border-left-color: var(--sl-navy-accent); }
.image-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
@media (max-width: 640px) {
    .image-pair { grid-template-columns: 1fr; }
}

/* Admin-only visibility hint for hidden spec rows (viewers never see these). */
.metric-row-hidden { opacity: 0.55; }
