/* ==========================================================================
   WOOFLOW & 965 NEXUS - ULTRA-RESPONSIVE MODERN GLASSMORPHISM DESIGN SYSTEM
   Optimized for Mobile, Tablet, Laptop, and 4K Ultra-wide Displays
   ========================================================================== */

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

:root {
    /* Theme Colors */
    --bg: #060c18;
    --bg-surface: #0a1426;
    --surface: #0d1a30;
    --surface-glass: rgba(13, 26, 48, 0.82);
    --surface-hover: #122240;
    --surface-card: rgba(16, 31, 56, 0.75);
    
    /* Lines & Borders */
    --line: rgba(36, 62, 98, 0.7);
    --line-subtle: rgba(255, 255, 255, 0.07);
    --line-glow: rgba(16, 185, 129, 0.35);
    
    /* Brand Accent Colors */
    --brand: #10b981;
    --brand-glow: rgba(16, 185, 129, 0.25);
    --brand-hover: #059669;
    --brand-light: #34d399;
    
    --cyan: #06b6d4;
    --cyan-glow: rgba(6, 182, 212, 0.25);
    --cyan-bg: rgba(6, 182, 212, 0.12);
    
    --violet: #8b5cf6;
    --violet-glow: rgba(139, 92, 246, 0.25);
    --violet-bg: rgba(139, 92, 246, 0.12);
    
    --green: #10b981;
    --green-bg: rgba(16, 185, 129, 0.12);
    
    --amber: #f59e0b;
    --amber-bg: rgba(245, 158, 11, 0.12);
    --amber-border: rgba(245, 158, 11, 0.35);
    
    --red: #f43f5e;
    --red-bg: rgba(244, 63, 94, 0.12);
    --red-border: rgba(244, 63, 94, 0.35);
    
    /* Text Hierarchy */
    --text: #f1f5f9;
    --muted: #94a3b8;
    --muted-dim: #64748b;
    
    /* Geometry */
    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 20px;
    --radius-pill: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.5);
}

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

html {
    scroll-behavior: smooth;
    color-scheme: dark;
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: var(--bg);
    background-image: 
        radial-gradient(circle at 90% -10%, rgba(16, 185, 129, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 10% 100%, rgba(6, 182, 212, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(139, 92, 246, 0.04) 0%, transparent 60%);
    background-attachment: fixed;
    color: var(--text);
    font-family: 'Cairo', system-ui, -apple-system, sans-serif !important;
    min-height: 100vh;
    line-height: 1.6;
    direction: rtl;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    color: #fff;
    font-weight: 800;
    line-height: 1.25;
}

a {
    color: inherit;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Layout Shell */
.app-shell {
    display: flex;
    min-height: 100vh;
    position: relative;
    width: 100%;
}

/* Backdrop for Mobile Drawer */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 105;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
}

.sidebar-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* Sidebar */
.app-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 260px;
    padding: 24px 16px;
    background: rgba(8, 16, 30, 0.94);
    border-left: 1px solid var(--line);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    z-index: 110;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Brand */
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 8px 22px;
    border-bottom: 1px solid var(--line-subtle);
    margin-bottom: 18px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #10b981, #06b6d4);
    color: #fff;
    font-size: 1.2rem;
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.35);
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.01em;
}

.brand-subtitle {
    font-size: 0.72rem;
    color: var(--muted-dim);
    font-weight: 600;
}

/* Nav */
.nav-label {
    padding: 12px 12px 6px;
    color: var(--muted-dim);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.app-nav {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 14px;
}

.app-nav a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 14px;
    border-radius: var(--radius);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.app-nav a:hover {
    background: var(--surface-hover);
    color: #fff;
    transform: translateX(-3px);
}

.app-nav a.active {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.18), rgba(6, 182, 212, 0.08));
    color: #fff;
    border-right: 3px solid var(--brand);
}

.nav-link-content {
    display: flex;
    align-items: center;
    gap: 11px;
}

.nav-icon {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
}

.nav-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--cyan);
    border: 1px solid var(--line);
    font-family: 'Plus Jakarta Sans', sans-serif;
}

/* Sidebar Footer */
.sidebar-foot {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--line-subtle);
}

.server-chip {
    padding: 12px;
    border: 1px solid rgba(16, 185, 129, 0.25);
    background: rgba(16, 185, 129, 0.08);
    border-radius: var(--radius);
    color: var(--brand-light);
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--brand);
    box-shadow: 0 0 10px var(--brand);
    position: relative;
    display: inline-block;
}

.pulse-dot::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 2px solid var(--brand);
    animation: pulseRing 2s infinite ease-out;
}

@keyframes pulseRing {
    0% { transform: scale(0.9); opacity: 1; }
    100% { transform: scale(2.2); opacity: 0; }
}

/* App Content Wrapper */
.app-content {
    margin-right: 260px;
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Topbar */
.app-topbar {
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    border-bottom: 1px solid var(--line);
    background: rgba(6, 12, 24, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 90;
}

.top-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

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

/* Page Container */
.app-main, .page-container {
    max-width: 1480px;
    width: 100%;
    margin: 0 auto;
    padding: 28px 32px;
    flex: 1;
}

/* Panels, Cards & Glass Containers */
.panel, .section, .card, .glass-card {
    background: var(--surface-glass) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--line) !important;
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-lg) !important;
    padding: 24px;
    margin-bottom: 24px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.panel:hover, .card:hover, .glass-card:hover {
    border-color: rgba(16, 185, 129, 0.35) !important;
    box-shadow: var(--shadow-lg);
}

/* Headers */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.panel-desc {
    color: var(--muted);
    font-size: 0.92rem;
    margin-top: 4px;
}

/* KPI / Stats Grid */
.stats, .stats-grid, .kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 26px;
}

