/**
 * Fleet CRM Apex v3 — Core Obsidian Glass Design System
 * High-performance, GPU-accelerated styling with ultra-low memory footprint.
 */

:root {
    --bg-deep: #070a12;
    --bg-surface: #0b1120;
    --bg-surface-trans: rgba(11, 17, 32, 0.85);
    --bg-card: rgba(15, 23, 42, 0.72);
    --bg-card-hover: rgba(30, 41, 59, 0.8);
    --bg-card-active: rgba(56, 189, 248, 0.08);

    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.16);
    --border-highlight: rgba(56, 189, 248, 0.4);

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-sub: #64748b;

    /* Accent & Brand Colors */
    --primary: #38bdf8;
    --primary-glow: rgba(56, 189, 248, 0.25);
    --accent-purple: #a855f7;
    --accent-purple-glow: rgba(168, 85, 247, 0.25);
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;

    /* Shadows & Transitions */
    --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --shadow-drawer: -10px 0 40px rgba(0, 0, 0, 0.7);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 22px;
    --transition-fast: 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-smooth: 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Base resets & typography */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-deep);
    color: var(--text-main);
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    min-height: 100vh;
}

.mono {
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: -0.3px;
}

/* Glassmorphism Card Utility */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.glass-card:hover {
    border-color: var(--border-hover);
}

/* ----------------------------------------------------
   APEX SHELL LAYOUT
---------------------------------------------------- */
.apex-shell {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    position: relative;
}

/* Sidebar */
aside.apex-sidebar {
    width: 250px;
    background: rgba(9, 14, 26, 0.95);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 50;
    transition: width var(--transition-smooth);
}

.apex-sidebar.collapsed {
    width: 76px;
}

.apex-brand {
    padding: 18px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.apex-brand-left {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}

.apex-brand-logo {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #0284c7, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 17px;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4);
    flex-shrink: 0;
}

.apex-brand-text {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.apex-brand-badge {
    font-size: 9.5px;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(168, 85, 247, 0.2);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.35);
}

.apex-sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    padding: 6px;
    border-radius: 6px;
    transition: color var(--transition-fast);
}
.apex-sidebar-toggle:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

/* Navigation List */
.apex-nav-list {
    padding: 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.apex-nav-group-title {
    font-size: 10.5px;
    font-weight: 800;
    color: var(--text-sub);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 10px 10px 4px;
}

.apex-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    user-select: none;
}

.apex-nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-main);
}

.apex-nav-item.active {
    background: linear-gradient(90deg, rgba(56, 189, 248, 0.15), rgba(56, 189, 248, 0.03));
    color: #38bdf8;
    font-weight: 700;
    border-left: 3px solid #38bdf8;
}

