/* ===== ROOT VARIABLES ===== */
:root {
    --primary: #3D2F7B;
    --primary-dark: #2b205a;
    --accent: #EC671F;
    --accent-dark: #d35400;
    --bg-light: #f3f4f7;
    --text-dark: #2c3e50;
    --text-light: #64748b;
    --border: #e2e8f0;
    --success: #2ecc71;
    --warning: #f39c12;
    --danger: #ef4444;
    --bg-white: #ffffff;
}

/* ===== GLOBAL STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Cairo', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
    direction: rtl;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    right: 0;
    top: 0;
    width: 260px;
    height: 100vh;
    background: var(--primary);
    color: white;
    padding-top: 20px;
    overflow-y: auto;
    box-shadow: -5px 0 15px rgba(0,0,0,0.1);
    z-index: 1000;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
}

.logo-area {
    text-align: center;
    padding: 0 20px 30px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 20px;
}

.logo-area img {
    max-width: 140px;
    height: auto;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.logo-area h4 {
    color: white;
    font-weight: bold;
    margin-top: 10px;
    font-size: 16px;
}

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

.nav-link {
    color: rgba(255,255,255,0.85);
    padding: 15px 25px;
    margin: 5px 15px;
    border-radius: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
}

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

.nav-link.active {
    background: linear-gradient(45deg, var(--accent), #ff8e4b);
    color: white;
    box-shadow: 0 4px 15px rgba(236, 103, 31, 0.4);
}

.nav-link i {
    margin-left: 12px;
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.auto-save-box {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    text-align: center;
    padding: 15px;
}

.save-badge {
    background: rgba(0,0,0,0.3);
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.8rem;
    color: #bdc3c7;
    display: inline-block;
    border: 1px solid rgba(255,255,255,0.1);
}

.pulse {
    animation: pulse-anim 2s infinite;
    color: #2ecc71;
}

@keyframes pulse-anim {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-right: 260px;
    padding: 30px;
    min-height: 100vh;
    animation: fadeIn 0.3s ease;
    transition: all 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== HEADER ===== */
.header-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.header-title h3 {
    font-size: 32px;
    font-weight: 800;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 12px;
    letter-spacing: -0.5px;
}

.header-title .text-muted {
    color: var(--text-light);
    font-size: 14px;
}

/* ===== CONTENT CARDS ===== */
.content-card {
    background: white;
    border-radius: 16px;
    border: none;
    box-shadow: 0 5px 20px rgba(0,0,0,0.05);
    padding: 25px;
    margin-bottom: 25px;
}

.content-card h5 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 24px;
}

/* ===== FORMS ===== */
.form-label {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 10px;
    font-size: 14px;
    display: block;
}

.form-control,
.form-select {
    border-radius: 10px;
    padding: 12px;
    border: 1px solid #e0e0e0;
    background-color: #f9f9f9;
    width: 100%;
    font-family: inherit;
    color: var(--text-dark);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(61, 47, 123, 0.1);
    background-color: white;
    outline: none;
}

.form-control::placeholder {
    color: var(--text-light);
}

textarea.form-control {
    resize: vertical;
    min-height: 110px;
}

/* ===== BUTTONS ===== */
.btn {
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn-brand {
    background-color: var(--primary);
    color: white;
    border-radius: 10px;
    padding: 10px 30px;
    font-weight: 600;
    border: none;
}

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

.btn-accent {
    background-color: var(--accent);
    color: white;
    border-radius: 10px;
    padding: 10px 30px;
    font-weight: 600;
    border: none;
}

.btn-accent:hover {
    background-color: var(--accent-dark);
    color: white;
}

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

.btn-success:hover {
    background: #059669;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.3);
}

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

.btn-danger:hover {
    background: #dc2626;
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.3);
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

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

.btn-outline-secondary:hover {
    background: var(--bg-light);
    border-color: var(--primary);
    color: var(--primary);
}

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

.btn-outline-warning:hover {
    background: rgba(245, 158, 11, 0.1);
    border-color: var(--warning);
}

.btn-sm {
    padding: 9px 14px;
    font-size: 12px;
}

.btn-sm i {
    font-size: 12px;
}

.px-4 {
    padding-left: 20px !important;
    padding-right: 20px !important;
}

.px-5 {
    padding-left: 28px !important;
    padding-right: 28px !important;
}

/* ===== BADGES ===== */
.badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.bg-success {
    background-color: rgba(16, 185, 129, 0.15) !important;
    color: var(--success) !important;
}

.bg-danger {
    background-color: rgba(239, 68, 68, 0.15) !important;
    color: var(--danger) !important;
}

/* ===== STATS CARDS ===== */
.stat-card {
    border-radius: 16px;
    color: white;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 32px;
}

.stat-card:hover {
    transform: translateY(-6px);
}

.stat-card.card-bg-1 {
    background: linear-gradient(135deg, var(--primary), #5a4b9f);
    box-shadow: 0 8px 24px rgba(61, 47, 123, 0.35);
}

.stat-card.card-bg-2 {
    background: linear-gradient(135deg, var(--accent), #f39c12);
    box-shadow: 0 8px 24px rgba(236, 103, 31, 0.35);
}

.stat-card.card-bg-3 {
    background: linear-gradient(135deg, #2c3e50, #4ca1af);
    box-shadow: 0 8px 24px rgba(44, 62, 80, 0.35);
}

.stat-icon {
    font-size: 36px;
    opacity: 0.25;
    margin-bottom: 16px;
}

.stat-value {
    font-size: 44px;
    font-weight: 800;
    margin-bottom: 10px;
    letter-spacing: -1px;
}

.stat-label {
    font-size: 14px;
    opacity: 0.9;
    font-weight: 500;
}

/* ===== CHARTS ===== */
.chart-wrapper {
    position: relative;
    height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 280px;
    padding: 20px 0;
}

canvas {
    max-height: 320px;
}

/* ===== TABLES ===== */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.table thead {
    background-color: #f8f9fa;
}

.table th {
    background-color: #f8f9fa;
    color: var(--primary);
    font-weight: 700;
    border-bottom: 2px solid #eee;
    padding: 16px;
    border-bottom: 2px solid var(--border);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    color: var(--text-dark);
}

.table tbody tr:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), transparent);
}

.table-responsive {
    overflow-x: auto;
    border-radius: 12px;
}

/* ===== SEARCH BOX ===== */
#searchBox {
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    background: var(--bg-white);
    transition: all 0.3s ease;
    width: auto;
    min-width: 250px;
}