.stat-card {
    background: var(--surface-glass);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.2s ease;
}

.stat-card:hover {
    border-color: var(--line-glow);
    transform: translateY(-2px);
}

.stat-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.stat-value {
    font-size: 1.9rem;
    font-weight: 800;
    color: #fff;
    font-family: 'Plus Jakarta Sans', 'Cairo', sans-serif;
    line-height: 1.2;
}

.stat-sub {
    font-size: 0.76rem;
    color: var(--muted-dim);
}

/* Tables & Wrappers */
.table-wrapper, .table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: rgba(10, 20, 36, 0.5);
    margin-bottom: 18px;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    text-align: right;
    min-width: 600px;
}

table thead {
    background: rgba(6, 12, 24, 0.8);
    border-bottom: 1px solid var(--line);
}

table th {
    padding: 14px 18px;
    color: var(--muted-dim);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--line-subtle);
    color: var(--text);
    vertical-align: middle;
}

table tbody tr {
    transition: background 0.15s ease;
}

table tbody tr:hover {
    background: rgba(255, 255, 255, 0.025);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: var(--radius);
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand), var(--brand-hover));
    color: #fff;
    box-shadow: 0 4px 14px var(--brand-glow);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--brand-glow);
}

.btn-secondary, .btn-off, .btn-ghost {
    background: var(--surface);
    color: var(--muted);
    border: 1px solid var(--line);
}

.btn-secondary:hover, .btn-off:hover, .btn-ghost:hover {
    background: var(--surface-hover);
    color: #fff;
    border-color: var(--line-glow);
}

.btn-success {
    background: linear-gradient(135deg, var(--brand), #059669);
    color: #fff;
}

.btn-danger {
    background: linear-gradient(135deg, var(--red), #e11d48);
    color: #fff;
}

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

/* Badges */
.badge, .live {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-size: 0.76rem;
    font-weight: 700;
    line-height: 1.2;
}

.badge-success, .badge-emerald { background: var(--green-bg); color: var(--green); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-info, .badge-cyan { background: var(--cyan-bg); color: var(--cyan); border: 1px solid rgba(6, 182, 212, 0.3); }
.badge-warning, .badge-amber { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-border); }
.badge-danger, .badge-rose { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }
.badge-purple, .badge-violet { background: var(--violet-bg); color: var(--violet); border: 1px solid rgba(139, 92, 246, 0.3); }
.badge-neutral { background: var(--surface); color: var(--muted); border: 1px solid var(--line); }

/* Forms & Filter Bar */
.filter-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 22px;
}

input, select, textarea {
    background: var(--bg) !important;
    border: 1px solid var(--line) !important;
    border-radius: var(--radius-sm) !important;
    padding: 10px 14px;
    color: #fff !important;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--brand) !important;
    box-shadow: 0 0 0 3px var(--brand-glow) !important;
}

/* Alerts */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 22px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: var(--green-bg); border: 1px solid rgba(16, 185, 129, 0.35); color: var(--brand-light); }
.alert-danger { background: var(--red-bg); border: 1px solid var(--red-border); color: var(--red); }
.alert-info { background: var(--cyan-bg); border: 1px solid rgba(6, 182, 212, 0.35); color: var(--cyan); }

/* Mobile Bottom Navigation (Visible on Small Screens) */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(8, 16, 30, 0.95);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 100;
    justify-content: space-around;
    align-items: center;
    padding: 0 8px;
}

.mobile-bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--muted-dim);
    font-size: 0.72rem;
    font-weight: 700;
}

.mobile-bottom-nav a.active, .mobile-bottom-nav a:hover {
    color: var(--brand-light);
}

.mobile-bottom-nav .bottom-nav-icon {
    font-size: 1.25rem;
}

/* Responsive Breakpoints */
.mobile-menu {
    display: none;
}

.desktop-only {
    display: flex;
}

@media (max-width: 980px) {
    .app-sidebar {
        transform: translateX(110%);
    }
    
    .app-sidebar.open {
        transform: translateX(0);
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.6);
    }
    
    .app-content {
        margin-right: 0;
    }
    
    .app-topbar {
        padding: 0 16px;
    }
    
    .app-main, .page-container {
        padding: 16px;
    }
    
    .mobile-menu {
        display: inline-flex;
    }
    
    .desktop-only {
        display: none !important;
    }
    
    .stats, .stats-grid, .kpi-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 14px;
    }
    
    .mobile-bottom-nav {
        display: flex;
    }
    
    body {
        padding-bottom: 70px; /* offset for bottom nav */
    }
}

@media (max-width: 600px) {
    .stats, .stats-grid, .kpi-grid {
        grid-template-columns: 1fr !important;
    }
    
    .app-topbar {
        height: 60px;
    }
    
    .top-title {
        font-size: 0.95rem;
    }
    
    .panel, .section, .card, .glass-card {
        padding: 16px;
        border-radius: var(--radius) !important;
    }
    
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
}
