/* ================================================================
   QuickData ProSoft — نظام التصميم (Theme)
   هوية احترافية عالمية: فحمي داكن + أحمر قرمزي + محايدات باردة
   ================================================================ */

:root {
    /* —— QuickData ProSoft — هوية احترافية عالمية —— */
    /* أساسي: فحمي داكن للشريط */
    --primary: #0f172a;
    --primary-light: #1e293b;
    --primary-dark: #020617;
    /* لمسة حمراء احترافية */
    --accent: #dc2626;
    --accent-light: #f87171;
    --accent-dark: #b91c1c;
    --accent-tint: rgba(220, 38, 38, 0.08);
    /* حالات */
    --success: #059669;
    --success-bg: #ecfdf5;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --info: #0284c7;
    --info-bg: #f0f9ff;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    /* خلفيات محايدة باردة (ليست بيج سياحي) */
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --text: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --text-inverse: #f8fafc;
    --shadow-sm: 0 1px 2px rgba(15,23,42,0.05), 0 1px 3px rgba(15,23,42,0.06);
    --shadow-md: 0 4px 12px rgba(15,23,42,0.07), 0 2px 4px rgba(15,23,42,0.04);
    --shadow-lg: 0 12px 32px rgba(15,23,42,0.12);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;
    --t-base: 0.2s ease;
    --sidebar-width: 260px;
}

* { font-family: 'Cairo', sans-serif; }
body { background: var(--bg); color: var(--text); font-size: 13.5px; }

/* ===== الشريط الجانبي ===== */
.sidebar {
    width: 260px;
    height: 100vh;
    position: fixed;
    right: 0;
    top: 0;
    background: var(--primary);
    overflow-y: auto;
    z-index: 50;
    transition: transform 0.3s ease;
    border-left: 1px solid rgba(255,255,255,0.05);
}
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 8px; }

.sidebar .logo-area {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar .logo-area h1 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-inverse);
    line-height: 1.25;
    letter-spacing: 0;
}
.sidebar .logo-area span {
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.3px;
    color: rgba(255,255,255,0.32);
    display: block;
    margin-top: 3px;
}

.sidebar nav { padding: 8px 8px !important; }

.nav-section-title {
    font-size: 9px;
    font-weight: 700;
    color: rgba(255,255,255,0.2);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 13px 14px 6px;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin: 1px 4px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.55);
    transition: all 0.2s;
    text-decoration: none;
    font-weight: 500;
    font-size: 12.5px;
    border-right: none;
    position: relative;
}
.sidebar .nav-link i {
    width: 18px;
    height: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    border-radius: 0;
    background: none;
    opacity: 0.75;
    transition: all 0.2s;
}
.sidebar .nav-link:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}
.sidebar .nav-link:hover i { background: none; opacity: 1; }
.sidebar .nav-link.active {
    background: rgba(220, 38, 38, 0.14);
    color: var(--text-inverse);
    font-weight: 600;
    border-right-color: transparent;
}
.sidebar .nav-link.active::before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 16px;
    background: var(--accent);
}
.sidebar .nav-link.active i {
    background: none;
    color: var(--accent-light);
    opacity: 1;
}
.sidebar .nav-link .badge {
    margin-right: auto;
    min-width: 20px;
    text-align: center;
    background: rgba(220, 38, 38, 0.18);
    padding: 1px 8px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
    color: var(--accent-light);
    border: 1px solid rgba(220, 38, 38, 0.15);
    transition: all 0.2s;
}
.sidebar .nav-link.active .badge {
    background: rgba(220, 38, 38, 0.22);
    color: var(--accent-light);
}
.sidebar hr { border-color: rgba(255,255,255,0.06) !important; margin: 10px 16px !important; }

.sidebar .nav-link:focus-visible,
.quick-action:focus-visible,
.menu-toggle-btn:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.sidebar .logout-link { color: rgba(255,255,255,0.35) !important; }
.sidebar .logout-link:hover { background: rgba(173, 63, 57, 0.14) !important; color: #e8a09a !important; }

/* ===== المحتوى الرئيسي ===== */
.main-content {
    margin-right: 260px;
    padding: 22px 30px;
    min-height: 100vh;
    transition: margin-right 0.3s ease;
}

.page-title-main {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}
.brand-mobile {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

/* ===== البطاقات ===== */
.stat-card {
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    border-top: none;
    transition: all 0.25s;
    position: relative;
    overflow: hidden;
}
.stat-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.stat-card .icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
    opacity: 0.85;
}
.stat-card .number {
    font-size: 21px;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
}
.stat-card .label {
    font-size: 11px;
    color: var(--text-tertiary);
    font-weight: 500;
}
.stat-card .trend {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: var(--radius-full);
    background: var(--success-bg);
    color: var(--success);
}

/* ===== الجداول ===== */
.table-card {
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}
.table-card table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}
.table-card th {
    text-align: right;
    padding: 10px 8px;
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 1;
}
.table-card td {
    padding: 11px 8px;
    border-bottom: 1px solid var(--border-light);
    font-size: 12.5px;
    color: var(--text);
    transition: background 0.15s;
}
.table-card tr:last-child td { border-bottom: none; }
.table-card tr:hover td { background: var(--surface-alt); }
.table-card .empty-state, .table-card .loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 28px 0;
    color: var(--text-tertiary);
}
.table-card .empty-state i, .table-card .loading-state i { font-size: 20px; }

