/* ============================================================
   عزبة طرابزون - نظام التصميم الأساسي
   مستوحى من طبيعة طرابزون: التلال الخضراء، الشاي، البحر الأسود، العمارة الخشبية
   ============================================================ */

:root {
    /* لوحة الألوان - مستوحاة من تلال طرابزون الشاي الخضراء والبحر الأسود والخشب */
    --tea-green: #2F5C44;        /* أخضر الشاي الغامق - اللون الأساسي */
    --tea-green-light: #4A7C5C;  /* أخضر فاتح للتمييز */
    --hazelnut: #A6713A;         /* بني البندق - لون ثانوي/دافئ */
    --hazelnut-light: #C99861;
    --mist: #EDF1ED;             /* خلفية ضباب التلال - خلفية رئيسية فاتحة */
    --sea-dark: #1B2E2A;         /* أخضر مزرق غامق جدًا - للنصوص والهيدر */
    --cream: #FBF8F2;            /* كريمي - خلفية البطاقات */
    --gold-accent: #D4A24E;      /* لون مميز - الإشعارات/التنبيهات */

    --success: #3E8E5A;
    --warning: #D4A24E;
    --danger: #C1502E;
    --info: #4A7C9E;
    --secondary: #8A958E;

    --radius: 10px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 3px rgba(27, 46, 42, 0.08);
    --shadow-md: 0 4px 14px rgba(27, 46, 42, 0.10);
    --shadow-lg: 0 10px 30px rgba(27, 46, 42, 0.14);

    --sidebar-width: 270px;
    --header-height: 64px;

    --font-display: 'Cairo', 'Tajawal', sans-serif;
    --font-body: 'Tajawal', 'Cairo', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--mist);
    color: var(--sea-dark);
    direction: rtl;
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
}

/* ============ نمط الخلفية - أوراق شاي خفيفة (Signature) ============ */
.leaf-pattern-bg {
    background-color: var(--mist);
    background-image:
        radial-gradient(circle at 15% 20%, rgba(74, 124, 92, 0.06) 0%, transparent 35%),
        radial-gradient(circle at 85% 75%, rgba(166, 113, 58, 0.05) 0%, transparent 40%);
}

/* ============ الهيكل العام ============ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--sea-dark) 0%, #15241F 100%);
    color: #E8EFE9;
    flex-shrink: 0;
    position: fixed;
    top: 0; right: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 22px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand .leaf-icon {
    width: 38px; height: 38px;
    background: var(--tea-green-light);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.sidebar-brand h1 {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    line-height: 1.3;
}
.sidebar-brand span {
    font-size: 11px;
    color: var(--hazelnut-light);
    letter-spacing: 0.5px;
}

.sidebar-nav { padding: 14px 12px; }

.sidebar-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255,255,255,0.35);
    padding: 14px 12px 6px;
    font-weight: 700;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.78);
    text-decoration: none;
    font-size: 14.5px;
    font-weight: 500;
    margin-bottom: 2px;
    transition: background 0.15s, color 0.15s;
    position: relative;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}

.sidebar-nav a.active {
    background: var(--tea-green-light);
    color: #fff;
    font-weight: 700;
}

.sidebar-nav a .badge-count {
    margin-right: auto;
    background: var(--gold-accent);
    color: var(--sea-dark);
    font-size: 11px;
    font-weight: 800;
    padding: 1px 7px;
    border-radius: 20px;
    min-width: 20px;
    text-align: center;
}

.sidebar-nav a i { width: 20px; text-align: center; font-size: 16px; flex-shrink: 0; }

/* ============ المحتوى الرئيسي ============ */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--header-height);
    background: var(--cream);
    border-bottom: 1px solid rgba(27,46,42,0.07);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h2 {
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 800;
    color: var(--sea-dark);
}

.topbar-actions { display: flex; align-items: center; gap: 16px; }

.topbar-icon-btn {
    width: 38px; height: 38px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--mist);
    color: var(--tea-green);
    border: none;
    cursor: pointer;
    position: relative;
    text-decoration: none;
    font-size: 16px;
    transition: background 0.15s;
}
.topbar-icon-btn:hover { background: rgba(47,92,68,0.12); }

