:root {
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --primary-dark: #1d4ed8;
    --secondary: #7c3aed;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #1f2937;
    --gray: #6b7280;
    --light: #f3f4f6;
    --white: #ffffff;
    --border: #e5e7eb;
    --bs-body-bg: #f8fafc;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --glass-bg: rgba(255, 255, 255, 0.85);
}

[data-theme='dark'] {
    --primary: #3b82f6;
    --primary-light: #60a5fa;
    --primary-dark: #2563eb;
    --secondary: #8b5cf6;
    --dark: #f9fafb;
    --gray: #9ca3af;
    --light: #374151;
    --white: #1f2937;
    --border: #374151;
    --bs-body-bg: #111827;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    --glass-bg: rgba(31, 41, 55, 0.85);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Cairo', sans-serif;
}

body {
    background-color: var(--bs-body-bg);
    color: var(--dark);
    line-height: 1.6;
}

/* Authentication Page */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--light) 0%, #e2e8f0 100%);
    position: relative;
    overflow: hidden;
}

.auth-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(37,99,235,0.05) 0%, rgba(255,255,255,0) 70%);
    animation: rotate 20s linear infinite;
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.auth-box {
    background: var(--white);
    padding: 2.5rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    position: relative;
    z-index: 1;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo i {
    font-size: 3.5rem;
    color: var(--primary);
    margin-bottom: 1rem;
    text-shadow: 0 4px 10px rgba(37,99,235,0.3);
}

.auth-logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
}

/* Base App Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--white);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    z-index: 1000;
    box-shadow: 2px 0 10px rgba(0,0,0,0.02);
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 1.25rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.close-sidebar-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--gray);
    cursor: pointer;
}

.user-info {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
}

.user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
    box-shadow: var(--shadow);
}

.user-details h3 {
    font-size: 1rem;
    margin: 0;
}

.user-details span {
    font-size: 0.8rem;
    color: var(--gray);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.85rem 1.5rem;
    color: var(--dark);
    text-decoration: none;
    transition: var(--transition);
    border-right: 3px solid transparent;
    font-weight: 500;
}

.sidebar-nav li a:hover, .sidebar-nav li a.active {
    background: var(--bs-body-bg);
    color: var(--primary);
    border-right-color: var(--primary);
}

.sidebar-nav li a i {
    width: 20px;
    text-align: center;
}

.nav-divider {
    padding: 1rem 1.5rem 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--gray);
    font-weight: 700;
    letter-spacing: 1px;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 0.75rem;
    background: var(--light);
    color: var(--danger);
    text-decoration: none;
    border-radius: 0.5rem;
    transition: var(--transition);
    font-weight: 600;
}

.logout-btn:hover {
    background: #fee2e2;
}

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

.topbar {
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    position: sticky;
    top: 0;
    z-index: 999;
}

.open-sidebar-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--dark);
    cursor: pointer;
}

.topbar-title h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

.content-wrapper {
    padding: 2rem;
    flex: 1;
    overflow-y: auto;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--dark);
    font-size: 0.95rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: var(--transition);
    background: var(--white);
    color: var(--dark);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 4px 6px rgba(37,99,235,0.1);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 6px 12px rgba(37,99,235,0.2);
    transform: translateY(-1px);
}

.btn-block {
    display: block;
    width: 100%;
}

.alert {
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #f87171;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #34d399;
}

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

.stat-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    border: 1px solid var(--border);
    transition: var(--transition);
}

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

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

.stat-icon.primary { background: linear-gradient(135deg, rgba(37,99,235,0.15) 0%, rgba(37,99,235,0.05) 100%); color: var(--primary); }
.stat-icon.success { background: linear-gradient(135deg, rgba(16,185,129,0.15) 0%, rgba(16,185,129,0.05) 100%); color: var(--success); }
.stat-icon.warning { background: linear-gradient(135deg, rgba(245,158,11,0.15) 0%, rgba(245,158,11,0.05) 100%); color: var(--warning); }
.stat-icon.danger { background: linear-gradient(135deg, rgba(239,68,68,0.15) 0%, rgba(239,68,68,0.05) 100%); color: var(--danger); }

.stat-details h3 {
    font-size: 0.9rem;
    color: var(--gray);
    margin-bottom: 0.25rem;
}

.stat-details p {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(3px);
    z-index: 1050;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
}

.modal-container {
    background: var(--white);
    border-radius: 1rem;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-overlay.show .modal-container {
    transform: scale(1);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--gray);
    cursor: pointer;
}

.modal-body {
    padding: 1.5rem;
}

/* Data Tables */
.table-container {
    background: var(--white);
    border-radius: 1rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.table-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

th, td {
    padding: 1rem 1.5rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--bs-body-bg);
    font-weight: 600;
    color: var(--gray);
    text-transform: uppercase;
    font-size: 0.85rem;
}

tbody tr:hover {
    background: var(--bs-body-bg);
}

.status-badge {
    padding: 0.35rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
}

.status-pending { background: rgba(245,158,11,0.1); color: var(--warning); }
.status-confirmed, .status-in_progress { background: rgba(37,99,235,0.1); color: var(--primary); }
.status-shipped, .status-completed { background: rgba(16,185,129,0.1); color: var(--success); }
.status-delivered { background: rgba(16,185,129,0.2); color: #065f46; }
.status-cancelled, .status-revision { background: rgba(239,68,68,0.1); color: var(--danger); }

/* Responsive Tables for Mobile */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        right: -260px;
        top: 0;
        bottom: 0;
    }
    
    .sidebar.active {
        right: 0;
    }
    
    .open-sidebar-btn, .close-sidebar-btn {
        display: block;
    }
    
    .topbar {
        padding: 1rem;
        gap: 1rem;
        flex-wrap: wrap;
    }
    
    .topbar-actions {
        width: 100%;
        display: flex;
        justify-content: center;
        margin-top: 10px;
    }
    
    .content-wrapper {
        padding: 1rem;
    }
    
    .table-container {
        border: none;
        background: transparent;
        box-shadow: none;
    }
    
    table, thead, tbody, th, td, tr {
        display: block;
    }
    
    thead tr {
        display: none; /* Hide headers visually but keep accessibility in mind if needed */
    }
    
    tr {
        background: var(--white) !important;
        border: 1px solid var(--border);
        border-radius: 0.5rem;
        margin-bottom: 1rem;
        box-shadow: var(--shadow);
        padding: 0.5rem;
        position: relative;
    }
    
    td {
        border: none !important;
        position: relative;
        padding: 0.5rem 1rem 0.5rem 40% !important;
        text-align: left !important;
        white-space: normal !important;
        min-height: 40px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px dashed var(--border) !important;
    }
    
    td:last-child {
        border-bottom: none !important;
        justify-content: center;
        padding-top: 1rem;
    }
    
    td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--gray);
        position: absolute;
        right: 1rem;
        top: 50%;
        transform: translateY(-50%);
        text-align: right;
    }
}

