/* ==========================================================================
   تطبيق «تَصَدَّق» - تنسيقات لوحة تحكم الإدارة والرقابة الميدانية (Admin Styles)
   ألوان مؤسسية رصينة، لوحة تحكم متكاملة، ونظام دخول مؤمن
   ========================================================================== */

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

:root {
    --admin-navy: #0f172a;
    --admin-dark: #1e293b;
    --admin-surface: #334155;
    --admin-accent: #15803d;
    --admin-accent-glow: rgba(21, 128, 61, 0.2);
    --admin-gold: #d97706;
    
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --border-subtle: #f1f5f9;

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

    --priority-urgent: #dc2626;
    --priority-urgent-bg: #fef2f2;
    --priority-urgent-border: #fecaca;

    --priority-high: #ea580c;
    --priority-high-bg: #fff7ed;
    --priority-high-border: #fed7aa;

    --priority-medium: #d97706;
    --priority-medium-bg: #fffbeb;
    --priority-medium-border: #fde68a;

    --priority-normal: #16a34a;
    --priority-normal-bg: #f0fdf4;
    --priority-normal-border: #bbf7d0;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    --shadow-card: 0 4px 20px -2px rgba(15, 23, 42, 0.06);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
}

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

html {
    direction: rtl;
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Tajawal', system-ui, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Cairo', system-ui, sans-serif;
    font-weight: 700;
    color: var(--text-main);
}

.container {
    width: 100%;
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ==========================================================================
   شاشة تسجيل الدخول المؤمنة (Admin Login Screen)
   ========================================================================== */

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top right, #1e293b, #0f172a);
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.login-card {
    background: #ffffff;
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 440px;
    padding: 2.75rem 2.25rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    position: relative;
    z-index: 10;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-icon-box {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--admin-accent), #0f5132);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    color: #fff;
    box-shadow: 0 10px 20px var(--admin-accent-glow);
}

.login-header h2 {
    font-size: 1.6rem;
    margin-bottom: 0.35rem;
    color: var(--admin-navy);
}

.login-header p {
    font-size: 0.88rem;
    color: var(--text-muted);
}

.login-alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
    display: none;
}

.login-alert.error {
    display: block;
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
}

/* شريط التنقل الإداري العلوي */
.admin-navbar {
    background: var(--admin-navy);
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.admin-nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 72px;
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.admin-brand h1 {
    color: #fff;
    font-size: 1.35rem;
    line-height: 1.1;
}

.admin-brand span {
    font-size: 0.75rem;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.15rem 0.6rem;
    border-radius: var(--radius-full);
}

.admin-user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.admin-badge-role {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.85rem;
    background: rgba(21, 128, 61, 0.2);
    border: 1px solid rgba(21, 128, 61, 0.4);
    border-radius: var(--radius-full);
    color: #4ade80;
    font-size: 0.82rem;
    font-weight: 700;
}

/* أزرار العمليات */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.4rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    border: none;
    transition: 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--admin-accent), #0f5132);
    color: #fff;
    box-shadow: 0 4px 12px var(--admin-accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(21, 128, 61, 0.3);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: #f1f5f9;
}

.btn-gold {
    background: linear-gradient(135deg, var(--admin-gold), #b45309);
    color: #fff;
}

.btn-danger {
    background: var(--priority-urgent);
    color: #fff;
}

.btn-sm {
    padding: 0.45rem 0.85rem;
    font-size: 0.85rem;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    position: relative;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.notif-badge {
    position: absolute;
    top: -4px;
    left: -4px;
    background: var(--priority-urgent);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--admin-navy);
}

/* القائمة المنسدلة للإشعارات */
.notif-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    width: 360px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    display: none;
    z-index: 1050;
    overflow: hidden;
}

.notif-dropdown.show {
    display: block;
}

.notif-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
}

.notif-list {
    max-height: 320px;
    overflow-y: auto;
    list-style: none;
}

.notif-item {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    gap: 0.75rem;
}

.notif-item.unread {
    background: #f0fdf4;
}

/* عناصر الإدارة */
.admin-header-bar {
    background: linear-gradient(135deg, var(--admin-navy) 0%, #1e293b 100%);
    border-radius: var(--radius-xl);
    color: #fff;
    padding: 2.25rem 2.5rem;
    margin: 2.5rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.15);
}

.admin-title-box h2 {
    color: #fff;
    font-size: 1.85rem;
    margin-bottom: 0.35rem;
}

.admin-title-box p {
    color: #94a3b8;
    font-size: 0.95rem;
}

/* شبكة المؤشرات الـ KPIs */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 2.5rem;
}

