/**
 * نظام التصميم الحديث - التركواز
 * Modern Design System - Turquoise Theme
 */

/* المتغيرات الأساسية */
:root {
    --primary: #1AAB9B;
    --primary-dark: #159588;
    --primary-light: #E6F7F5;
    
    --secondary: #F59E0B;
    --blue: #3B82F6;
    --purple: #8B5CF6;
    --orange: #F97316;
    
    --bg: #F7F9FA;
    --sidebar-bg: #FFFFFF;
    --card-bg: #FFFFFF;
    
    --text: #1F2937;
    --text-light: #6B7280;
    --text-muted: #9CA3AF;
    
    --border: #E5E7EB;
    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
}

/* إعادة تعيين الأساسيات */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    line-height: 1.6;
}

/* الهيدر العلوي العام */
.app-header {
    width: 100%;
    padding: 12px 0;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    box-shadow: 0 4px 12px rgba(15, 118, 110, 0.35);
}

.app-header-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #F9FAFB;
}

.app-title-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.app-title {
    font-size: 22px;
    font-weight: 800;
    color: #FFFFFF;
}

.app-subtitle {
    font-size: 13px;
    color: #E5E7EB;
}

.app-header-right .app-logo {
    width: 48px;
    height: 48px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #FFFFFF;
    font-size: 13px;
}

/* تخطيط الصفحة */
.page-wrapper {
    display: flex;
    max-width: 1120px;
    margin: 32px auto 40px;
    padding: 0 12px;
    gap: 20px;
    align-items: flex-start;
}

/* Compatibility for School subfolder pages which use `.container` and `.main` */
.container.school-with-global-header {
    display: flex;
    /* use the same centered max-width as the main layout */
    max-width: 1120px;
    width: 100%;
    margin: 32px auto 40px;
    padding: 0 12px;
    gap: 20px;
    align-items: flex-start;
    /* keep flex ordering left-to-right so sidebar appears like the main site
       but preserve RTL text inside the children */
    direction: ltr;
}

.container.school-with-global-header > .sidebar,
.container.school-with-global-header > .main {
    direction: rtl;
}

/* Also provide a safe rule for generic .container fallback, but less aggressive */
.container {
    box-sizing: border-box;
}

.main-content, .main {
    flex: 1;
    overflow-y: auto;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 20px 24px;
}

/* القائمة الجانبية */
.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 40px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.brand {
    padding: 16px 20px;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}


.brand i {
    font-size: 28px;
}

.sidebar nav {
    flex: 1;
    padding: 8px 0 12px;
    overflow-y: auto;
}

.nav-btn {
    width: 100%;
    padding: 8px 18px;
    background: none;
    border: none;
    border-right: 3px solid transparent;
    text-align: right;
    font-size: 13px;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: inherit;
}

