/* ═══════════════════════════════════════════════════════════════════
   APEX PORTAL CSS - GCP DENSE THEME
   ═══════════════════════════════════════════════════════════════════ */

:root {
    --a11y-scale: 1;

    --font-sans: 'Google Sans', 'Roboto', -apple-system, 'Helvetica Neue', sans-serif;
    --font-mono: 'Roboto Mono', 'JetBrains Mono', 'Consolas', monospace;

    /* Scaled sizes */
    --fs-xs:   calc(11px * var(--a11y-scale));
    --fs-sm:   calc(12px * var(--a11y-scale));
    --fs-base: calc(13px * var(--a11y-scale));
    --fs-lg:   calc(15px * var(--a11y-scale));
    --fs-xl:   calc(18px * var(--a11y-scale));
    --fs-2xl:  calc(24px * var(--a11y-scale));

    --space-1: calc(4px * var(--a11y-scale));
    --space-2: calc(8px * var(--a11y-scale));
    --space-3: calc(12px * var(--a11y-scale));
    --space-4: calc(16px * var(--a11y-scale));
    --space-6: calc(24px * var(--a11y-scale));
    --space-8: calc(32px * var(--a11y-scale));

    --header-h: calc(48px * var(--a11y-scale));
    --sidebar-w: calc(240px * var(--a11y-scale));

    --radius-sm: 0px;
    --radius-md: 0px;
    --transition: 0.15s ease;
}

/* Light Theme — GCP Console exact */
:root, [data-theme="light"] {
    --bg-app:          #f8f9fa;
    --bg-main:         #f8f9fa;
    --bg-surface:      #ffffff;
    --bg-card:         #ffffff;
    --bg-card-hover:   #f1f3f4;
    --bg-header:       #ffffff;
    --bg-sidebar:      #ffffff;
    --bg-input:        #ffffff;

    --border:          #dadce0;
    --border-subtle:   #e8eaed;
    --border-strong:   #bdc1c6;

    --text-primary:    #202124;
    --text-secondary:  #5f6368;
    --text-dim:        #80868b;
    --text-on-accent:  #ffffff;

    /* GCP blue — used for text links, indicators, active underlines */
    --accent:          #1a73e8;
    --accent-hover:    #1557b0;
    --accent-subtle:   #e8f0fe;

    /* Separate filled-button bg (darker, always legible with white text) */
    --btn-primary:     #1a73e8;
    --btn-primary-hover: #1557b0;

    --green:           #137333;
    --red:             #d93025;
    --yellow:          #f9ab00;
    --green-soft:      rgba(19, 115, 51, 0.1);
    --green-border:    rgba(19, 115, 51, 0.3);
    --red-soft:        rgba(217, 48, 37, 0.1);
    --shadow-sm:       0 1px 2px rgba(60,64,67,0.3), 0 1px 3px rgba(60,64,67,0.15);
}

/* Dark Theme — GCP Cloud Console exact */
[data-theme="dark"] {
    --bg-app:          #121212;
    --bg-main:         #121212;
    --bg-surface:      #202124;
    --bg-card:         #292b2f;
    --bg-card-hover:   #303134;
    --bg-header:       #202124;
    --bg-sidebar:      #202124;
    --bg-input:        #303134;

    --border:          #3c4043;
    --border-subtle:   #2d2f33;
    --border-strong:   #5f6368;

    --text-primary:    #e8eaed;
    --text-secondary:  #9aa0a6;
    --text-dim:        #80868b;
    --text-on-accent:  #202124;

    /* GCP blue-200 — used for nav highlights, links, tab underlines, icon tints */
    --accent:          #8ab4f8;
    --accent-hover:    #aecbfa;
    --accent-subtle:   rgba(138, 180, 248, 0.12);

    /* Filled buttons stay Google-blue with white text regardless of dark mode */
    --btn-primary:     #1a73e8;
    --btn-primary-hover: #1967d2;
    --text-on-btn:     #ffffff;

    --green:           #81c995;
    --red:             #f28b82;
    --yellow:          #fdd663;
    --green-soft:      rgba(129, 201, 149, 0.12);
    --green-border:    rgba(129, 201, 149, 0.3);
    --red-soft:        rgba(242, 139, 130, 0.12);
    --shadow-sm:       none;
}