#searchBox:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    outline: none;
}

/* ===== UTILITIES ===== */
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-light); }
.text-center { text-align: center; }
.text-primary { color: var(--primary); }
.text-warning { color: var(--warning); }

.d-flex { display: flex; }
.justify-content-between { justify-content: space-between; }
.justify-content-end { justify-content: flex-end; }
.align-items-center { align-items: center; }

.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 20px; }

.mb-3 { margin-bottom: 20px; }
.mb-4 { margin-bottom: 30px; }
.mt-3 { margin-top: 20px; }
.mt-4 { margin-top: 30px; }
.m-0 { margin: 0; }

.w-100 { width: 100%; }
.w-25 { width: 25%; }
.h-100 { height: 100%; }
.h-auto { height: auto; }

.ms-2 { margin-right: 8px; }
.opacity-25 { opacity: 0.25; }

.border-primary { border-color: var(--primary) !important; }
.border-warning { border-color: var(--warning) !important; }
.border-danger { border-color: var(--danger) !important; }
.border-top { border-top: 1px solid; }
.border-top-4 { border-top: 4px solid; }
.border-4 { border-width: 4px; }

.rounded { border-radius: 12px; }
.small { font-size: 12px; }
.fw-bold { font-weight: 700; }

.p-4 { padding: 20px; }
.px-4 { padding-left: 20px; padding-right: 20px; }
.py-2 { padding-top: 10px; padding-bottom: 10px; }

/* ===== GRID LAYOUT ===== */
.row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 28px;
}

.row.g-3 { gap: 16px; }
.row.g-4 { gap: 28px; }

.col-12 { grid-column: 1 / -1; }
.col-md-4 { grid-column: span 1; }
.col-md-5 { grid-column: span 1; }
.col-md-6 { grid-column: span 1; }
.col-md-7 { grid-column: span 1; }

@media (max-width: 1200px) {
    .row { grid-template-columns: repeat(2, 1fr); }
    .col-md-4, .col-md-5, .col-md-6, .col-md-7 { grid-column: 1 / -1; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        padding: 20px;
        border-left: none;
        border-bottom: 1px solid var(--border);
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 20px;
    }

    .main-content {
        margin-right: 0;
        padding: 20px;
    }

    .logo-area {
        padding: 0;
        border: none;
        margin: 0;
    }

    .nav {
        flex-direction: row;
        margin-bottom: 0;
        gap: 5px;
    }

    .nav-link {
        padding: 8px 12px;
        font-size: 12px;
    }

    .auto-save-box {
        position: static;
        border: none;
        padding: 0;
    }

    .save-badge {
        padding: 8px 10px;
    }

    .row { grid-template-columns: 1fr; }
    .stat-value { font-size: 32px; }
    .header-title h3 { font-size: 24px; }
    .content-card { padding: 20px; }
}

/* ===== ALERTS ===== */
.alert {
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    border-left: 4px solid;
    border: 1px solid;
}

.alert-success {
    background: rgba(16, 185, 129, 0.08);
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.3);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.08);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.3);
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-light);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}

/* ===== PRINT ===== */
@media print {
    .sidebar, .header-title { display: none; }
    .main-content { margin-right: 0; }
}