.nav-btn span {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-btn i {
    width: 20px;
    font-size: 18px;
}

.nav-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.nav-btn.active {
    background: var(--primary-light);
    border-right-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

.badge {
    background: var(--danger);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

/* المحتوى الرئيسي */
.main-content {
    flex: 1;
    overflow-y: auto;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

/* رأس الصفحة */
.header {
    background: white;
    padding: 18px 28px;
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* الأزرار الملونة */
.btn-icon {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    font-family: inherit;
}

.btn-icon i {
    font-size: 16px;
}

.btn-icon:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-suggestions {
    background: var(--purple);
}

.btn-suggestions:hover {
    background: #7C3AED;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.btn-subscriptions {
    background: var(--orange);
}

.btn-subscriptions:hover {
    background: #EA580C;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
}

.btn-contact {
    background: var(--blue);
}

.btn-contact:hover {
    background: #2563EB;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-help {
    background: var(--primary);
}

.btn-help:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(26, 171, 155, 0.4);
}

.btn-logout {
    background: var(--danger);
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.btn-logout:hover {
    background: #DC2626;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

/* تنسيق زر تسجيل الخروج داخل القائمة الجانبية */
.sidebar .btn-logout {
    padding: 6px 10px;
    font-size: 12px;
    box-shadow: none;
    transform: none;
}

.sidebar .btn-logout i {
    font-size: 12px;
}

/* منطقة المحتوى */
.content {
    padding: 24px 24px 28px;
}

/* شبكة الإحصائيات */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-card h4 {
    font-size: 14px;
    color: var(--text-light);
    font-weight: 500;
    margin-bottom: 12px;
}

.stat-card .number {
    font-size: 36px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-card .number i {
    font-size: 32px;
    color: var(--primary);
}

/* Report controls (date range + print) */
.report-controls input[type="date"] {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: #fff;
    font-family: inherit;
}

/* Print helpers */
@media print {
    body { background: #fff !important; }
    .sidebar, header, .btn-icon, .icon-btn, .no-print, .header-actions, .brand { display: none !important; }
    main, .main-content, .container, .page-wrapper { box-shadow: none !important; background: #fff !important; }
    .card { border: none !important; box-shadow: none !important; }
}

/* Print header and table formatting for tickets report */
.print-header { display: none; }

@media print {
    .print-header { display: block; width: 100%; margin-bottom: 12px; }
    .print-header .title { font-size: 20px; font-weight: 800; color: var(--text); margin-bottom: 4px; }
    .print-header .meta { font-size: 13px; color: var(--text-muted); display:flex; justify-content:space-between; gap:12px; }

    .ticket-table-full table { width: 100%; border-collapse: collapse; font-size: 12px; }
    .ticket-table-full thead { display: table-header-group; }
    .ticket-table-full th, .ticket-table-full td { border: 1px solid rgba(0,0,0,0.08); padding: 8px 10px; text-align: right; }
    .ticket-table-full th { background: #f3f4f6; font-weight:800; }
    .ticket-table-full tbody tr { page-break-inside: avoid; }
    .ticket-table-full td { color: #111827; }

    /* Ensure compact spacing on print */
    .card { padding: 10px !important; border-radius: 0 !important; }
    .tickets-full-top { display: none !important; }
}

/* Landscape @page for printing and improved table look */
@page {
    size: A4 landscape;
    margin: 12mm;
}

/* Apply landscape layout and refined table styling when printing */
@media print {
    body { -webkit-print-color-adjust: exact; }
    .ticket-table-full table { font-size: 11px; border-collapse: collapse; width: 100%; }
    .ticket-table-full thead th { background: #f8fafc !important; color: #111827; font-weight: 800; padding: 10px 12px; }
    .ticket-table-full tbody td { padding: 10px 12px; vertical-align: top; border: 1px solid rgba(0,0,0,0.06); }
    .ticket-table-full tbody tr:nth-child(even) { background: rgba(15,23,42,0.02); }
    .ticket-table-full td.notes { max-width: 420px; white-space: pre-wrap; word-wrap: break-word; }
    .ticket-table-full td { word-break: break-word; }
    .print-header .title { font-size: 22px; }
    .print-header .school { font-size: 16px; font-weight: 800; margin-bottom:6px; color: var(--primary); }

    /* Page breaks: avoid splitting rows and keep header on each page */
    .ticket-table-full tbody tr { page-break-inside: avoid; }
    .ticket-table-full thead { display: table-header-group; }
}

/* Buttons used across the app */
.btn-primary {
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    padding: 8px 12px;
    border-radius: 10px;
    display: inline-flex;
    gap: 8px;
    align-items: center;
    cursor: pointer;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.btn-secondary {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 10px;
    display: inline-flex;
    gap: 8px;
    align-items: center;
    cursor: pointer;
    text-decoration: none;
}
.btn-secondary:hover { box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06); }

.icon-btn {
    background: transparent;
    border: 1px solid transparent;
    padding: 6px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.icon-btn:hover { background: rgba(0,0,0,0.03); }
.icon-btn-danger { color: var(--danger); }

.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 13px;
    color: #fff;
}
.status-resolved { background: var(--success); }
.status-not_resolved { background: var(--danger); }
.status-in_progress { background: var(--warning); color:#111; }

/* Tighter table for compact view */
.ticket-table-compact table { width: 100%; border-collapse: collapse; }
.ticket-table-compact th, .ticket-table-compact td { padding: 12px 10px; text-align: right; border-bottom: 1px solid var(--border); }
.ticket-subject-main { font-weight: 700; color: var(--text); }
.ticket-subject-meta { font-size: 13px; color: var(--text-muted); margin-top:6px; display:flex; gap:10px; align-items:center; }

@media (max-width: 800px) {
    .sidebar { display: none; }
    .page-wrapper { padding: 12px; }
}

/* Clickable cards and ticket card styles */
.clickable { cursor: pointer; }
.clickable:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.selected { outline: 3px solid rgba(26,171,155,0.12); }

.dept-card { transition: transform 0.18s ease, box-shadow 0.18s ease; }

.cards-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin: 18px 0; }
.ticket-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap:10px; }
.ticket-card .ticket-header { display:flex; justify-content:space-between; align-items:center; gap:8px; }
.ticket-card .ticket-number { font-weight:800; color:var(--primary); }
.ticket-card .ticket-subject { font-weight:700; color:var(--text); }
.ticket-card .ticket-meta { color:var(--text-muted); font-size:13px; display:flex; gap:8px; align-items:center; }
.ticket-card .ticket-notes { font-size:14px; color:var(--text-light); white-space:pre-wrap; }
.ticket-card .ticket-actions { display:flex; gap:8px; justify-content:flex-end; }
.ticket-card.hidden { display: none !important; }

/* Improved visual style for cards */
.stat-card {
    padding: 20px;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(246,249,249,0.95));
    border: 1px solid rgba(15,23,42,0.04);
    box-shadow: 0 8px 24px rgba(15,23,42,0.06);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.stat-card:hover { transform: translateY(-6px); box-shadow: 0 18px 40px rgba(15,23,42,0.08); }
.stat-card h4 { font-size: 15px; color: var(--text-light); margin-bottom: 6px; }
.stat-card .number { font-size: 34px; display:flex; align-items:center; gap:10px; }
.stat-card .number i { font-size:28px; }
.stat-card .subtitle { color:var(--text-muted); }

/* Department card refinement */
.dept-card { padding: 18px; border-radius: 12px; transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease; }
.dept-card:hover { transform: translateY(-6px); box-shadow: 0 12px 30px rgba(15,23,42,0.06); border-color: rgba(26,171,155,0.12); }
.dept-card > div:first-child { padding-bottom: 8px; }
.dept-card .dept-name { font-weight: 800; color: var(--text); }

/* New department card design */
.dept-card {
    background: linear-gradient(180deg, #ffffff, #fbfcfd);
    border: 1px solid var(--border);
    padding: 18px 20px;
    border-radius: 14px;
    box-shadow: 0 8px 20px rgba(15,23,42,0.04);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.dept-card:hover { transform: translateY(-6px); box-shadow: 0 18px 40px rgba(15,23,42,0.06); }
.dept-card .dept-top { display:flex; justify-content:space-between; align-items:center; gap:10px; }
.dept-card .dept-name { font-size:16px; font-weight:800; color:var(--text); }
.dept-card .dept-total { font-size:28px; font-weight:900; color:var(--text); }
.dept-card .dept-sub { font-size:13px; color:var(--text-muted); }
.dept-counts { display:flex; gap:8px; margin-top:6px; }
.count-pill { flex:1; display:flex; flex-direction:column; align-items:center; padding:10px 8px; border-radius:10px; background:rgba(0,0,0,0.02); }
.count-pill .count-num { font-weight:800; font-size:16px; color:var(--text); }
.count-pill .count-label { font-size:12px; color:var(--text-muted); margin-top:4px; }
.count-open { background: rgba(239,68,68,0.06); border: 1px solid rgba(239,68,68,0.08); }
.count-open .count-num { color: var(--danger); }
.count-resolved { background: rgba(16,185,129,0.06); border: 1px solid rgba(16,185,129,0.08); }
.count-resolved .count-num { color: var(--success); }
.count-inprogress { background: rgba(245,158,11,0.06); border: 1px solid rgba(245,158,11,0.08); }
.count-inprogress .count-num { color: var(--warning); }

/* Progress bar and enhanced visuals for department cards */
.dept-progress { display:flex; flex-direction:column; gap:8px; }
.progress-line { width:100%; height:10px; background: rgba(15,23,42,0.04); border-radius: 999px; overflow: hidden; border: 1px solid rgba(15,23,42,0.02); }
.progress-fill { height:100%; background: linear-gradient(90deg, rgba(16,185,129,0.9), rgba(26,171,155,0.9)); box-shadow: inset 0 -4px 8px rgba(0,0,0,0.06); transition: width 0.5s ease; }
.progress-meta { display:flex; justify-content:space-between; font-size:13px; color:var(--text-muted); }
.progress-meta .resolved-text { color:var(--success); font-weight:700; }
.progress-meta .open-text { color:var(--danger); font-weight:700; }

.dept-total { font-size:36px; font-weight:900; color:var(--text); }

/* Slightly larger pills on wider screens */
@media (min-width: 900px) {
    .count-pill { padding:12px 10px; }
    .dept-card .dept-name { font-size:18px; }
}

/* Ticket card with colored status accent */
.ticket-card { position: relative; overflow: hidden; }
.ticket-card::before { content: ''; position: absolute; top: 0; right: 0; width: 6px; height: 100%; background: var(--primary); opacity: 0.08; }
.ticket-card[data-status="resolved"]::before { background: linear-gradient(180deg, rgba(16,185,129,0.9), rgba(16,185,129,0.6)); opacity: 0.14; }
.ticket-card[data-status="not_resolved"]::before { background: linear-gradient(180deg, rgba(239,68,68,0.9), rgba(239,68,68,0.6)); opacity: 0.14; }
.ticket-card[data-status="in_progress"]::before { background: linear-gradient(180deg, rgba(245,158,11,0.9), rgba(245,158,11,0.6)); opacity: 0.12; }
.ticket-card .status-badge { margin-left: 8px; }
.ticket-card .ticket-header { align-items: flex-start; }
.ticket-card .ticket-number { font-size: 13px; color:var(--text-muted); font-weight:700; }
.ticket-card .ticket-subject { font-size: 16px; margin-top:6px; }
.ticket-card .ticket-meta { margin-top:6px; }
.ticket-card .ticket-actions { margin-top:6px; }

/* Make selected state more visible */
.selected { box-shadow: 0 20px 40px rgba(15,23,42,0.09) !important; transform: translateY(-6px) !important; }

/* Dashboard-specific helpers (for School pages) */
.section-title {
    font-size: 18px;
    color: var(--text);
    margin: 24px 0 12px;
    font-weight: 700;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 12px 0;
}

.charts-grid { align-items: start; }

@media (max-width: 1100px) {
    .charts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 700px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

.chart-card, .insight-card {
    background: var(--card-bg);
    padding: 18px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.insight-card::before { display: none; }

.muted { color: var(--text-muted); font-size: 13px; }

.progress-bar { height: 10px; background: #F1F5F9; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-dark)); display: block; }

.data-table { width: 100%; border-collapse: collapse; background: var(--card-bg); border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.data-table thead { background: linear-gradient(90deg, rgba(0,0,0,0.02), rgba(0,0,0,0.01)); }
.data-table th, .data-table td { padding: 12px 14px; text-align: right; color: var(--text); border-bottom: 1px solid var(--border); }
.data-table tbody tr:hover { background: rgba(0,0,0,0.02); }

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 10px 0 22px 0; }
.kpi-card { background: linear-gradient(135deg, rgba(246,251,255,1) 0%, rgba(240,255,252,1) 100%); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; }
.kpi-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: white; font-size: 18px; font-weight: 700; }
.kpi-icon.red { background: linear-gradient(135deg, #da4453, #b12a38); }
.kpi-icon.orange { background: linear-gradient(135deg, #f5b041, #d68910); }
.kpi-icon.green { background: linear-gradient(135deg, #1f7a4d, #2ca06c); }
.kpi-title { font-weight: 800; color: var(--text); }
.kpi-sub { color: var(--text-muted); font-size: 13px; }
.delta { font-weight: 800; font-size: 13px; }
.delta.up { color: var(--danger); }
.delta.down { color: var(--primary); }

.cards-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin: 18px 0; }
.suggestions { background: linear-gradient(135deg, #ffffff, #f7fbfd); border: 1px solid var(--border); padding: 16px; border-radius: 12px; box-shadow: var(--shadow); }

.stat-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 999px; background: rgba(16,185,129,0.08); color: var(--primary); font-weight: 700; font-size: 12px; }
.stat-pill.danger { background: rgba(239,68,68,0.08); color: var(--danger); }
.stat-pill.warn { background: rgba(245,158,11,0.08); color: var(--warning); }

/* Fine-tune dashboard content spacing and table readability */
.chart-card {
    min-height: 180px;
    display: flex;
    flex-direction: column;
    padding: 12px;
}
.chart-card canvas {
    width: 100% !important;
    height: 160px !important;
    max-height: 240px;
}

.section-title { text-align: right; }

.stat-card h3 { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.stat-card .number { font-size: 30px; }

.data-table th { background: rgba(0,0,0,0.02); font-weight: 700; }
.data-table tbody td { color: var(--text-light); font-size: 14px; }
.data-table tbody tr:nth-child(even) { background: rgba(15, 118, 110, 0.02); }

.suggestions ul { padding-right: 18px; color: var(--text-muted); }

.kpi-card .kpi-icon i { font-size: 16px; }

.charts-grid .chart-card h4, .chart-card h4 { margin-bottom: 12px; font-size: 15px; color: var(--text); }

.insights-grid .insight-card { min-height: 140px; }

@media (max-width: 900px) {
    .chart-card canvas { height: 200px !important; }
    .chart-card { min-height: 220px; }
}


.stat-card .subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* البطاقات */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title i {
    color: var(--primary);
}

/* الجداول */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* مودال التأكيد العام */
.confirm-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.confirm-modal {
    background: #FFFFFF;
    padding: 20px 22px 18px;
    border-radius: 18px;
    box-shadow: 0 18px 35px -12px rgba(15, 23, 42, 0.4);
    width: 100%;
    max-width: 360px;
    position: relative;
}

.confirm-icon {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.confirm-icon i {
    font-size: 16px;
}

.confirm-title {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text);
}

.confirm-message {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 18px;
    line-height: 1.7;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.confirm-close {
    position: absolute;
    inset-block-start: 14px;
    inset-inline-end: 18px;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.1s ease;
}

.confirm-close i {
    font-size: 14px;
}

.confirm-close:hover {
    background: var(--bg);
    color: var(--text);
    transform: scale(1.05);
}

/* زر العودة للأعلى العام */
.back-to-top-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(145deg, var(--primary), var(--primary-dark));
    border: 1px solid rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(6px);
    color: #FFFFFF;
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease, background 0.2s ease, box-shadow 0.2s ease;
    z-index: 2200;
}

.back-to-top-btn svg {
    width: 21px;
    height: 21px;
    display: block;
}

.back-to-top-btn.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    animation: backToTopPulse 2s ease-in-out infinite;
}

.back-to-top-btn:hover {
    background: linear-gradient(145deg, var(--primary-dark), #0f766e);
    transform: translateY(-3px) scale(1.07);
    box-shadow: 0 14px 28px -10px rgba(20, 184, 166, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.25);
    animation: none;
}

.back-to-top-btn:active {
    transform: translateY(0) scale(0.98);
}

@keyframes backToTopPulse {
    0%,
    100% {
        box-shadow: var(--shadow-lg);
    }
    50% {
        box-shadow: 0 12px 20px -8px rgba(16, 185, 129, 0.45);
    }
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
}

/* جدول المستخدمين المدمج */
.user-table-compact table th,
.user-table-compact table td {
    padding: 10px 12px;
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

.user-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-name {
    font-weight: 600;
    color: var(--text);
}

.user-username {
    font-size: 12px;
    color: var(--primary);
}

.user-email {
    font-size: 12px;
    color: var(--text-muted);
}

/* جدول التذاكر - نسخة مدمجة وسهلة القراءة */
.ticket-table-compact table th,
.ticket-table-compact table td {
    padding: 10px 12px;
    vertical-align: top;
}

.ticket-table-compact table th {
    font-size: 12px;
    white-space: nowrap;
}

.ticket-table-compact table td {
    font-size: 13px;
}

.ticket-table-compact table td:first-child {
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

.ticket-table-compact .status-badge {
    padding: 4px 10px;
    font-size: 11px;
}

.ticket-table-compact .icon-btn {
    padding: 3px 5px;
}

.ticket-table-compact .icon-btn i {
    font-size: 14px;
}

.ticket-subject-main {
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}

.ticket-subject-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    font-size: 11px;
    line-height: 1.4;
    color: var(--text-light);
    flex-wrap: wrap;
}

.ticket-subject-sep {
    opacity: 0.6;
}

.tickets-full-card {
    padding: 20px;
}

.tickets-full-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.tickets-full-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.tickets-filter-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
}

.tickets-filter-form label {
    font-size: 12px;
}

.tickets-filter-form input,
.tickets-filter-form select {
    font-size: 13px;
    padding: 8px 10px;
}

.tickets-filter-actions {
    display: flex;
    align-items: end;
    gap: 8px;
}

.ticket-table-full table td {
    vertical-align: middle;
}

@media print {
    .no-print {
        display: none !important;
    }

    .tickets-full-card {
        border: none;
        box-shadow: none;
        padding: 0;
    }

    .table-container {
        overflow: visible;
    }
}

.icon-btn {
    border: none;
    background: transparent;
    padding: 4px 6px;
    cursor: pointer;
    color: var(--text-light);
    transition: color 0.2s ease, transform 0.1s ease;
}

.icon-btn i {
    font-size: 16px;
}

.icon-btn:hover {
    color: var(--primary);
    transform: translateY(-1px);
}

.icon-btn-danger {
    color: var(--danger);
}

.icon-btn-danger:hover {
    color: #B91C1C;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

thead {
    background: #F9FAFB;
}

th {
    padding: 16px;
    text-align: right;
    font-weight: 600;
    color: var(--text);
    font-size: 14px;
    border-bottom: 2px solid var(--border);
}

td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-light);
    font-size: 14px;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background: var(--bg);
}

/* الأزرار العامة */
.btn-primary {
    background: var(--primary);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(26, 171, 155, 0.4);
}

.btn-secondary {
    background: var(--text-light);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.btn-secondary:hover {
    background: var(--text);
    transform: translateY(-2px);
}

.btn-danger {
    background: var(--danger);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.btn-danger:hover {
    background: #DC2626;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

/* أحجام الأزرار الصغيرة (تُستخدم في المودال وغيره) */
.btn-primary.btn-sm,
.btn-secondary.btn-sm,
.btn-danger.btn-sm {
    padding: 7px 18px;
    font-size: 13px;
    border-radius: 999px;
}

/* تنسيق خاص لأزرار المودال لتشبه التصميم المرجعي */
.confirm-actions .btn-secondary.btn-sm {
    background: #FFFFFF;
    color: var(--primary);
    border: 1px solid rgba(148, 163, 184, 0.6);
    box-shadow: 0 10px 18px -10px rgba(15, 23, 42, 0.3);
}

.confirm-actions .btn-secondary.btn-sm:hover {
    background: #F9FAFB;
}

.confirm-actions .btn-primary.btn-sm {
    background: var(--primary);
    color: #FFFFFF;
    box-shadow: 0 14px 24px -12px rgba(26, 171, 155, 0.7);
}

.confirm-actions .btn-primary.btn-sm:hover {
    background: var(--primary-dark);
}

/* حالات الحالة */
.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.status-active {
    background: #D1FAE5;
    color: #065F46;
}

.status-inactive {
    background: #FEE2E2;
    color: #991B1B;
}

.status-pending {
    background: #FEF3C7;
    color: #92400E;
}

/* صفحة تسجيل الدخول */
.login-container {
    min-height: calc(100vh - 70px);
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 20px;
}

.login-box {
    background: white;
    padding: 48px;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 420px;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header i {
    font-size: 48px;
    color: var(--primary);
    margin-bottom: 16px;
}

.login-header h2 {
    font-size: 28px;
    color: var(--text);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-light);
    font-size: 14px;
}

/* نماذج الإدخال */
.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text);
    font-weight: 600;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    transition: all 0.3s ease;
    font-family: inherit;
    background: var(--bg);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(26, 171, 155, 0.1);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

/* رسائل التنبيه */
.alert {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert i {
    font-size: 18px;
}

.alert-success {
    background: #D1FAE5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

.alert-error {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

.alert-info {
    background: #DBEAFE;
    color: #1E40AF;
    border: 1px solid #BFDBFE;
}

.alert-warning {
    background: #FEF3C7;
    color: #92400E;
    border: 1px solid #FDE68A;
}

/* التصميم المتجاوب */
@media (max-width: 768px) {
    .page-wrapper {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        position: fixed;
        bottom: 0;
        top: auto;
        border-left: none;
        border-top: 1px solid var(--border);
        z-index: 1000;
    }
    
    .sidebar nav {
        display: flex;
        flex-direction: row;
        padding: 0;
        overflow-x: auto;
    }
    
    .nav-btn {
        flex-direction: column;
        padding: 12px;
        border-right: none;
        border-top: 3px solid transparent;
        font-size: 12px;
        white-space: nowrap;
    }
    
    .nav-btn.active {
        border-right-color: transparent;
        border-top-color: var(--primary);
    }
    
    .main-content {
        margin-bottom: 80px;
    }
    
    .header {
        padding: 16px;
    }
    
    .header-actions {
        flex-wrap: wrap;
    }
    
    .content {
        padding: 20px 16px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .login-box {
        padding: 32px 24px;
    }
}

/* تأثير التحميل */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

/* سكرول بار مخصص */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}
