:root {
    /* Premium Color Palette */
    --primary: #5b7fe5;
    --primary-dark: #4a6cd4;
    --primary-light: #818cf8;
    --primary-subtle: #eef2ff;

    --secondary: #64748b;
    --secondary-dark: #475569;
    --secondary-light: #94a3b8;

    --success: #10b981;
    --success-dark: #059669;
    --success-light: #34d399;

    --info: #3b82f6;
    --info-dark: #2563eb;
    --info-light: #60a5fa;

    --warning: #f59e0b;
    --warning-dark: #d97706;
    --warning-light: #fbbf24;

    --danger: #ef4444;
    --danger-dark: #dc2626;
    --danger-light: #f87171;

    /* Dark shades */
    --dark: #0f172a;
    --dark-medium: #1e293b;
    --dark-light: #334155;

    /* Light shades */
    --light: #f8fafc;
    --light-medium: #f1f5f9;
    --light-dark: #e2e8f0;

    /* Background */
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: linear-gradient(180deg, #2d3e50 0%, #1e293b 100%);

    /* Text */
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    /* Borders */
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;

    /* Layout */
    --sidebar-width: 280px;
    --header-height: 70px;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 24px;

    /* Shadows */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

    /* Glow Effects */
    --glow-primary: 0 0 20px rgba(91, 127, 229, 0.4);
    --glow-success: 0 0 20px rgba(16, 185, 129, 0.4);
    --glow-warning: 0 0 20px rgba(245, 158, 11, 0.4);
    --glow-danger: 0 0 20px rgba(239, 68, 68, 0.4);

    /* Transitions */
    --transition-base: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    overflow-x: hidden;
    direction: rtl;
    text-align: right;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   SIDEBAR STYLES - Premium Dark Design
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1000;
    color: #fff;
    transition: var(--transition-base);
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.2);
    padding: 1.5rem 0;
    overflow-y: auto;
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.02'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
    opacity: 0.4;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
    position: relative;
}

.sidebar-brand {
    font-size: 1.75rem;
    font-weight: 800;
    color: #fff;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 14px;
    letter-spacing: -0.5px;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    position: relative;
    transition: var(--transition-base);
}

.sidebar-brand:hover {
    transform: scale(1.05);
}

.sidebar-brand i {
    font-size: 2rem;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 12px rgba(99, 102, 241, 0.6));
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.sidebar-menu {
    list-style: none;
    padding: 0 1rem;
    margin: 0;
}

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

.nav-link {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: var(--transition-base);
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 1rem;
    position: relative;
    overflow: hidden;
}

.nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: linear-gradient(180deg, var(--primary-light) 0%, var(--primary) 100%);
    transform: scaleY(0);
    transition: var(--transition-base);
}

.nav-link:hover {
    color: white;
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(-4px);
}

.nav-link:hover::before {
    transform: scaleY(1);
}

.nav-link.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(99, 102, 241, 0.1) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    border-right: 4px solid var(--primary);
}

.nav-link.active i {
    color: var(--primary-light);
    filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.6));
}

.nav-link i {
    width: 1.5rem;
    font-size: 1.2rem;
    margin-left: 1rem;
    text-align: center;
    transition: var(--transition-base);
}

.nav-link:hover i {
    transform: scale(1.2);
}

.nav-link.text-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-light) !important;
}

/* ============================================
   MAIN CONTENT WRAPPER
   ============================================ */
.main-wrapper {
    margin-right: var(--sidebar-width);
    margin-left: 0;
    padding: 2rem;
    min-height: 100vh;
    transition: var(--transition-base);
    background: var(--bg-body);
}

/* ============================================
   CARDS - Premium Glass Design
   ============================================ */
.card {
    background: var(--bg-card);
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: var(--transition-base);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-light);
    padding: 1.5rem;
    font-weight: 600;
}

/* Premium Card Variants */
.card-premium {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    background: white;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-base);
}

.card-premium:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--border-color);
}

.card-header-premium {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-light);
    background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* Glass Card Effect */
.card-glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: var(--shadow-xl);
}

/* ============================================
   FORM CONTROLS - Modern Input Design
   ============================================ */
.form-control-premium {
    border: 2px solid var(--border-color);
    background: var(--light);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    transition: var(--transition-base);
    font-size: 1rem;
}

.form-control-premium:focus {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    outline: none;
}

.form-control-premium:hover {
    border-color: var(--secondary-light);
}

/* ============================================
   TABLES - Premium Data Display
   ============================================ */
.table th,
.table td,
table.dataTable tfoot td {
    vertical-align: middle;
    text-align: right !important;
    direction: rtl;
    padding: 1rem 1.25rem;
}