.apex-nav-item i {
    font-size: 15px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.apex-nav-badge {
    margin-left: auto;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 20px;
}

/* Sidebar User Profile */
.apex-sidebar-user {
    padding: 14px 14px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.apex-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #10b981, #0284c7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
}

.apex-user-details {
    flex: 1;
    overflow: hidden;
}

.apex-user-name {
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.apex-user-role {
    font-size: 11px;
    color: var(--text-muted);
}

/* Main Workspace */
main.apex-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background: radial-gradient(circle at 50% 0%, rgba(56, 189, 248, 0.03) 0%, transparent 60%);
}

/* Header */
header.apex-header {
    height: 64px;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(11, 17, 32, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 40;
}

.apex-header-search {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    width: 320px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.apex-header-search:hover {
    border-color: var(--border-highlight);
    background: rgba(255, 255, 255, 0.06);
}

.apex-header-search input {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 13px;
    outline: none;
    width: 100%;
}

.apex-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.apex-header-btn {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.apex-header-btn:hover {
    background: rgba(255, 255, 255, 0.09);
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Dynamic Content Container */
#apex-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ----------------------------------------------------
   BUTTONS & BADGES
---------------------------------------------------- */
.btn-apex {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition-fast);
    text-decoration: none;
    line-height: 1;
}

.btn-apex-primary {
    background: linear-gradient(135deg, #0284c7, #2563eb);
    color: #fff;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
}
.btn-apex-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(2, 132, 199, 0.45);
}

.btn-apex-secondary {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border);
    color: var(--text-main);
}
.btn-apex-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-apex-sip {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-apex-danger {
    background: rgba(244, 63, 94, 0.15);
    border-color: rgba(244, 63, 94, 0.35);
    color: #f43f5e;
}
.btn-apex-danger:hover {
    background: rgba(244, 63, 94, 0.25);
}

/* Badges */
.apex-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1.2;
}

.badge-live {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-amber {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-rose {
    background: rgba(244, 63, 94, 0.15);
    color: #f43f5e;
    border: 1px solid rgba(244, 63, 94, 0.3);
}

.badge-cyan {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-purple {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

/* ----------------------------------------------------
   SLIDE-OVER DRAWER (480px)
---------------------------------------------------- */
.apex-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-smooth);
}
.apex-drawer-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.apex-drawer {
    position: fixed;
    top: 0;
    right: -520px;
    width: 480px;
    height: 100vh;
    background: #090e1a;
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-drawer);
    z-index: 101;
    display: flex;
    flex-direction: column;
    transition: right var(--transition-smooth);
}
.apex-drawer.active {
    right: 0;
}

.apex-drawer-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.apex-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.apex-drawer-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.3);
}

/* ----------------------------------------------------
   COMMAND PALETTE (CTRL+K)
---------------------------------------------------- */
.apex-palette-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 200;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}
.apex-palette-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.apex-palette-modal {
    width: 580px;
    max-width: 90vw;
    background: #0f172a;
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 40px rgba(56, 189, 248, 0.2);
    overflow: hidden;
    transform: scale(0.96);
    transition: transform var(--transition-fast);
}
.apex-palette-backdrop.active .apex-palette-modal {
    transform: scale(1);
}

.apex-palette-input-wrap {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.apex-palette-input {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 16px;
    width: 100%;
    outline: none;
}

.apex-palette-results {
    max-height: 340px;
    overflow-y: auto;
    padding: 8px;
}

.apex-palette-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.apex-palette-item:hover, .apex-palette-item.selected {
    background: rgba(56, 189, 248, 0.12);
    color: #fff;
}

/* ----------------------------------------------------
   TOAST NOTIFICATION ENGINE
---------------------------------------------------- */
.apex-toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 300;
    pointer-events: none;
}

.apex-toast {
    pointer-events: auto;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 12px 18px;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    transform: translateY(12px);
    opacity: 0;
    transition: all var(--transition-smooth);
}
.apex-toast.show {
    transform: translateY(0);
    opacity: 1;
}

.apex-toast.toast-success {
    border-color: rgba(16, 185, 129, 0.4);
}
.apex-toast.toast-error {
    border-color: rgba(244, 63, 94, 0.4);
}
.apex-toast.toast-info {
    border-color: rgba(56, 189, 248, 0.4);
}

/* ----------------------------------------------------
   OBSIDIAN GLASS MODAL SYSTEM (ApexUI.modal)
---------------------------------------------------- */
.apex-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 250;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.apex-modal-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.apex-modal-card {
    background: #0d1322;
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85), 0 0 40px rgba(56, 189, 248, 0.15);
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.95) translateY(10px);
    transition: all var(--transition-fast);
    overflow: hidden;
}

.apex-modal-backdrop.active .apex-modal-card {
    transform: scale(1) translateY(0);
}

.apex-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.02);
}

.apex-modal-body {
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.apex-modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Form inputs & controls */
.apex-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.apex-form-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
}

.apex-input,
.apex-select,
.apex-textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    color: #fff;
    font-size: 13.5px;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.apex-input:focus,
.apex-select:focus,
.apex-textarea:focus {
    border-color: #38bdf8;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.apex-textarea {
    min-height: 80px;
    resize: vertical;
}

/* ----------------------------------------------------
   RESPONSIVE TABLE CONTAINER (NO JAMMING)
---------------------------------------------------- */
.apex-table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.apex-table-container::-webkit-scrollbar {
    height: 6px;
}

.apex-table-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

table.apex-table-cards,
table.apex-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 780px;
}

table.apex-table-cards th,
table.apex-table-cards td,
table.apex-table th,
table.apex-table td {
    white-space: nowrap;
}

table.apex-table-cards td.allow-wrap,
table.apex-table td.allow-wrap {
    white-space: normal;
}