.status-badge {
    padding: 3px 12px;
    border-radius: var(--radius-full);
    font-size: 10.5px;
    font-weight: 600;
    white-space: nowrap;
}
.status-active, .status-info { background: var(--info-bg); color: var(--info); }
.status-pending { background: var(--warning-bg); color: var(--warning); }
.status-completed { background: var(--success-bg); color: var(--success); }
.status-cancelled { background: var(--danger-bg); color: var(--danger); }

.quick-action {
    background: var(--surface-alt);
    border-radius: var(--radius-sm);
    padding: 15px 18px;
    border: 1px solid var(--border);
    transition: 0.2s;
    text-decoration: none;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 13px;
}
.quick-action:hover {
    border-color: var(--accent);
    background: var(--accent-tint);
}
.quick-action i {
    font-size: 20px;
    color: var(--accent-dark);
    width: 38px;
    height: 38px;
    background: var(--accent-tint);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

/* ===== أزرار موحّدة (تُستخدم في صفحات القوائم/المودالز) ===== */
.btn-primary-solid {
    background: var(--primary);
    color: var(--text-inverse);
    font-weight: 600;
    font-size: 12.5px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--primary);
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-primary-solid:hover { background: var(--primary-light); border-color: var(--primary-light); box-shadow: var(--shadow-md); }
.btn-outline-soft {
    background: var(--surface);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 12.5px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-outline-soft:hover { border-color: var(--accent); color: var(--accent-dark); background: var(--accent-tint); }
.icon-btn {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    background: var(--surface-alt);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: 0.2s;
    font-size: 12px;
}
.icon-btn:hover { background: var(--info-bg); color: var(--info); border-color: var(--border); }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--border); }

/* ===== نماذج الإدخال (مودالز) ===== */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(14,28,46,0.45);
    display: none; align-items: center; justify-content: center;
    z-index: 100; padding: 16px; backdrop-filter: blur(3px);
}
.modal-backdrop.active { display: flex; }
.modal-box {
    background: var(--surface); border-radius: var(--radius-lg); padding: 26px 28px;
    width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
    animation: modalPop 0.2s ease; box-shadow: var(--shadow-lg);
}
.modal-box h3 { font-size: 15.5px !important; color: var(--text); }
.modal-box h3 i { color: var(--accent) !important; }
.form-field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-field input, .form-field select, .form-field textarea {
    width: 100%; padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    font-size: 13px; font-family: 'Cairo', sans-serif; transition: 0.2s; background: var(--surface); color: var(--text);
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(220,38,38,0.12);
}
@keyframes modalPop {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

/* ===== حالات التحميل (Skeleton) ===== */
.skeleton {
    background: linear-gradient(90deg, var(--border-light) 25%, var(--border) 37%, var(--border-light) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.4s ease infinite;
    border-radius: var(--radius-sm);
}
@keyframes shimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

/* ===== شارة "آخر تحديث" ===== */
.last-updated {
    font-size: 11.5px;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    gap: 6px;
}
.last-updated i { font-size: 10.5px; }

/* ===== Toast تنبيهات ===== */
#toastContainer {
    position: fixed; bottom: 24px; left: 24px; z-index: 200;
    display: flex; flex-direction: column; gap: 10px;
}
.toast-item {
    background: var(--surface); color: var(--text); padding: 11px 16px; border-radius: var(--radius-sm);
    font-size: 12.5px; box-shadow: var(--shadow-lg);
    display: flex; align-items: center; gap: 10px;
    animation: toastIn 0.25s ease;
    min-width: 220px;
    border-right: 3px solid var(--accent);
}
.toast-item.success { border-right-color: var(--success); }
.toast-item.error { border-right-color: var(--danger); }
.toast-item.warning { border-right-color: var(--warning); }
.toast-item.info { border-right-color: var(--info); }
@keyframes toastIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== التوافق مع الشاشات الصغيرة ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
        width: 280px;
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-right: 0; padding: 16px; }
    .menu-toggle { display: flex !important; }
}
.menu-toggle { display: flex; }
.menu-toggle-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--text-secondary);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
    cursor: pointer;
}
.menu-toggle-btn:hover {
    color: var(--accent-dark);
    border-color: var(--accent);
    background: var(--accent-tint);
}

/* ===== تبديل القائمة الجانبية على الشاشات الكبيرة ===== */
@media (min-width: 769px) {
    .sidebar.closed { transform: translateX(100%); }
    .main-content.full { margin-right: 0; }
}

/* ===== خلفية معتمة عند فتح القائمة على الشاشات الصغيرة ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(14,28,46,0.4);
    z-index: 40;
}
@media (max-width: 768px) {
    .sidebar-overlay.show { display: block; }
}