.notif-dot {
    position: absolute;
    top: 4px; right: 4px;
    width: 9px; height: 9px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--cream);
}

.user-chip {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 14px 6px 8px;
    background: var(--mist);
    border-radius: 30px;
    text-decoration: none;
    color: var(--sea-dark);
    font-weight: 600;
    font-size: 13.5px;
}
.user-chip .avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--hazelnut);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 800;
}

.page-body { padding: 24px; flex: 1; }

/* ============ البطاقات ============ */
.card {
    background: var(--cream);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(27,46,42,0.05);
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(27,46,42,0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h3 {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 800;
}
.card-body { padding: 20px; }

/* ============ شبكة الإحصائيات ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--cream);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(27,46,42,0.05);
    border-right: 4px solid var(--tea-green-light);
    position: relative;
    overflow: hidden;
}
.stat-card.gold { border-right-color: var(--gold-accent); }
.stat-card.brown { border-right-color: var(--hazelnut); }
.stat-card.red { border-right-color: var(--danger); }
.stat-card.blue { border-right-color: var(--info); }

.stat-card .stat-label {
    font-size: 13px;
    color: var(--secondary);
    font-weight: 600;
    margin-bottom: 6px;
}
.stat-card .stat-value {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 800;
    color: var(--sea-dark);
}
.stat-card .stat-sub {
    font-size: 12px;
    color: var(--tea-green-light);
    margin-top: 4px;
    font-weight: 600;
}
.stat-card .stat-icon {
    position: absolute;
    left: 16px; top: 16px;
    font-size: 26px;
    opacity: 0.18;
}

/* ============ الجداول ============ */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data-table th {
    text-align: right;
    padding: 12px 14px;
    background: rgba(47,92,68,0.06);
    color: var(--sea-dark);
    font-weight: 700;
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
}
table.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(27,46,42,0.05);
    vertical-align: middle;
}
table.data-table tbody tr:hover { background: rgba(47,92,68,0.03); }
table.data-table tbody tr:last-child td { border-bottom: none; }

/* ============ البادجات ============ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 11px;
    border-radius: 30px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}
.badge-success { background: rgba(62,142,90,0.13); color: var(--success); }
.badge-warning { background: rgba(212,162,78,0.18); color: #95701F; }
.badge-danger { background: rgba(193,80,46,0.13); color: var(--danger); }
.badge-info { background: rgba(74,124,158,0.13); color: var(--info); }
.badge-secondary { background: rgba(138,149,142,0.15); color: #5C6660; }
.badge-primary { background: rgba(47,92,68,0.13); color: var(--tea-green); }

/* ============ الأزرار ============ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.08s ease, box-shadow 0.15s, background 0.15s;
    font-family: var(--font-body);
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--tea-green); color: #fff; }
.btn-primary:hover { background: #264A37; }
.btn-secondary { background: var(--mist); color: var(--sea-dark); }
.btn-secondary:hover { background: #DFE6E0; }
.btn-gold { background: var(--gold-accent); color: var(--sea-dark); }
.btn-gold:hover { background: #C5933E; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #A8431F; }
.btn-outline { background: transparent; border: 1.5px solid rgba(27,46,42,0.15); color: var(--sea-dark); }
.btn-outline:hover { background: rgba(27,46,42,0.04); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 6px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; justify-content: center; }
.btn-block { width: 100%; justify-content: center; }

/* ============ النماذج ============ */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
    font-size: 13.5px;
    color: var(--sea-dark);
}
.form-group .hint { font-size: 12px; color: var(--secondary); margin-top: 4px; }
.form-control, select.form-control, textarea.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid rgba(27,46,42,0.12);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font-body);
    background: #fff;
    color: var(--sea-dark);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus, select.form-control:focus, textarea.form-control:focus {
    outline: none;
    border-color: var(--tea-green-light);
    box-shadow: 0 0 0 3px rgba(74,124,92,0.13);
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.input-group { display: flex; }
.input-group .form-control { border-radius: 0; }
.input-group .form-control:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .form-control:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-group-text {
    display: flex; align-items: center;
    padding: 0 12px;
    background: var(--mist);
    border: 1.5px solid rgba(27,46,42,0.12);
    font-size: 13px;
    font-weight: 700;
    color: var(--secondary);
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

/* ============ التنبيهات/الرسائل ============ */
.alert {
    padding: 13px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-success { background: rgba(62,142,90,0.12); color: var(--success); border: 1px solid rgba(62,142,90,0.25); }
.alert-danger { background: rgba(193,80,46,0.1); color: var(--danger); border: 1px solid rgba(193,80,46,0.22); }
.alert-warning { background: rgba(212,162,78,0.15); color: #8C6A20; border: 1px solid rgba(212,162,78,0.3); }
.alert-info { background: rgba(74,124,158,0.1); color: var(--info); border: 1px solid rgba(74,124,158,0.22); }

/* ============ تبويبات ============ */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid rgba(27,46,42,0.07); margin-bottom: 20px; flex-wrap: wrap; }
.tabs a {
    padding: 10px 18px;
    text-decoration: none;
    color: var(--secondary);
    font-weight: 700;
    font-size: 14px;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}
.tabs a.active { color: var(--tea-green); border-color: var(--tea-green); }

/* ============ مودال ============ */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(27,46,42,0.45);
    z-index: 1000;
    align-items: center; justify-content: center;
    padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal-box {
    background: var(--cream);
    border-radius: var(--radius);
    max-width: 600px; width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    padding: 18px 22px;
    border-bottom: 1px solid rgba(27,46,42,0.07);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-family: var(--font-display); font-size: 17px; font-weight: 800; }
.modal-body { padding: 22px; }
.modal-footer { padding: 16px 22px; border-top: 1px solid rgba(27,46,42,0.07); display: flex; gap: 10px; justify-content: flex-end; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--secondary); line-height: 1; }

/* ============ صفحة تسجيل الدخول ============ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--sea-dark) 0%, var(--tea-green) 100%);
    position: relative;
    overflow: hidden;
}
.login-page::before, .login-page::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.04);
}
.login-page::before { width: 400px; height: 400px; top: -150px; right: -100px; }
.login-page::after { width: 300px; height: 300px; bottom: -100px; left: -80px; background: rgba(212,162,78,0.08); }

.login-card {
    background: var(--cream);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
}
.login-card .logo-circle {
    width: 64px; height: 64px;
    background: var(--tea-green);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 30px;
    margin: 0 auto 16px;
    color: #fff;
}
.login-card h1 { text-align: center; font-family: var(--font-display); font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.login-card p.subtitle { text-align: center; color: var(--secondary); font-size: 13px; margin-bottom: 28px; }

/* ============ صفحة الفاتورة العامة ============ */
.invoice-page { background: #fff; max-width: 800px; margin: 0 auto; padding: 30px; }
.invoice-header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid var(--tea-green); padding-bottom: 20px; margin-bottom: 20px; }
.invoice-header h1 { font-family: var(--font-display); color: var(--tea-green); font-size: 26px; font-weight: 800; }
.invoice-meta { text-align: left; font-size: 13px; }
.invoice-section-title { font-weight: 800; color: var(--tea-green); margin: 20px 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.5px; }
.invoice-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.invoice-table th, .invoice-table td { padding: 10px 12px; border: 1px solid #e0e0e0; font-size: 13.5px; }
.invoice-table th { background: var(--mist); font-weight: 700; }
.invoice-totals { width: 320px; margin-right: auto; margin-left: 0; }
.invoice-totals div { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.invoice-totals .grand-total { border-top: 2px solid var(--tea-green); font-weight: 800; font-size: 18px; color: var(--tea-green); padding-top: 10px; margin-top: 6px; }
.invoice-footer { text-align: center; margin-top: 30px; padding-top: 16px; border-top: 1px solid #eee; font-size: 12px; color: var(--secondary); }

@media print {
    .no-print { display: none !important; }
    body { background: #fff; }
    .invoice-page { padding: 0; }
}

/* ============ عناصر مساعدة ============ */
.text-muted { color: var(--secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-bold { font-weight: 800; }
.mb-0 { margin-bottom: 0; }
.d-flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--secondary); }
.empty-state .icon { font-size: 48px; opacity: 0.3; margin-bottom: 12px; }

.pagination { display: flex; gap: 6px; margin-top: 16px; justify-content: center; flex-wrap: wrap; }
.pagination a, .pagination span {
    padding: 8px 13px;
    border-radius: 6px;
    background: var(--cream);
    border: 1px solid rgba(27,46,42,0.1);
    text-decoration: none;
    color: var(--sea-dark);
    font-size: 13px;
    font-weight: 700;
}
.pagination a:hover { background: var(--mist); }
.pagination .active { background: var(--tea-green); color: #fff; border-color: var(--tea-green); }

/* ============ موبايل ============ */
.mobile-toggle {
    display: none;
    background: none; border: none; font-size: 22px; color: var(--sea-dark); cursor: pointer;
}

@media (max-width: 992px) {
    .sidebar { transform: translateX(100%); }
    .sidebar.show { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .main-content { margin-right: 0; }
    .mobile-toggle { display: block; }
    .page-body { padding: 14px; }
    .invoice-totals { width: 100%; }
}

@media (max-width: 600px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stat-card .stat-value { font-size: 22px; }
    table.data-table { font-size: 12.5px; }
}

/* ============ Tooltip للملاحظات ============ */
.note-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: rgba(212,162,78,0.18);
    color: var(--gold-accent);
    font-size: 11px;
    cursor: help;
    flex-shrink: 0;
}
.note-tooltip .tooltip-content {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: 130%;
    right: 50%;
    transform: translateX(50%);
    background: var(--sea-dark);
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    white-space: normal;
    width: 220px;
    line-height: 1.6;
    z-index: 50;
    box-shadow: var(--shadow-lg);
    transition: opacity 0.15s ease, visibility 0.15s ease;
    text-align: right;
}
.note-tooltip .tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 50%;
    transform: translateX(50%);
    border-width: 6px;
    border-style: solid;
    border-color: var(--sea-dark) transparent transparent transparent;
}
.note-tooltip:hover .tooltip-content {
    visibility: visible;
    opacity: 1;
}

/* ============ بطاقات أولوية الاستلام/التسليم ============ */
.priority-list { display: flex; flex-direction: column; gap: 8px; padding: 14px; }
.priority-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--cream);
    border: 1px solid rgba(27,46,42,0.06);
    text-decoration: none;
    color: var(--sea-dark);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.priority-item:hover { box-shadow: var(--shadow-sm); transform: translateX(-2px); }
.priority-item.urgent { border-right: 4px solid var(--danger); background: rgba(193,80,46,0.05); }
.priority-item.soon { border-right: 4px solid var(--gold-accent); background: rgba(212,162,78,0.06); }
.priority-item.upcoming { border-right: 4px solid var(--info); }

.priority-rank {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: rgba(27,46,42,0.06);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 800; flex-shrink: 0;
    color: var(--sea-dark);
}
.priority-item.urgent .priority-rank { background: var(--danger); color: #fff; }
.priority-item.soon .priority-rank { background: var(--gold-accent); color: var(--sea-dark); }

.priority-main { flex: 1; min-width: 0; }
.priority-main .ptitle { font-weight: 800; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.priority-main .psub { font-size: 11.5px; color: var(--secondary); margin-top: 2px; }
.priority-time {
    text-align: left;
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}
.priority-time .time-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 10.5px;
    font-weight: 800;
    margin-bottom: 2px;
}
.time-badge.danger { background: rgba(193,80,46,0.13); color: var(--danger); }
.time-badge.warning { background: rgba(212,162,78,0.18); color: #95701F; }
.time-badge.info { background: rgba(74,124,158,0.13); color: var(--info); }