/* High Contrast Overrides */
html[data-theme="light"] body.high-contrast {
    --text-primary: #000;
    --text-secondary: #000;
    --text-dim: #000;
    --border: #000;
    --border-strong: #000;
    --accent: #0000ee;
}
html[data-theme="dark"] body.high-contrast {
    --text-primary: #fff;
    --text-secondary: #fff;
    --text-dim: #fff;
    --border: #fff;
    --border-strong: #fff;
    --accent: #ffff00;
    --bg-card-hover: #333;
}

/* Base */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    color: var(--text-primary);
    background: var(--bg-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* Focus ring for screen readers / keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
}
.app-header {
    height: var(--header-h);
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 var(--space-4);
    position: sticky;
    top: 0;
    z-index: 100;
}
.app-header-logo {
    font-size: var(--fs-lg);
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.app-header-logo:hover { text-decoration: none; }
.app-body {
    display: flex;
    flex: 1;
}
.app-sidebar {
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    overflow-y: auto;
}
.app-main {
    flex: 1;
    padding: var(--space-4) var(--space-6);
    max-width: calc(100vw - var(--sidebar-w));
}
/* Pages without a sidebar (login, public/auth flows) use the full width so cards centre */
.app-body:not(:has(.app-sidebar)) > .app-main { max-width: 100vw; }

/* A11y Settings Panel (Top Right) */
.a11y-controls {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--space-4);
}
.a11y-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--fs-sm);
}
.a11y-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.a11y-btn.active { background: var(--accent-subtle); color: var(--accent); border-color: var(--accent); }

.a11y-slider-wrap {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--fs-xs);
    color: var(--text-secondary);
}
.a11y-slider {
    width: 80px;
    cursor: pointer;
}

/* Sidebar Nav */
.sidebar-nav {
    padding: var(--space-2) 0;
    display: flex;
    flex-direction: column;
}
.nav-group {
    margin-bottom: var(--space-4);
}
.nav-title {
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-dim);
    padding: 0 var(--space-4);
    margin-bottom: var(--space-2);
    font-weight: 500;
}
.nav-item {
    display: flex;
    align-items: center;
    padding: var(--space-2) var(--space-4);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--fs-base);
    border-radius: 0;
}
.nav-item:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    text-decoration: none;
}
.nav-item.active {
    background: var(--accent-subtle);
    color: var(--accent);
    font-weight: 500;
    border-left: 3px solid var(--accent);
}

/* Cards (GCP dense style) */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-3);
}
.card-title {
    font-size: var(--fs-base);
    font-weight: 500;
    color: var(--text-primary);
}
.card-value {
    font-size: var(--fs-xl);
    font-family: var(--font-mono);
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}
.card-label {
    font-size: var(--fs-xs);
    color: var(--text-secondary);
}

/* Forms & Inputs */
.form-group {
    margin-bottom: var(--space-4);
}
.form-label {
    display: block;
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
    font-weight: 500;
}
.form-control {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: var(--fs-base);
    font-family: var(--font-mono);
}
.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-2) var(--space-4);
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: var(--fs-base);
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: var(--bg-card-hover); text-decoration: none; }
.btn-primary {
    background: var(--btn-primary);
    color: #ffffff;
    border: none;
    border-radius: 0;
}
.btn-primary:hover { opacity: 0.9; }

/* Tables */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
}
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
}
.table th, .table td {
    padding: var(--space-2) var(--space-4);
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.table th {
    background: var(--bg-card-hover);
    color: var(--text-secondary);
    font-weight: 500;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg-card-hover); }