.table th {
    font-weight: 700;
    color: var(--secondary-dark);
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 2px solid var(--border-color);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.table-premium tbody tr {
    transition: var(--transition-fast);
    border-bottom: 1px solid var(--border-light);
}

.table-premium tbody tr:hover {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.02) 0%, rgba(99, 102, 241, 0.05) 100%);
    transform: scale(1.01);
    box-shadow: var(--shadow-sm);
}

.table-premium tbody tr:last-child {
    border-bottom: none;
}

/* ============================================
   BUTTONS - Interactive & Premium
   ============================================ */
.btn-premium {
    border-radius: var(--radius-md);
    padding: 12px 24px;
    font-weight: 600;
    transition: var(--transition-base);
    border: none;
    position: relative;
    overflow: hidden;
}

.btn-premium::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-premium:hover::before {
    width: 300px;
    height: 300px;
}

.btn-premium:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-premium:active {
    transform: translateY(0);
}

/* Button Icon Soft */
.btn-icon-soft {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    border: none;
    transition: var(--transition-base);
    font-size: 0.9rem;
}

.btn-icon-soft:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

/* ============================================
   STAT CARDS - Dashboard Cards
   ============================================ */
.stat-card-premium {
    background: white;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    transition: var(--transition-base);
    height: 100%;
    position: relative;
    overflow: hidden;
}

.stat-card-premium::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    transform: scaleX(0);
    transform-origin: right;
    transition: var(--transition-base);
}

.stat-card-premium:hover::before {
    transform: scaleX(1);
}

.stat-card-premium:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-2xl);
    border-color: var(--primary-subtle);
}

/* Icon Boxes */
.icon-box-lg {
    width: 70px;
    height: 70px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin-bottom: 1rem;
    transition: var(--transition-base);
}

.stat-card-premium:hover .icon-box-lg {
    transform: rotate(10deg) scale(1.1);
}

/* Avatar Box for Item Icons */
.avatar-box {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* Gradient Backgrounds */
.bg-gradient-primary-soft {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(99, 102, 241, 0.05) 100%);
    color: var(--primary);
}

.bg-gradient-warning-soft {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(245, 158, 11, 0.05) 100%);
    color: var(--warning);
}

.bg-gradient-success-soft {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(16, 185, 129, 0.05) 100%);
    color: var(--success);
}

.bg-gradient-info-soft {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.15) 0%, rgba(14, 165, 233, 0.05) 100%);
    color: var(--info);
}

.bg-gradient-danger-soft {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15) 0%, rgba(239, 68, 68, 0.05) 100%);
    color: var(--danger);
}

/* ============================================
   BADGES - Status Indicators
   ============================================ */
.badge {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    transition: var(--transition-base);
}

.badge:hover {
    transform: scale(1.05);
}

/* ============================================
   UTILITIES
   ============================================ */

/* Scrollbar Styling */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Floating Animation */
@keyframes float {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }
}

.float-animation {
    animation: float 3s ease-in-out infinite;
}

/* Shimmer Effect */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }

    100% {
        background-position: 1000px 0;
    }
}

