/**
 * =====================================================================
 * AGY Gateway - Enterprise Fintech-Grade Design System
 * Stripe / Linear / Vercel Pure White Light-Mode Architecture
 * 100% Pure CSS - Fluid Cubic-Bezier Motion - Universal Browser Compatibility
 * =====================================================================
 */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    /* Color Palette: Pure White & Slate */
    --bg-canvas: #F8FAFC;
    --bg-surface: #FFFFFF;
    --bg-surface-alt: #F1F5F9;
    --border-color: #E2E8F0;
    --border-subtle: #F1F5F9;
    --border-focus: #2563EB;

    /* Typographic Slate */
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #64748B;
    --text-subtle: #94A3B8;

    /* Primary Accent (Cobalt Blue) */
    --brand-primary: #2563EB;
    --brand-primary-hover: #1D4ED8;
    --brand-primary-light: #EFF6FF;
    --brand-primary-border: #BFDBFE;

    /* Status Colors */
    --status-success: #059669;
    --status-success-bg: #ECFDF5;
    --status-success-border: #A7F3D0;

    --status-warning: #B45309;
    --status-warning-bg: #FFFBEB;
    --status-warning-border: #FDE68A;

    --status-danger: #DC2626;
    --status-danger-bg: #FEF2F2;
    --status-danger-border: #FECACA;

    /* Typography */
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
    --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.03), 0 8px 24px rgba(15, 23, 42, 0.04);
    --shadow-float: 0 20px 40px -8px rgba(15, 23, 42, 0.08), 0 8px 16px -4px rgba(15, 23, 42, 0.03);

    /* Transitions */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: 0.15s var(--ease-in-out);
    --transition-normal: 0.25s var(--ease-out-expo);
}

/* Reset & Base Elements */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

body {
    background-color: var(--bg-canvas);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

code, pre, .font-mono {
    font-family: var(--font-mono);
}

.tabular-nums {
    font-variant-numeric: tabular-nums;
}

/* =====================================================================
   App Layout System: Fixed 260px Sidebar + Sticky Topbar + Main Canvas
   ===================================================================== */
.app-layout {
    display: flex;
    min-height: 100vh;
    background-color: var(--bg-canvas);
    position: relative;
    width: 100%;
}

/* Fixed 260px Left Sidebar */
.app-sidebar {
    width: 260px;
    min-width: 260px;
    max-width: 260px;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    background: #FFFFFF;
    border-right: 1px solid var(--border-color);
    z-index: 50;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

.brand-header {
    height: 64px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    background: #FFFFFF;
    flex-shrink: 0;
}

.brand-logo {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--brand-primary);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.brand-text {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-sub {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-subtle);
    padding: 12px 10px 4px;
}

.nav-item, .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition-fast);
    border-right: 3px solid transparent;
}

.nav-item:hover, .nav-link:hover {
    background: var(--bg-surface-alt);
    color: var(--text-primary);
}

.nav-item.active, .nav-link.active {
    background: var(--brand-primary-light);
    color: #1D4ED8;
    font-weight: 600;
    border-right: 3px solid var(--brand-primary);
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: inherit;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: #FFFFFF;
    flex-shrink: 0;
}

/* Main Content Area */
.app-main {
    margin-left: 260px;
    flex: 1;
    min-width: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-canvas);
}

/* Sticky Topbar */
.topbar {
    position: sticky;
    top: 0;
    height: 64px;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    z-index: 40;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-title, .page-heading {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin: 0;
}

/* =====================================================================
   Sticky KPI Grid (4-Column Enterprise Strip)
   ===================================================================== */
.kpi-strip, .kpi-container {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    padding: 24px 32px 0;
}

.kpi-cell, .kpi-card {
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: var(--transition-normal);
}

.kpi-cell:hover, .kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-float);
    border-color: #CBD5E1;
}

.kpi-label, .kpi-card-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.kpi-value, .kpi-card-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.kpi-value.text-accent {
    color: var(--brand-primary);
}

.kpi-sub, .kpi-card-subtitle {
    font-size: 11px;
    color: var(--text-subtle);
    font-weight: 500;
}

/* Content Canvas */
.page-content, .page-container {
    padding: 24px 32px 48px;
    flex: 1;
    min-width: 0;
}

/* =====================================================================
   Cards & Panels (Elevated White Surfaces)
   ===================================================================== */
.card, .panel {
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    margin-bottom: 24px;
    transition: var(--transition-normal);
}

.card-header, .panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    background: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title, .panel-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.card-desc, .panel-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.card-body, .panel-body {
    padding: 20px;
}

.card-footer, .panel-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-canvas);
}

/* =====================================================================
   Enterprise Data Tables
   ===================================================================== */
.table-responsive, .table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table, .data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    text-align: left;
}

.table th, .data-table th {
    background: var(--bg-canvas);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.table td, .data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-size: 13px;
    vertical-align: middle;
}

.table tbody tr:last-child td, .data-table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr, .data-table tbody tr {
    transition: background-color 0.15s ease;
}

.table tbody tr:hover, .data-table tbody tr:hover {
    background-color: #F8FAFC;
}

/* =====================================================================
   Badges, Pills & Status Indicators
   ===================================================================== */
.badge, .pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.01em;
    line-height: 1.3;
}

.badge-success, .pill-success {
    background: var(--status-success-bg);
    color: var(--status-success);
    border: 1px solid var(--status-success-border);
}