/* Utilities */
.text-mono { font-family: var(--font-mono); }
.text-xs { font-size: var(--fs-xs); }
.text-sm { font-size: var(--fs-sm); }
.text-dim { color: var(--text-dim); }
.text-accent { color: var(--accent); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

/* Mobile nav */
.mobile-menu-btn { display: none; }
@media (max-width: 900px) {
    .app-sidebar {
        position: fixed;
        left: 0;
        top: var(--header-h);
        z-index: 200;
        transform: translateX(-100%);
        transition: transform var(--transition);
    }
    .app-sidebar.open { transform: translateX(0); }
    .app-main { max-width: 100vw; padding: var(--space-4); }
    .mobile-menu-btn { display: inline-flex; margin-right: var(--space-4); background:none; border:none; color:var(--text-primary); cursor:pointer; font-size:18px;}
    .a11y-controls { display: none; /* Hide on small screens to save space */ }
}

/* ── Admin Dashboard Grid ── */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: minmax(140px, auto);
    gap: var(--space-4);
    margin-top: var(--space-4);
}
.grid-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0;
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
}
.grid-box1 {
    grid-column: span 1;
    grid-row: span 2;
}
.grid-box4 {
    grid-column: span 1;
    grid-row: span 2;
}
.grid-box7 {
    grid-column: span 2;
    grid-row: span 1;
}

.stat-card-flex {
    display: flex;
    flex-direction: column;
    height: 100%;
    justify-content: space-between;
}
.stat-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 500;
}
.stat-card-title {
    font-weight: 600;
    color: var(--text-primary);
}
.stat-card-trend.pos {
    color: var(--green);
}
.stat-card-num {
    font-size: var(--fs-2xl);
    font-weight: 500;
    color: var(--text-primary);
    margin: var(--space-2) 0;
    font-family: var(--font-sans);
}
.stat-card-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}
.stat-card-link {
    font-size: var(--fs-xs);
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}
.stat-card-link:hover {
    text-decoration: underline;
}

.feed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-3);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    padding-bottom: var(--space-2);
}
.feed-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    overflow-y: auto;
    flex: 1;
}
.feed-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--bg-card-hover);
}
.feed-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.feed-org {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-primary);
}
.feed-meta {
    font-size: var(--fs-xs);
    color: var(--text-secondary);
    font-family: var(--font-mono);
}
.status-pill {
    font-size: 10px;
    padding: 2px 6px;
    background: var(--bg-card-hover);
    border: 1px solid var(--border-strong);
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase;
}
.status-pill.executed, .status-pill.registered, .status-pill.active {
    color: var(--green);
    border-color: var(--green);
    background: rgba(129, 201, 149, 0.1);
}
.status-pill.pending, .status-pill.draft {
    color: var(--yellow);
    border-color: var(--yellow);
    background: rgba(253, 214, 99, 0.1);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: var(--space-6);
    border-bottom: 1px solid var(--border);
    padding-bottom: var(--space-4);
}
.page-title h1 {
    font-size: var(--fs-2xl);
    font-weight: 500;
    margin: 0 0 var(--space-1) 0;
    color: var(--text-primary);
}
.page-title p {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    margin: 0;
}
.page-actions {
    display: flex;
    gap: var(--space-2);
}
.quick-action-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: var(--space-2) var(--space-4);
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
}
.quick-action-btn.primary {
    background: var(--btn-primary);
    color: #ffffff;
    border-color: var(--btn-primary);
    border-radius: 0;
}
.quick-action-btn:hover {
    background: var(--bg-card-hover);
}
.quick-action-btn.primary:hover {
    background: var(--accent-hover);
}

/* ── Table Cards for Users and Agreements ── */
.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    margin-bottom: var(--space-6);
}
.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
}
.table-search input {
    background: var(--bg-main);
    border: 1px solid var(--border);
    padding: 4px 8px;
    font-size: var(--fs-sm);
    color: var(--text-primary);
    width: 200px;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th, .data-table td {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: var(--fs-sm);
}
.data-table th {
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: var(--fs-xs);
    background: var(--bg-card-hover);
}
.data-table td {
    color: var(--text-primary);
}
.data-table tr:hover td {
    background: var(--bg-surface);
}

/* Search Widget */
#search-dropdown a:hover {
    background-color: var(--bg-card-hover);
}

