/* 
   Sales Dashboard Design System 
   Focus: Premium SaaS, Glassmorphism, Responsive
*/

:root {
    /* Color Palette */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #10b981;
    --accent: #f59e0b;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    
    /* Backgrounds */
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #1e293b;
    
    /* Text */
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-on-dark: #f8fafc;
    
    /* Layout */
    --sidebar-width: 260px;
    --header-height: 70px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    
    /* Shadow */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
}

[data-theme="dark"] {
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --bg-sidebar: #020617;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
}

/* Layout Grid */
.app-container {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    background-color: var(--bg-sidebar);
    color: var(--text-on-dark);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-logo {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 3rem;
    background: linear-gradient(135deg, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    list-style: none;
    flex-grow: 1;
}

.nav-item {
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: #94a3b8;
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.nav-link i {
    margin-right: 0.75rem;
    font-size: 1.25rem;
}

.nav-link:hover, .nav-link.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Main Content */
.main-content {
    display: flex;
    flex-direction: column;
}

.header {
    height: var(--header-height);
    background-color: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.dashboard-content {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Components */
.card {
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0,0,0,0.05);
    margin-bottom: 1.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1.5rem;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.stat-info .label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-info .value {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 0.25rem;
}

.stat-info .trend {
    font-size: 0.75rem;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* Status Badges */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.badge-danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

/* Buttons */
.btn {
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

/* Tables */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

td {
    padding: 1rem;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    font-size: 0.9375rem;
}

/* Responsive Adjustments */
@media (max-width: 1024px) {
    .app-container {
        display: block; /* Stack container */
    }
    
    .sidebar {
        position: fixed;
        left: -280px; /* Force hide off-screen */
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 1001; /* Above everything */
        transition: transform 0.3s ease, left 0.3s ease;
        box-shadow: 10px 0 30px rgba(0,0,0,0.2);
        visibility: hidden; /* Prevent interaction when hidden */
    }
    
    .sidebar.active {
        left: 0;
        visibility: visible;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding-top: 70px; /* Space for fixed header if needed */
    }
    
    .header-menu-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
    
    .header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        padding: 0 1rem;
        height: 60px;
        background: var(--bg-card);
        border-bottom: 1px solid rgba(0,0,0,0.05);
    }
    
    .dashboard-content {
        padding: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    /* General grid breakdown */
    div[style*="display: grid"] {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    .header-right .user-profile span {
        display: none;
    }
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Arabic RTL Support */
[dir="rtl"] {
    text-align: right;
}
[dir="rtl"] .nav-link i {
    margin-right: 0;
    margin-left: 0.75rem;
}
[dir="rtl"] th {
    text-align: right;
}