.badge-danger, .pill-danger {
    background: var(--status-danger-bg);
    color: var(--status-danger);
    border: 1px solid var(--status-danger-border);
}

.badge-warning, .pill-warning {
    background: var(--status-warning-bg);
    color: var(--status-warning);
    border: 1px solid var(--status-warning-border);
}

.badge-neutral, .pill-neutral {
    background: var(--bg-surface-alt);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.badge-primary, .badge-brand, .pill-brand {
    background: var(--brand-primary-light);
    color: var(--brand-primary);
    border: 1px solid var(--brand-primary-border);
}

/* Pulse Dots */
.pulse-dot, .dot-pulse {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.pulse-success {
    background: #10B981;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulseEmerald 2s infinite;
}

.pulse-danger {
    background: #EF4444;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    animation: pulseRose 2s infinite;
}

.pulse-warning {
    background: #F59E0B;
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
    animation: pulseAmber 2s infinite;
}

@keyframes pulseEmerald {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes pulseRose {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

@keyframes pulseAmber {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

/* =====================================================================
   Banners & System Alerts
   ===================================================================== */
.banner {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 13px;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 12px;
}

.banner-warning {
    background: var(--status-warning-bg);
    border: 1px solid var(--status-warning-border);
    color: #92400E;
}

.banner-danger {
    background: var(--status-danger-bg);
    border: 1px solid var(--status-danger-border);
    color: #991B1B;
}

.banner-success {
    background: var(--status-success-bg);
    border: 1px solid var(--status-success-border);
    color: #065F46;
}

.banner-info {
    background: var(--brand-primary-light);
    border: 1px solid var(--brand-primary-border);
    color: #1E40AF;
}

/* =====================================================================
   Buttons (Stripe Tactile Micro-Interactions)
   ===================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    border: 1px solid transparent;
    text-decoration: none;
    line-height: 1.4;
    user-select: none;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary, .btn-brand {
    background: var(--brand-primary);
    color: #FFFFFF;
    border-color: var(--brand-primary);
}

.btn-primary:hover, .btn-brand:hover {
    background: var(--brand-primary-hover);
    border-color: var(--brand-primary-hover);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
}

.btn-secondary, .btn-outline {
    background: #FFFFFF;
    border-color: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover, .btn-outline:hover {
    background: var(--bg-surface-alt);
    border-color: #CBD5E1;
    color: var(--text-primary);
}

.btn-danger {
    background: var(--status-danger);
    color: #FFFFFF;
    border-color: var(--status-danger);
}

.btn-danger:hover {
    background: #B91C1C;
    border-color: #B91C1C;
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.25);
}

.btn-sm {
    padding: 5px 11px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

.btn-block {
    width: 100%;
    display: flex;
}

/* =====================================================================
   Form Controls (42px Sleek Inputs)
   ===================================================================== */
.form-group, .form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 18px;
}

.form-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-input, .form-control, .input-box {
    width: 100%;
    height: 42px;
    padding: 0 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: #FFFFFF;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    transition: var(--transition-fast);
    box-sizing: border-box;
}

textarea.form-input, textarea.form-control, textarea.input-box {
    height: auto;
    min-height: 84px;
    padding: 10px 14px;
}

.form-input:focus, .form-control:focus, .input-box:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-hint, .field-hint {
    font-size: 11px;
    color: var(--text-muted);
}

/* =====================================================================
   Animated Toggle Switch (1-Click Bet Kill-Switch)
   ===================================================================== */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #CBD5E1;
    transition: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

input:checked + .toggle-slider {
    background-color: var(--brand-primary);
}

input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* =====================================================================
   Terminal Snippet Container
   ===================================================================== */
.terminal-card {
    background: #0F172A;
    color: #F8FAFC;
    border-radius: var(--radius-md);
    padding: 18px;
    font-family: var(--font-mono);
    font-size: 12px;
    position: relative;
    overflow-x: auto;
    border: 1px solid #1E293B;
}

.terminal-copy {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.terminal-copy:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* =====================================================================
   Toast System & Modals
   ===================================================================== */
#toast-system {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast-item {
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-float);
    border-radius: var(--radius-md);
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    font-weight: 600;
    pointer-events: auto;
    animation: toastPop 0.35s var(--ease-out-expo);
}

@keyframes toastPop {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(6px);
    z-index: 999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop.is-active {
    display: flex;
}

.modal-sheet {
    background: #FFFFFF;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-float);
    width: 100%;
    max-width: 540px;
    overflow: hidden;
    animation: sheetIn 0.3s var(--ease-out-expo);
}

@keyframes sheetIn {
    from { transform: scale(0.96) translateY(8px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

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

.modal-sheet-title {
    font-size: 16px;
    font-weight: 700;
}

.modal-sheet-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    display: flex;
}

.modal-sheet-body {
    padding: 24px;
}

.modal-sheet-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: var(--bg-surface-alt);
}

/* =====================================================================
   Mobile & Responsive Adaptations
   ===================================================================== */
@media (max-width: 1024px) {
    .kpi-strip, .kpi-container {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .app-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: none;
    }
    
    .sidebar-open .app-sidebar {
        transform: translateX(0);
        box-shadow: 0 0 40px rgba(15, 23, 42, 0.25);
    }

    .app-main {
        margin-left: 0;
    }

    .topbar {
        padding: 0 16px;
    }

    .kpi-strip, .kpi-container {
        grid-template-columns: 1fr;
        padding: 16px 16px 0;
    }

    .page-content, .page-container {
        padding: 16px 16px 36px;
    }
}
