/* ==========================================================================
   Apple Design System & VPS Dashboard Aesthetics (Sonoma / iOS 18 Design)
   Plus Jakarta Sans & JetBrains Mono Typography - Light & Dark Modes
   ========================================================================== */

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

:root {
    --apple-font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --apple-mono: 'JetBrains Mono', ui-monospace, Menlo, Monaco, Consolas, monospace;
    
    /* Light Mode Tokens (Default) */
    --bg-page: #f8fafc;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --card-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.05), 0 1px 3px 0 rgba(0, 0, 0, 0.03);
    --card-shadow-hover: 0 12px 28px -4px rgba(15, 23, 42, 0.09), 0 4px 8px -2px rgba(0, 0, 0, 0.04);
    --key-badge-bg: #f1f5f9;
    --key-badge-border: #cbd5e1;
    --key-badge-text: #0f172a;
}

html.dark {
    /* Dark Mode Tokens */
    --bg-page: #070a12;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --card-bg: rgba(15, 23, 42, 0.65);
    --card-border: rgba(255, 255, 255, 0.09);
    --card-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.08), 0 12px 36px -12px rgba(0, 0, 0, 0.45);
    --card-shadow-hover: inset 0 1px 0 0 rgba(255, 255, 255, 0.14), 0 16px 44px -10px rgba(0, 0, 0, 0.65);
    --key-badge-bg: rgba(0, 0, 0, 0.5);
    --key-badge-border: rgba(255, 255, 255, 0.12);
    --key-badge-text: #e2e8f0;
}

body {
    font-family: var(--apple-font);
    background-color: var(--bg-page);
    background-image: 
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(99, 102, 241, 0.07), transparent),
        radial-gradient(ellipse 60% 40% at 90% 10%, rgba(14, 165, 233, 0.04), transparent);
    background-attachment: fixed;
    letter-spacing: -0.012em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html.dark body {
    background-image: 
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(99, 102, 241, 0.14), transparent),
        radial-gradient(ellipse 60% 40% at 90% 10%, rgba(14, 165, 233, 0.07), transparent);
}

/* Glassmorphism & Structured Cards */
.apple-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    box-shadow: var(--card-shadow);
    border-radius: 1.25rem;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease;
}

html.dark .apple-card {
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
}

.apple-card:hover {
    border-color: #cbd5e1;
    box-shadow: var(--card-shadow-hover);
}

html.dark .apple-card:hover {
    border-color: rgba(255, 255, 255, 0.18);
}

/* Sub-card box (inner cards) */
.apple-box {
    border-radius: 0.875rem;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
}

html.dark .apple-box {
    border-color: rgba(255, 255, 255, 0.07);
    background: rgba(7, 10, 18, 0.5);
}

/* ==========================================================================
   Action Buttons (Apple Cupertino Strict Inline-Row System)
   ========================================================================== */
.apple-btn {
    font-family: var(--apple-font);
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.5rem !important;
    white-space: nowrap !important;
    line-height: 1.25rem !important;
    font-weight: 600 !important;
    border-radius: 0.75rem !important;
    transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1) !important;
    cursor: pointer !important;
    user-select: none !important;
    text-decoration: none !important;
}

.apple-btn svg {
    display: inline-block !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    vertical-align: middle !important;
}

.apple-btn span {
    display: inline-block !important;
    white-space: nowrap !important;
    vertical-align: middle !important;
}

.apple-btn:active {
    transform: scale(0.97) !important;
}

/* Button Variants */
.apple-btn-primary {
    background: linear-gradient(180deg, #6366f1 0%, #4f46e5 100%) !important;
    color: #ffffff !important;
    border: 1px solid rgba(67, 56, 202, 0.5) !important;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.06), 0 4px 12px 0 rgba(79, 70, 229, 0.3), inset 0 1px 0 0 rgba(255, 255, 255, 0.25) !important;
}

.apple-btn-primary:hover {
    background: linear-gradient(180deg, #4f46e5 0%, #4338ca 100%) !important;
    box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.08), 0 6px 16px 0 rgba(79, 70, 229, 0.42) !important;
}

.apple-btn-secondary {
    background: #ffffff !important;
    color: #1e293b !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.05), inset 0 1px 0 0 rgba(255, 255, 255, 1) !important;
}

.apple-btn-secondary:hover {
    background: #f8fafc !important;
    border-color: #94a3b8 !important;
    color: #0f172a !important;
    box-shadow: 0 2px 6px -1px rgba(15, 23, 42, 0.1) !important;
}

html.dark .apple-btn-secondary {
    background: rgba(255, 255, 255, 0.06) !important;
    color: #f1f5f9 !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.08), 0 2px 8px rgba(0, 0, 0, 0.25) !important;
}

html.dark .apple-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12) !important;
    border-color: rgba(255, 255, 255, 0.22) !important;
    color: #ffffff !important;
}

.apple-btn-amber {
    background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%) !important;
    color: #b45309 !important;
    border: 1px solid #fde68a !important;
    box-shadow: 0 1px 2px rgba(245, 158, 11, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.8) !important;
}

.apple-btn-amber:hover {
    background: #fde68a !important;
    border-color: #fcd34d !important;
    color: #92400e !important;
}

html.dark .apple-btn-amber {
    background: rgba(245, 158, 11, 0.15) !important;
    color: #fcd34d !important;
    border: 1px solid rgba(245, 158, 11, 0.3) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
}

html.dark .apple-btn-amber:hover {
    background: rgba(245, 158, 11, 0.25) !important;
    border-color: rgba(245, 158, 11, 0.45) !important;
    color: #fbbf24 !important;
}