/* Messages */
.messages-container { display:flex; flex-direction:column; height: 100%; }
.messages-header { display:flex; justify-content:space-between; align-items:center; border-bottom:1px solid var(--border); padding-bottom:12px; margin-bottom:12px; }
.messages-content { display:flex; gap:16px; flex:1; }
.messages-sidebar { width:200px; display:flex; flex-direction:column; gap:8px; border-right:1px solid var(--border); padding-right:16px; }
.messages-list { flex:1; overflow-y:auto; }
.message-item { padding:12px; border-bottom:1px solid var(--border-subtle); cursor:pointer; }
.message-item:hover { background:var(--bg-card-hover); }
.message-item.unread { font-weight:bold; background:var(--bg-card); }
.message-item.unread::before { content:'●'; color:var(--accent); margin-right:8px; }
.msg-item-header { display:flex; justify-content:space-between; font-size:12px; color:var(--text-secondary); margin-bottom:4px; }
.msg-item-subject { font-size:14px; color:var(--text-primary); }
.message-view { flex:1; background:var(--bg-card); padding:16px; border:1px solid var(--border); }
.msg-meta { font-size:12px; color:var(--text-secondary); margin-bottom:16px; padding-bottom:12px; border-bottom:1px solid var(--border-subtle); }
.msg-body { font-size:14px; line-height:1.6; white-space:pre-wrap; }


/* ═══════════════════════════════════════════════════════════════════════
   UI CUSTOMIZATIONS — BETA (disabled, re-enable when ready)
   To activate: remove the opening slash-asterisk above and closing
   asterisk-slash below, then un-prefix the section headers (remove the
   leading dashes) to restore valid CSS selectors.
   ═══════════════════════════════════════════════════════════════════════

   ── Nav text variable support ──────────────────────────────────────────
   .nav-item { color: var(--nav-text, var(--text-secondary)); }

   ── Theme transition smoothing ─────────────────────────────────────────
   :root {
     --_theme-transition: background-color 0.18s ease, color 0.18s ease,
                          border-color 0.18s ease;
   }
   .app-header, .app-sidebar, .app-main, .card, .nav-item, .nav-title,
   .btn, button, .table-container, .panel, .forge-section {
     transition: var(--_theme-transition);
   }

   ── Glassmorphic sticky header ─────────────────────────────────────────
   .app-header.glass-header {
     background: rgba(10, 12, 18, 0.68);
     border-bottom: 1px solid color-mix(in oklab, var(--accent) 22%, transparent);
     -webkit-backdrop-filter: blur(14px) saturate(150%) brightness(1.06);
     backdrop-filter: blur(14px) saturate(150%) brightness(1.06);
     contain: layout paint;
   }
   @supports not (backdrop-filter: blur(1px)) {
     .app-header.glass-header { background: var(--bg-surface); }
   }
   @media (prefers-reduced-transparency: reduce) {
     .app-header.glass-header {
       background: var(--bg-surface);
       backdrop-filter: none; -webkit-backdrop-filter: none;
     }
   }

   ── Card hover elevation ────────────────────────────────────────────────
   .card-elevation .card, .card-elevation .panel, .card-elevation .forge-section {
     transition: translate 0.15s ease, box-shadow 0.15s ease;
   }
   .card-elevation .card:hover, .card-elevation .panel:hover,
   .card-elevation .forge-section:hover {
     translate: 0 -2px;
     box-shadow: 0 6px 28px rgba(0, 0, 0, 0.38);
   }
   @media (prefers-reduced-motion: reduce) {
     .card-elevation .card, .card-elevation .panel,
     .card-elevation .forge-section { transition: none; }
     .card-elevation .card:hover, .card-elevation .panel:hover,
     .card-elevation .forge-section:hover {
       translate: none; transform: none; box-shadow: none;
     }
   }

═══════════════════════════════════════════════════════════════════════ */
