/* ══════════════════════════════════════════════════════════════════════
 * Platform Shell — Shared CSS
 *
 * Provides the unified platform shell used by all surfaces (Console,
 * Dashboard, Core). Surface-specific styles live in their own files
 * (e.g. console-shell.css).
 *
 * Environment color tokens are system-owned constants defined here,
 * selected by CSS class — never injected by PHP or Twig.
 *
 * All non-env colors use CSS variables from /css/color-system.css.
 *
 * Date: 2026-05-26
 * Policy: docs/console/PLATFORM-SHELL-FOUNDATION.md
 * ══════════════════════════════════════════════════════════════════════ */

/* ── Environment Color Tokens (system-owned, CSS-only) ────────────── */

.platform-shell--env-local {
    --env-accent: #8b5cf6;
    --env-bg-soft: rgba(139, 92, 246, 0.08);
    --env-text: #7c3aed;
    --env-border: rgba(139, 92, 246, 0.3);
}

.platform-shell--env-dev {
    --env-accent: #f59e0b;
    --env-bg-soft: rgba(245, 158, 11, 0.08);
    --env-text: #d97706;
    --env-border: rgba(245, 158, 11, 0.3);
}

.platform-shell--env-staging {
    --env-accent: #3b82f6;
    --env-bg-soft: rgba(59, 130, 246, 0.08);
    --env-text: #2563eb;
    --env-border: rgba(59, 130, 246, 0.3);
}

.platform-shell--env-production {
    --env-accent: #ef4444;
    --env-bg-soft: rgba(239, 68, 68, 0.06);
    --env-text: #dc2626;
    --env-border: rgba(239, 68, 68, 0.3);
}

/* ── Surface Identity Tokens (consumes color tokens from color-system.css) ── */

.platform-shell--console {
    --surface-accent: var(--surface-console-accent);
    --surface-accent-soft: var(--surface-console-accent-soft);
    --surface-card-hover-border: var(--surface-console-card-hover-border);
    --surface-topbar-bg: var(--surface-console-topbar-bg);
    --surface-card-radius: 8px;
    --surface-search-max-width: 480px;
}

.platform-shell--dashboard {
    --surface-accent: var(--surface-dashboard-accent);
    --surface-accent-soft: var(--surface-dashboard-accent-soft);
    --surface-card-hover-border: var(--surface-dashboard-card-hover-border);
    --surface-topbar-bg: var(--surface-dashboard-topbar-bg);
    --surface-card-radius: 12px;
    --surface-search-max-width: 480px;
}

.platform-shell--core {
    --surface-accent: var(--surface-core-accent);
    --surface-accent-soft: var(--surface-core-accent-soft);
    --surface-card-hover-border: var(--surface-core-card-hover-border);
    --surface-topbar-bg: var(--surface-core-topbar-bg);
    --surface-card-radius: 10px;
    --surface-search-max-width: 560px;
}

.platform-shell--aao {
    --surface-accent: var(--surface-aao-accent);
    --surface-accent-soft: var(--surface-aao-accent-soft);
    --surface-card-hover-border: var(--surface-aao-card-hover-border);
    --surface-topbar-bg: var(--surface-aao-topbar-bg);
    --surface-card-radius: 8px;
    --surface-search-max-width: 480px;
}

.platform-shell--admin {
    --surface-accent: var(--surface-admin-accent);
    --surface-accent-soft: var(--surface-admin-accent-soft);
    --surface-card-hover-border: var(--surface-admin-card-hover-border);
    --surface-topbar-bg: var(--surface-admin-topbar-bg);
    --surface-card-radius: 8px;
    --surface-search-max-width: 480px;
}

.platform-shell--fepc {
    --surface-accent: var(--surface-fepc-accent);
    --surface-accent-soft: var(--surface-fepc-accent-soft);
    --surface-card-hover-border: var(--surface-fepc-card-hover-border);
    --surface-topbar-bg: var(--surface-fepc-topbar-bg);
    --surface-card-radius: 10px;
    --surface-search-max-width: 480px;
}