.shimmer {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

/* ============================================
   RESPONSIVE DESIGN - Mobile First
   ============================================ */

/* Tablets and below (991px and down) */
@media (max-width: 991px) {
    :root {
        --sidebar-width: 280px;
    }

    /* Sidebar - Slide from right */
    .sidebar {
        transform: translateX(100%);
        box-shadow: -15px 0 50px rgba(0, 0, 0, 0.3);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    /* Main content - Full width on mobile */
    .main-wrapper {
        margin-right: 0;
        margin-left: 0;
        padding: 1.5rem;
        min-height: calc(100vh - 64px);
    }

    /* Adjust stat cards for tablet */
    .stat-card-premium {
        margin-bottom: 1rem;
    }

    /* Make buttons stack better */
    .btn-group-mobile {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .btn-group-mobile .btn {
        width: 100%;
    }
}

/* Mobile phones (768px and down) */
@media (max-width: 768px) {

    /* Spacing adjustments */
    .main-wrapper {
        padding: 1rem;
    }

    /* Typography - Smaller on mobile */
    h1,
    .h1 {
        font-size: 1.75rem !important;
    }

    h2,
    .h2 {
        font-size: 1.5rem !important;
    }

    h3,
    .h3 {
        font-size: 1.25rem !important;
    }

    h4,
    .h4 {
        font-size: 1.1rem !important;
    }

    h5,
    .h5 {
        font-size: 1rem !important;
    }

    /* Cards - Reduce padding */
    .card-header-premium {
        padding: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    /* Tables - Make responsive */
    .table-responsive {
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-sm);
    }

    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.875rem;
    }

    .table th {
        font-size: 0.75rem;
    }

    /* Stack table buttons vertically */
    .table .btn-icon-soft {
        width: 36px;
        height: 36px;
        font-size: 0.85rem;
    }

    /* Form controls - Larger touch targets */
    .form-control,
    .form-control-premium {
        font-size: 16px;
        /* Prevents zoom on iOS */
        padding: 0.875rem 1rem;
        min-height: 48px;
        /* Touch-friendly */
    }

    .btn,
    .btn-premium {
        min-height: 48px;
        /* Touch-friendly */
        padding: 0.875rem 1.25rem;
        font-size: 1rem;
    }

    /* Stat cards - Better mobile layout */
    .stat-card-premium {
        padding: 1.25rem !important;
    }

    .icon-box-lg {
        width: 56px;
        height: 56px;
        font-size: 1.5rem;
    }

    /* Welcome banner - Adjust for mobile */
    .welcome-banner {
        padding: 2rem 1.5rem !important;
        border-radius: 1.25rem !important;
    }

    .welcome-banner h1 {
        font-size: 1.5rem !important;
    }

    .welcome-banner p {
        font-size: 0.95rem !important;
    }

    /* Action buttons - Full width on mobile */
    .action-button {
        padding: 1.25rem 1rem;
    }

    .action-button i {
        font-size: 1.5rem;
    }

    /* Avatar box - Smaller on mobile */
    .avatar-box {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    /* Badge - Adjust size */
    .badge {
        padding: 0.35rem 0.75rem;
        font-size: 0.8rem;
    }

    /* Modals - Full screen on mobile */
    .modal-dialog {
        margin: 0.5rem;
    }

    .modal-content {
        border-radius: var(--radius-lg);
    }
}

/* Small phones (576px and down) */
@media (max-width: 576px) {

    /* Even tighter spacing */
    .main-wrapper {
        padding: 0.75rem;
    }

    /* Welcome banner - Stack content */
    .welcome-banner .welcome-content {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .date-display {
        width: 100%;
        min-width: auto;
    }

    /* Stat cards - Stack icon and text */
    .stat-card-premium .d-flex {
        flex-direction: column;
        align-items: flex-start !important;
    }

    .stat-card-premium .icon-box-lg {
        margin-bottom: 0.75rem;
        align-self: flex-start;
    }

    /* Charts - Reduce height */
    .chart-container {
        height: 250px !important;
    }

    /* Tables - Hide less important columns */
    .table-mobile-hide {
        display: none;
    }

    /* Buttons - Smaller icons */
    .btn i {
        font-size: 0.9rem;
    }

    /* Forms - Stack labels and inputs */
    .form-group label {
        margin-bottom: 0.5rem;
    }

    /* Sidebar - Adjust for small screens */
    .sidebar {
        width: 85vw;
        max-width: 320px;
    }

    .sidebar-header {
        height: 60px;
    }

    .sidebar-brand {
        font-size: 1.4rem;
    }

    /* Login page - Adjust for small screens */
    .login-container {
        padding: 1rem;
    }

    .glass-card {
        padding: 2rem 1.5rem !important;
        border-radius: 24px !important;
    }

    .brand-logo {
        width: 75px;
        height: 75px;
        font-size: 32px;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 896px) and (orientation: landscape) {
    .sidebar {
        width: 280px;
    }

    .main-wrapper {
        padding: 1rem;
    }

    .welcome-banner {
        padding: 1.5rem !important;
    }

    .stat-card-premium {
        padding: 1rem !important;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {

    /* Larger touch targets */
    .btn,
    .nav-link,
    .action-button,
    .btn-icon-soft {
        min-height: 48px;
        min-width: 48px;
    }

    /* Remove hover effects on touch devices */
    .stat-card-premium:hover,
    .card:hover,
    .action-button:hover {
        transform: none;
    }

    /* Use active states instead */
    .stat-card-premium:active {
        transform: scale(0.98);
    }

    .action-button:active {
        transform: scale(0.97);
    }

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

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {

    /* Sharper borders and shadows */
    .card,
    .btn,
    .form-control {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {

    .sidebar,
    .btn,
    .navbar,
    .mobile-navbar,
    .mobile-nav,
    .mobile-overlay,
    .action-button,
    .btn-icon-soft {
        display: none !important;
    }

    .main-wrapper {
        margin: 0;
        padding: 0;
    }

    .card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .table {
        font-size: 10pt;
    }

    /* Show all content */
    .table-mobile-hide {
        display: table-cell !important;
    }
}