@media (max-width: 1200px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 580px) {
    .kpi-grid { grid-template-columns: 1fr; }
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.kpi-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.kpi-title {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
}

.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.kpi-icon.green { background: linear-gradient(135deg, #10b981, #059669); }
.kpi-icon.blue { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.kpi-icon.amber { background: linear-gradient(135deg, #f59e0b, #d97706); }
.kpi-icon.purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.kpi-icon.red { background: linear-gradient(135deg, #ef4444, #dc2626); }
.kpi-icon.teal { background: linear-gradient(135deg, #14b8a6, #0d9488); }

.kpi-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-main);
    font-family: 'Cairo', sans-serif;
    line-height: 1.1;
    margin-bottom: 0.35rem;
}

.kpi-subtext {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* الرسوم البيانية */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1.6fr;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

@media (max-width: 992px) {
    .charts-grid { grid-template-columns: 1fr; }
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.chart-canvas-wrap {
    position: relative;
    flex-grow: 1;
    min-height: 280px;
    width: 100%;
}

/* التبويبات */
.admin-tabs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 2rem;
    overflow-x: auto;
}

.admin-tab-btn {
    padding: 0.85rem 1.5rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    background: none;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: 0.2s ease;
}

.admin-tab-btn:hover, .admin-tab-btn.active {
    color: var(--admin-accent);
}

.admin-tab-btn.active {
    border-bottom: 2px solid var(--admin-accent);
}

.tab-badge-count {
    background: #f1f5f9;
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
}

.admin-tab-btn.active .tab-badge-count {
    background: #dcfce7;
    color: #15803d;
}

/* الجداول */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    margin-bottom: 2.5rem;
}

.table-toolbar {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    background: #fafaf9;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
    font-size: 0.92rem;
}

.custom-table th {
    background: #f1f5f9;
    color: var(--text-muted);
    font-weight: 700;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.custom-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-main);
    vertical-align: middle;
}

.custom-table tr:hover td {
    background-color: #f8fafc;
}

/* الشارات */
.priority-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.8rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 700;
}

.priority-pill.urgent { background: var(--priority-urgent-bg); color: var(--priority-urgent); border: 1px solid var(--priority-urgent-border); }
.priority-pill.high { background: var(--priority-high-bg); color: var(--priority-high); border: 1px solid var(--priority-high-border); }
.priority-pill.medium { background: var(--priority-medium-bg); color: var(--priority-medium); border: 1px solid var(--priority-medium-border); }
.priority-pill.normal { background: var(--priority-normal-bg); color: var(--priority-normal); border: 1px solid var(--priority-normal-border); }

.priority-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.priority-pill.urgent .priority-dot {
    animation: pulseGlow 1.6s infinite ease-in-out;
}

@keyframes pulseGlow {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.3; transform: scale(1.3); }
}

.table-status-pill {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 700;
}

.table-status-pill.received { background: #fef3c7; color: #b45309; }
.table-status-pill.assigned { background: #e0f2fe; color: #0369a1; }
.table-status-pill.delivering { background: #ede9fe; color: #6d28d9; }
.table-status-pill.delivered { background: #dcfce7; color: #15803d; }

.cat-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-full);
    background: #f1f5f9;
    color: var(--text-muted);
}

/* النماذج */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.92rem;
    font-weight: 700;
    margin-bottom: 0.45rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: #f8fafc;
    font-family: inherit;
    font-size: 0.95rem;
    transition: 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--admin-accent);
    background: #fff;
    box-shadow: 0 0 0 3px var(--admin-accent-glow);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 600px) {
    .form-row { grid-template-columns: 1fr; }
}

.select-custom {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: #f8fafc;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

/* النوافذ المنبثقة */
.modal-backdrop {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 0;
    visibility: hidden;
    transition: 0.25s ease;
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal-dialog {
    background: #fff;
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    position: sticky;
    top: 0;
    z-index: 10;
}

.modal-title {
    font-size: 1.35rem;
    font-weight: 800;
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    background: #fff;
    cursor: pointer;
}

.modal-body {
    padding: 2rem;
}

.modal-footer {
    padding: 1.25rem 2rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background: #f8fafc;
    position: sticky;
    bottom: 0;
}

/* رسائل التوست */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    background: #0f172a;
    color: #fff;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.92rem;
    font-weight: 600;
    min-width: 280px;
    border-right: 4px solid var(--admin-accent);
}

.toast.urgent { border-right-color: var(--priority-urgent); }

@media print {
    .admin-navbar, .btn, .admin-tabs, .modal-backdrop, .toast-container {
        display: none !important;
    }
    body { background: #fff !important; }
}