.apple-btn-sky {
    background: linear-gradient(180deg, #f0f9ff 0%, #e0f2fe 100%) !important;
    color: #0369a1 !important;
    border: 1px solid #bae6fd !important;
    box-shadow: 0 1px 2px rgba(14, 165, 233, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.8) !important;
}

.apple-btn-sky:hover {
    background: #bae6fd !important;
    border-color: #7dd3fc !important;
    color: #075985 !important;
}

html.dark .apple-btn-sky {
    background: rgba(14, 165, 233, 0.15) !important;
    color: #7dd3fc !important;
    border: 1px solid rgba(14, 165, 233, 0.3) !important;
}

html.dark .apple-btn-sky:hover {
    background: rgba(14, 165, 233, 0.25) !important;
    border-color: rgba(14, 165, 233, 0.45) !important;
}

.apple-btn-emerald {
    background: linear-gradient(180deg, #10b981 0%, #059669 100%) !important;
    color: #ffffff !important;
    border: 1px solid rgba(4, 120, 87, 0.5) !important;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05), 0 4px 12px 0 rgba(16, 185, 129, 0.3), inset 0 1px 0 0 rgba(255, 255, 255, 0.25) !important;
}

.apple-btn-emerald:hover {
    background: linear-gradient(180deg, #059669 0%, #047857 100%) !important;
    box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.08), 0 6px 16px 0 rgba(16, 185, 129, 0.4) !important;
}

.apple-btn-rose {
    background: linear-gradient(180deg, #f43f5e 0%, #e11d48 100%) !important;
    color: #ffffff !important;
    border: 1px solid rgba(190, 18, 60, 0.5) !important;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05), 0 4px 12px 0 rgba(225, 29, 72, 0.3), inset 0 1px 0 0 rgba(255, 255, 255, 0.25) !important;
}

.apple-btn-rose:hover {
    background: linear-gradient(180deg, #e11d48 0%, #be123c 100%) !important;
    box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.08), 0 6px 16px 0 rgba(225, 29, 72, 0.4) !important;
}

/* iOS Toggle Switch */
.ios-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.ios-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.ios-slider {
    width: 38px;
    height: 22px;
    background-color: #cbd5e1;
    border-radius: 9999px;
    transition: background-color 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

html.dark .ios-slider {
    background-color: #334155;
}

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

.ios-switch input:checked + .ios-slider {
    background-color: #4f46e5;
}

.ios-switch input:checked + .ios-slider::before {
    transform: translateX(16px);
}

/* Segmented Control Pill Bar */
.apple-segmented-bar {
    background: #e2e8f0;
    border: 1px solid #cbd5e1;
    border-radius: 9999px;
    padding: 3px;
    display: inline-flex;
    gap: 2px;
}

html.dark .apple-segmented-bar {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.apple-segmented-item {
    padding: 0.35rem 0.85rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    transition: all 0.15s ease;
}

.apple-segmented-item.active {
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

html.dark .apple-segmented-item {
    color: #94a3b8;
}

html.dark .apple-segmented-item.active {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* Monospace Pill Key Displays (JetBrains Mono) */
.key-badge {
    font-family: var(--apple-mono);
    letter-spacing: 0.03em;
    font-weight: 600;
    background: var(--key-badge-bg);
    color: var(--key-badge-text);
    border: 1px solid var(--key-badge-border);
    border-radius: 0.5rem;
    padding: 0.2rem 0.55rem;
}

/* Sleek Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03);
}

html.dark ::-webkit-scrollbar-track {
    background: rgba(7, 10, 18, 0.5);
}

::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.4);
    border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.7);
}

/* Slow Spin */
@keyframes spin-slow {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.animate-spin-slow {
    animation: spin-slow 4s linear infinite;
}

* {
    -webkit-tap-highlight-color: transparent;
}

/* Safe Area Bottom for Modern Mobile Devices */
.safe-bottom {
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0px));
}

/* Off-Canvas Navigation Drawer Smooth Slide */
#mobile-drawer {
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform;
}

/* Cockpit Pro KPI Cards (Datadog style) */
.cockpit-kpi {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 0.875rem;
    padding: 0.875rem 1rem;
    position: relative;
    overflow: hidden;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.cockpit-kpi::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2.5px;
    background: currentColor;
    opacity: 0.85;
}
.cockpit-kpi:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px -4px rgba(0, 0, 0, 0.3);
}
.cockpit-kpi-cyan { color: #06b6d4; }
.cockpit-kpi-emerald { color: #10b981; }
.cockpit-kpi-violet { color: #8b5cf6; }
.cockpit-kpi-amber { color: #f59e0b; }
.cockpit-kpi-rose { color: #f43f5e; }
.cockpit-kpi-indigo { color: #6366f1; }

/* Table Density Classes */
.table-dense {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
.table-dense th {
    padding: 0.45rem 0.75rem !important;
    font-size: 0.6875rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
}
.table-dense td {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.75rem !important;
}

/* Sidebar Collapsed Mode (64px mini-cockpit) */
#sidebar-desktop {
    transition: width 0.25s cubic-bezier(0.16, 1, 0.3, 1), padding 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: width;
}
.sidebar-collapsed-mode #sidebar-desktop {
    width: 4.5rem !important;
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
}
.sidebar-collapsed-mode #sidebar-desktop .nav-hide-collapsed {
    display: none !important;
}
.sidebar-collapsed-mode #sidebar-desktop .nav-center-collapsed {
    justify-content: center !important;
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
}
.sidebar-collapsed-mode #sidebar-desktop .nav-group-title {
    display: none !important;
}
