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

:root {
    --primary: #F97316;
    --primary-hover: #EA580C;
    --secondary: #0F172A;
    --secondary-light: #1E293B;
    --accent: #F97316;
    --text-main: #E2E8F0;
    --text-dark: #1E293B;
    --bg-light: #F8FAFC;
    --bg-white: #FFFFFF;
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
    --border: #E2E8F0;
    --radius: 16px;
    --transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --glass: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.3);
}

/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

[dir="rtl"] {
    font-family: 'Cairo', sans-serif;
}

[dir="ltr"] {
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

button {
    cursor: pointer;
    border: none;
    outline: none;
    transition: var(--transition);
}

ul {
    list-style: none;
}

/* Layout Utilities */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 2rem;
}

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-col { flex-direction: column; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.gap-8 { gap: 2rem; }

.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 101, 35, 0.3);
}

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

.btn-secondary:hover {
    background-color: var(--secondary-light);
}

.btn-outline {
    border: 2px solid var(--border);
    background: transparent;
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Typography */
h1 { font-size: 3.5rem; line-height: 1.2; font-weight: 800; }
h2 { font-size: 2.5rem; line-height: 1.3; font-weight: 700; }
h3 { font-size: 1.75rem; line-height: 1.4; font-weight: 600; }
p { font-size: 1.1rem; color: #64748b; }

/* Micro-animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade {
    animation: fadeIn 0.8s ease forwards;
}

/* Mobile Sidebar Drawer Styles */
.mobile-sidebar {
    position: fixed;
    top: 0;
    right: -100%; /* Hidden off-screen right (RTL) */
    width: 85%;
    max-width: 320px;
    height: 100vh;
    background: white;
    z-index: 2000;
    box-shadow: -10px 0 30px rgba(0,0,0,0.1);
    transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.mobile-sidebar.active {
    right: 0;
}

.mobile-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: 0.3s;
}

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

/* Responsive Utilities */
@media (min-width: 769px) {
    .mobile-menu-toggle { display: none !important; }
}

@media (max-width: 768px) {
    .desktop-only { display: none !important; }
    .mobile-menu-toggle { display: block !important; }
    
    /* Dashboard Responsive Fixes */
    .admin-container, .dashboard-container {
        grid-template-columns: 1fr !important;
    }

    .admin-sidebar, .sidebar {
        position: fixed;
        top: 0;
        right: -100%;
        width: 280px;
        height: 100vh;
        z-index: 2005;
        transition: 0.4s;
    }

    .admin-sidebar.active, .sidebar.active {
        right: 0;
    }

    .admin-main, .main-content {
        padding: 1.5rem !important;
    }
}

/* Responsive */
@media (max-width: 1024px) {
    .container { padding: 0 1.5rem; }
}

@media (max-width: 768px) {
    h1 { font-size: 2.2rem; }
    h2 { font-size: 1.8rem; }
    h3 { font-size: 1.5rem; }
    
    .grid-cols-2, .grid-cols-3, .grid-cols-4 {
        grid-template-columns: 1fr;
    }
    
    .container { padding: 0 1rem; }

    /* Fix nav expansion on mobile */
    nav .header-container {
        padding: 0 1rem;
        flex-direction: column;
        height: auto;
        padding-bottom: 1rem;
    }
    nav { height: auto; }
    .nav-links { 
        gap: 1.5rem; 
        margin-top: 1rem;
        flex-direction: row; 
        flex-wrap: wrap;
        justify-content: center;
    }
    
    /* Global Table Fix */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    table {
        min-width: 600px; /* Force scroll on mobile */
    }

    /* Dashboard grids */
    .secondary-grid {
        grid-template-columns: 1fr !important;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
    .nav-links {
        display: none; /* Hide links on very small screens if no toggle exists */
    }
}

/* Stackable Table Pattern */
@media (max-width: 768px) {
    .stackable-table thead {
        display: none; /* Hide header on mobile */
    }
    .stackable-table, .stackable-table tbody, .stackable-table tr, .stackable-table td {
        display: block;
        width: 100%;
    }
    .stackable-table tr {
        margin-bottom: 1.5rem;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        padding: 0.5rem;
        box-shadow: var(--shadow);
    }
    .stackable-table td {
        text-align: left !important; /* Left for value in RTL context if needed, but usually we want it visual */
        padding: 0.75rem 1rem;
        border-bottom: 1px solid #f1f5f9;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    [dir="rtl"] .stackable-table td {
        text-align: right !important;
        flex-direction: row-reverse;
    }
    .stackable-table td:last-child {
        border-bottom: none;
    }
    .stackable-table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: #64748b;
        font-size: 0.8rem;
        text-transform: uppercase;
    }
}

/* Modern Dashboard Mobile Header */
.dashboard-mobile-header {
    display: none;
    position: sticky;
    top: 0;
    z-index: 1000;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 1.5rem;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

@media (max-width: 768px) {
    .dashboard-mobile-header {
        display: flex;
    }
}

/* Responsive Tabs Utilities */
.scrollable-tabs {
    display: flex;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    gap: 1rem;
    padding-bottom: 0.5rem;
    scrollbar-width: none; /* Firefox */
}
.scrollable-tabs::-webkit-scrollbar {
    display: none; /* Safari/Chrome */
}

/* RTL Specific Adjustments */
[dir="rtl"] .ml-auto { margin-right: auto; margin-left: 0; }
[dir="rtl"] .mr-auto { margin-left: auto; margin-right: 0; }
[dir="ltr"] .ml-auto { margin-left: auto; margin-right: 0; }
[dir="ltr"] .mr-auto { margin-right: auto; margin-left: 0; }