/* Production strictness: mute surface accent toward neutral */
.platform-shell--env-production {
    --surface-accent-soft: var(--surface-production-accent-soft);
}

/* ── Shell Layout (full-width) ───────────────────────────────────── */

.platform-shell {
    min-height: 100vh;
    background: var(--bg-primary, #ffffff);
    position: relative;
    width: 100%;
}

.platform-shell-body {
    display: flex;
    min-height: calc(100vh - 55px);
    width: 100%;
}

.platform-shell-main {
    flex: 1;
    min-width: 0;
    width: 100%;
}

.platform-main {
    width: 100%;
    max-width: none;
    padding: 0 2.5rem;
}

@media (max-width: 1024px) {
    .platform-main {
        padding: 0 1.5rem;
    }
}

@media (max-width: 768px) {
    .platform-main {
        padding: 0 1rem;
    }
}

/* ── Environment Accent Strip ─────────────────────────────────────── */

.platform-env-strip {
    display: none;
}

/* ── Top Navigation Bar ───────────────────────────────────────────── */

.platform-topbar {
    background: var(--surface-topbar-bg, var(--brand-navy, #283A90));
    color: #f1f5f9;
    padding: 0 1.5rem;
    height: 52px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
}

/* ── Brand Identity ──────────────────────────────────────────────── */

.platform-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
}

.platform-brand-logo {
    height: 28px;
    width: auto;
    filter: brightness(0) invert(1);
    transition: opacity 0.2s ease;
}

.platform-brand:hover .platform-brand-logo {
    opacity: 0.85;
}

.platform-brand-fallback {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 1rem;
    font-weight: 700;
    color: #f1f5f9;
}

.platform-topbar-divider {
    width: 1px;
    height: 1.25rem;
    background: rgba(241, 245, 249, 0.3);
    flex-shrink: 0;
}

.platform-topbar-surface-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: rgba(241, 245, 249, 0.85);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.platform-topbar-spacer {
    flex: 1;
    min-width: 0;
}

/* ── Environment Badge ────────────────────────────────────────────── */

.platform-env-badge {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    flex-shrink: 0;
    background: var(--env-bg-soft);
    color: var(--env-text);
    border: 1px solid var(--env-border);
}

/* ── Global Search ────────────────────────────────────────────────── */

.platform-search-wrap {
    flex: 1;
    max-width: var(--surface-search-max-width, 480px);
    position: relative;
}

.platform-search-input {
    width: 100%;
    padding: 0.4375rem 0.75rem 0.4375rem 2.25rem;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: #f1f5f9;
    font-size: 0.8125rem;
    outline: none;
    transition: all 0.2s ease;
}

.platform-search-input::placeholder {
    color: rgba(241, 245, 249, 0.6);
}

.platform-search-input:focus {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.platform-search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(241, 245, 249, 0.6);
    font-size: 0.8125rem;
    pointer-events: none;
}

/* ── Search Results Dropdown (Typeahead) ──────────────────────────── */

.platform-search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    max-height: 400px;
    overflow-y: auto;
    z-index: 200;
}

.platform-search-results.active {
    display: block;
}

.platform-search-result-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    text-decoration: none;
    color: var(--text-primary, #1e293b);
    transition: background 0.15s ease;
    border-bottom: 1px solid var(--border, #e2e8f0);
}

.platform-search-result-item:last-child {
    border-bottom: none;
}

.platform-search-result-item:hover,
.platform-search-result-item.highlighted {
    background: var(--bg-secondary, #f8fafc);
}

.platform-search-result-item--locked {
    opacity: 0.5;
}

.platform-search-result-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 0.875rem;
    flex-shrink: 0;
    background: var(--surface-accent-soft, rgba(31, 111, 214, 0.1));
    color: var(--surface-accent, var(--primary-blue, #1F6FD6));
}

.platform-search-result-body {
    flex: 1;
    min-width: 0;
}

.platform-search-result-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    margin: 0;
}

.platform-search-result-desc {
    font-size: 0.75rem;
    color: var(--text-muted, #64748b);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.platform-search-result-lock {
    font-size: 0.75rem;
    color: var(--text-muted, #64748b);
    flex-shrink: 0;
}

.platform-search-empty {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-muted, #64748b);
    font-size: 0.8125rem;
}

/* ── Service Indicator ────────────────────────────────────────────── */

.platform-service-indicator {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    color: rgba(241, 245, 249, 0.8);
    padding: 0.25rem 0.625rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    flex-shrink: 0;
}

/* ── Right Navigation Controls ───────────────────────────────────── */

.platform-right-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.platform-right-nav-btn {
    background: none;
    border: none;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(241, 245, 249, 0.8);
    font-size: 1.0625rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
    position: relative;
}

.platform-right-nav-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.platform-avatar-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-blue, #1F6FD6);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    font-weight: 600;
}

.platform-avatar-circle--lg {
    width: 40px;
    height: 40px;
    font-size: 1rem;
}

/* ── Dropdown Panels (right-nav buttons) ─────────────────────────── */

.platform-dropdown {
    position: relative;
}

.platform-dropdown-panel {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 240px;
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 200;
    overflow: hidden;
}

.platform-dropdown.open .platform-dropdown-panel {
    display: block;
}

.platform-dropdown-header {
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted, #64748b);
    border-bottom: 1px solid var(--border, #e2e8f0);
}

.platform-dropdown-placeholder {
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--text-muted, #64748b);
}

.platform-dropdown-placeholder i {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.platform-dropdown-placeholder span {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    margin-bottom: 0.25rem;
}

.platform-dropdown-placeholder small {
    display: block;
    font-size: 0.75rem;
}

.platform-dropdown-divider {
    height: 1px;
    background: var(--border, #e2e8f0);
}

.platform-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    text-decoration: none;
    color: var(--text-primary, #1e293b);
    font-size: 0.8125rem;
    transition: background 0.15s ease;
}

.platform-dropdown-item:hover {
    background: var(--bg-secondary, #f8fafc);
}

.platform-dropdown-item i {
    font-size: 0.875rem;
    color: var(--text-muted, #64748b);
    width: 1.25rem;
    text-align: center;
}

/* ── User dropdown specifics ── */

.platform-dropdown-panel--user {
    min-width: 260px;
}

.platform-dropdown-user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
}

.platform-dropdown-user-details {
    min-width: 0;
}

.platform-dropdown-user-details strong {
    display: block;
    font-size: 0.875rem;
    color: var(--text-primary, #1e293b);
}

.platform-dropdown-user-details small {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted, #64748b);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .platform-right-nav {
        gap: 0.125rem;
    }

    /* Hide messages and account on mobile */
    .platform-dropdown[data-dropdown="messages"],
    .platform-dropdown[data-dropdown="account"] {
        display: none;
    }
}

/* ── Left Navigation Rail ────────────────────────────────────────── */

.platform-left-rail {
    width: 96px;
    flex-shrink: 0;
    background: var(--bg-primary, #ffffff);
    border-right: 1px solid var(--border, #e2e8f0);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 0;
    gap: 0.25rem;
    overflow-y: auto;
}

.platform-rail-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1875rem;
    padding: 0.5rem 0.25rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-muted, #64748b);
    font-size: 1.125rem;
    width: 88px;
    transition: all 0.15s ease;
    text-align: center;
}

.platform-rail-item:hover {
    background: var(--bg-secondary, #f8fafc);
    color: var(--surface-accent, var(--primary-blue, #1F6FD6));
}

.platform-rail-item--active {
    background: var(--surface-accent-soft, rgba(31, 111, 214, 0.12));
    color: var(--surface-accent, var(--primary-blue, #1F6FD6));
}

.platform-rail-item--active:hover {
    background: var(--surface-accent-soft, rgba(31, 111, 214, 0.16));
    filter: brightness(0.97);
}

.platform-rail-label {
    font-size: 0.625rem;
    font-weight: 500;
    line-height: 1.3;
}

@media (max-width: 1024px) {
    .platform-left-rail {
        display: none;
    }
}

/* ── Navigation Drawer ────────────────────────────────────────────── */

.platform-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 299;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.platform-drawer-overlay.active {
    opacity: 1;
    visibility: visible;
}

.platform-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 320px;
    max-width: 85vw;
    height: 100vh;
    background: var(--bg-primary, #ffffff);
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
    overflow: hidden;
}

.platform-drawer.open {
    transform: translateX(0);
}

/* ── Drawer Header ── */

.platform-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border, #e2e8f0);
    flex-shrink: 0;
}

.platform-drawer-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--brand-navy, #283A90);
}

.platform-drawer-brand-name {
    white-space: nowrap;
}

.platform-drawer-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.375rem;
    border-radius: 6px;
    color: var(--text-muted, #64748b);
    font-size: 1.125rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.platform-drawer-close:hover {
    background: var(--bg-secondary, #f8fafc);
    color: var(--text-primary, #1e293b);
}

/* ── Drawer Search ── */

.platform-drawer-search {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border, #e2e8f0);
    position: relative;
    flex-shrink: 0;
}

.platform-drawer-search-input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.25rem;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 6px;
    background: var(--bg-secondary, #f8fafc);
    color: var(--text-primary, #1e293b);
    font-size: 0.8125rem;
    outline: none;
    transition: all 0.2s ease;
}

.platform-drawer-search-input::placeholder {
    color: var(--text-muted, #64748b);
}

.platform-drawer-search-input:focus {
    border-color: var(--primary-blue, #1F6FD6);
    background: var(--bg-primary, #ffffff);
    box-shadow: 0 0 0 3px rgba(31, 111, 214, 0.1);
}

.platform-drawer-search-icon {
    position: absolute;
    left: 2rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted, #64748b);
    font-size: 0.8125rem;
    pointer-events: none;
}

/* ── Drawer Navigation ── */

.platform-drawer-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.platform-drawer-section {
    padding: 0.25rem 0;
}

.platform-drawer-section + .platform-drawer-section {
    border-top: 1px solid var(--border, #e2e8f0);
}

.platform-drawer-section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #64748b);
}

.platform-drawer-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 1.25rem 0.5rem 2.5rem;
    text-decoration: none;
    color: var(--text-primary, #1e293b);
    font-size: 0.8125rem;
    transition: background 0.15s ease;
    border-radius: 0;
}

.platform-drawer-item:hover {
    background: var(--bg-secondary, #f8fafc);
}

.platform-drawer-item-icon {
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
    color: var(--surface-accent, var(--primary-blue, #1F6FD6));
    font-size: 0.875rem;
}

.platform-drawer-item-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.platform-drawer-item-lock {
    font-size: 0.6875rem;
    color: var(--text-muted, #64748b);
    flex-shrink: 0;
}

.platform-drawer-item--locked {
    opacity: 0.5;
}

.platform-drawer-item--locked:hover {
    opacity: 0.7;
}

.platform-drawer-empty {
    padding: 2rem 1.25rem;
    text-align: center;
    color: var(--text-muted, #64748b);
    font-size: 0.8125rem;
}

/* ── Hamburger Button ────────────────────────────────────────────── */

.platform-topbar-hamburger {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.375rem;
    border-radius: 6px;
    color: rgba(241, 245, 249, 0.9);
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.platform-topbar-hamburger:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

/* ── Dashboard surface: GC grid adjustment ────────────────────────── */
/* GC sidebar is a template-level no-op inside the platform shell.
   Collapse the grid from 2-column (sidebar+content) to 1-column. */

.platform-shell--dashboard .gc-layout,
.platform-shell--dashboard .gc-home-layout {
    grid-template-columns: 1fr;
}

/* ── Environment Watermark (non-production only) ──────────────────── */

.platform-env-watermark {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 6rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--env-accent);
    opacity: 0.04;
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
    z-index: 0;
}
