/* ═══════════════════════════════════════════════════════════
   app.css - نظام التصميم الموحد (RTL, Mobile-First, Responsive)
   دائرة حماية المستهلك - طولكرم
   ═══════════════════════════════════════════════════════════ */

/* ===== Fonts ===== */
@font-face {
    font-family: 'Cairo';
    src: url('/static/fonts/Cairo-Regular.ttf') format('truetype');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'Cairo';
    src: url('/static/fonts/Cairo-Bold.ttf') format('truetype');
    font-weight: 700;
    font-display: swap;
}
@font-face {
    font-family: 'Cairo';
    src: url('/static/fonts/Cairo-SemiBold.ttf') format('truetype');
    font-weight: 600;
    font-display: swap;
}
@font-face {
    font-family: 'Cairo';
    src: url('/static/fonts/Cairo-Medium.ttf') format('truetype');
    font-weight: 500;
    font-display: swap;
}
@font-face {
    font-family: 'Cairo';
    src: url('/static/fonts/Cairo-Light.ttf') format('truetype');
    font-weight: 300;
    font-display: swap;
}

@font-face {
    font-family: 'Almarai';
    src: url('/static/fonts/Almarai-Regular.ttf') format('truetype');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'Almarai';
    src: url('/static/fonts/Almarai-Bold.ttf') format('truetype');
    font-weight: 700;
    font-display: swap;
}
@font-face {
    font-family: 'Almarai';
    src: url('/static/fonts/Almarai-Light.ttf') format('truetype');
    font-weight: 300;
    font-display: swap;
}

@font-face {
    font-family: 'Tajawal';
    src: url('/static/fonts/Tajawal-Regular.ttf') format('truetype');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'Tajawal';
    src: url('/static/fonts/Tajawal-Bold.ttf') format('truetype');
    font-weight: 700;
    font-display: swap;
}
@font-face {
    font-family: 'Tajawal';
    src: url('/static/fonts/Tajawal-Medium.ttf') format('truetype');
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: 'Changa';
    src: url('/static/fonts/Changa-Regular.ttf') format('truetype');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'Changa';
    src: url('/static/fonts/Changa-Bold.ttf') format('truetype');
    font-weight: 700;
    font-display: swap;
}
@font-face {
    font-family: 'Changa';
    src: url('/static/fonts/Changa-Medium.ttf') format('truetype');
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: 'IBM Plex Sans Arabic';
    src: url('/static/fonts/IBMPlexSansArabic-Regular.ttf') format('truetype');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'IBM Plex Sans Arabic';
    src: url('/static/fonts/IBMPlexSansArabic-Bold.ttf') format('truetype');
    font-weight: 700;
    font-display: swap;
}
@font-face {
    font-family: 'IBM Plex Sans Arabic';
    src: url('/static/fonts/IBMPlexSansArabic-Medium.ttf') format('truetype');
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: 'Readex Pro';
    src: url('/static/fonts/ReadexPro-Regular.ttf') format('truetype');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'Readex Pro';
    src: url('/static/fonts/ReadexPro-Bold.ttf') format('truetype');
    font-weight: 700;
    font-display: swap;
}
@font-face {
    font-family: 'Readex Pro';
    src: url('/static/fonts/ReadexPro-Medium.ttf') format('truetype');
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: 'Manal';
    src: url('/static/fonts/arfonts-ah-manal-medium.ttf') format('truetype');
    font-weight: 500;
    font-display: swap;
}
@font-face {
    font-family: 'Manal';
    src: url('/static/fonts/arfonts-ah-manal-bold.ttf') format('truetype');
    font-weight: 700;
    font-display: swap;
}
@font-face {
    font-family: 'Manal';
    src: url('/static/fonts/arfonts-ah-manal-light.ttf') format('truetype');
    font-weight: 300;
    font-display: swap;
}

/* ===== CSS Variables - مطابقة للمرجعي AID-SPA ===== */
:root {
    /* ألوان رئيسية */
    --color-primary: #3d5a80;
    --color-primary-dark: #2c4a6e;
    --color-primary-light: #e8eef5;
    --color-secondary: #5c7a9e;
    --color-accent: #e09f3e;

    /* ألوان الحالات */
    --color-success: #2a9d8f;
    --color-success-light: #d4edda;
    --color-warning: #e09f3e;
    --color-warning-light: #fff3cd;
    --color-danger: #e63946;
    --color-danger-light: #f8d7da;
    --color-info: #457b9d;
    --color-info-light: #cff4fc;

    /* خلفيات */
    --color-bg: #f5f5f0;
    --color-card: #ffffff;
    --color-surface: #f0f0eb;
    --bg-hover: #f0f0eb;

    /* نصوص */
    --color-text: #2b2d42;
    --color-text-secondary: #374151;
    --color-text-muted: #4b5563;

    /* خلفيات خاصة */
    --bg-header: #3d5a80;
    --text-header: #ffffff;
    --bg-sidebar: #3d5a80;

    /* حدود وظلال */
    --color-border: #dee2e6;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

    /* تدوير */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* تخطيط */
    --sidebar-width: 260px;
    --header-height: 56px;
    --bottom-nav-height: 64px;
    --font-family: 'Cairo', -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* Dark Mode - يدعم التبديل اليدوي والنظام */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --color-bg: #1a1a1a;
        --color-card: #242424;
        --color-surface: #333333;
        --bg-hover: #333333;
        --color-text: #e0e0e0;
        --color-text-secondary: #a0a0a0;
        --color-text-muted: #707070;
        --color-border: #3a3a3a;
        --color-primary-light: rgba(61, 90, 128, 0.2);
        --color-success-light: rgba(42, 157, 143, 0.15);
        --color-danger-light: rgba(230, 57, 70, 0.15);
        --color-warning-light: rgba(224, 159, 62, 0.15);
        --color-info-light: rgba(69, 123, 157, 0.15);
        --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
        --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
        --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
    }
}
[data-theme="dark"] {
    --color-bg: #1a1a1a;
    --color-card: #242424;
    --color-surface: #333333;
    --bg-hover: #333333;
    --color-text: #e0e0e0;
    --color-text-secondary: #a0a0a0;
    --color-text-muted: #707070;
    --color-border: #3a3a3a;
    --bg-header: #2c3e50;
    --text-header: #ffffff;
    --bg-sidebar: #2c3e50;
    --color-primary-light: rgba(61, 90, 128, 0.2);
    --color-success-light: rgba(42, 157, 143, 0.15);
    --color-danger-light: rgba(230, 57, 70, 0.15);
    --color-warning-light: rgba(224, 159, 62, 0.15);
    --color-info-light: rgba(69, 123, 157, 0.15);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
}
[data-theme="light"] {
    /* تأكيد الوضع الفاتح حتى لو النظام داكن */
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    direction: rtl;
    overflow-x: hidden;
    min-height: 100dvh;
}
a { color: var(--color-primary); text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; outline: none; }
input, select, textarea { font-family: inherit; font-size: 16px; }
img { max-width: 100%; height: auto; }

/* ===== App Layout ===== */
#app {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

/* ===== Header (AID-SPA Style) ===== */
#app-header {
    position: fixed;
    top: 0; right: 0; left: 0;
    padding-top: env(safe-area-inset-top);
    height: calc(var(--header-height) + env(safe-area-inset-top));
    background: var(--bg-header);
    color: var(--text-header);
    display: flex;
    align-items: center;
    padding-right: 16px;
    padding-left: 16px;
    z-index: 500;
    box-shadow: var(--shadow-md);
    gap: 8px;
}
@media (min-width: 769px) {
    #app-header { position: static; }
}
#header-title {
    flex: 1;
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.header-btn {
    background: transparent;
    border: none;
    color: #fff;
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background 0.2s;
}
.header-btn:hover { background: rgba(255,255,255,0.15); }
.header-actions { display: flex; align-items: center; gap: 4px; }
@media (max-width: 480px) {
    .header-btn { width: 44px; height: 44px; padding: 10px; border-radius: 50%; justify-content: center; }
    .header-btn svg { width: 24px; height: 24px; }
}
.header-back {
    background: transparent; border: none; color: #fff;
    padding: 6px; border-radius: 6px; cursor: pointer; display: flex; align-items: center;
    transition: background 0.2s;
}
.header-back:hover { background: rgba(255,255,255,0.15); }
@media (max-width: 480px) {
    .header-back { padding: 10px; }
    .header-back svg { width: 24px; height: 24px; }
}

/* ===== Main Content ===== */
#app-main {
    flex: 1;
    padding: 16px;
    padding-top: calc(var(--header-height) + env(safe-area-inset-top, 0px) + 16px);
    padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 16px);
    max-width: 100%;
    min-width: 0;
}

/* ===== Bottom Navigation (Mobile/Tablet) - AID-SPA Style ===== */
#bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: var(--color-card);
    border-top: 1px solid var(--color-border);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
    z-index: 500;
}
.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 6px;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: color 0.2s;
    border: none;
    background: transparent;
    font-family: inherit;
    text-decoration: none;
    min-height: 56px;
}
.nav-item.active { color: var(--color-primary); }
.nav-item:hover { color: var(--color-primary); }
.nav-icon { width: 32px; height: 32px; font-size: 28px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.nav-icon svg { width: 28px; height: 28px; }
.nav-label { font-size: 12px; font-weight: 600; }

/* زر الإضافة المركزي */
.nav-add {
    width: 48px; height: 48px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: transform 0.2s, background 0.2s;
    flex-shrink: 0;
    margin-bottom: 8px;
}
.nav-add:hover { transform: scale(1.08); background: var(--color-primary-dark); }
.nav-add svg { width: 24px; height: 24px; }

/* ===== Sidebar (Desktop) ===== */
#sidebar {
    display: none;
}
@media (min-width: 1024px) {
    #app {
        display: grid;
        grid-template-columns: var(--sidebar-width) 1fr;
        grid-template-rows: var(--header-height) 1fr;
        grid-template-areas:
            "sidebar header"
            "sidebar main";
        min-height: 100vh;
    }
    #sidebar {
        display: flex;
        flex-direction: column;
        grid-area: sidebar;
        background: #3d5a80;
        color: #fff;
        overflow-y: auto;
        scrollbar-width: none;           /* Firefox */
        -ms-overflow-style: none;        /* IE/Edge */
        position: fixed;
        top: 0; right: 0;
        width: var(--sidebar-width);
        height: 100vh;
        z-index: 200;
    }
    #sidebar::-webkit-scrollbar { display: none; }  /* Chrome/Safari */
    #app-header {
        grid-area: header;
        position: sticky;
        top: 0;
    }
    #app-main {
        grid-area: main;
        padding: 24px;
        padding-bottom: 24px;
        max-width: 100%;
        min-width: 0;
    }
    #bottom-nav { display: none; }
    .header-btn.only-mobile { display: none; }
}

/* Sidebar Content */
.sidebar-brand {
    padding: 20px 16px 14px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo { font-size: 2.2rem; margin-bottom: 4px; }
.sidebar-title { font-size: 1rem; font-weight: 700; }
.sidebar-subtitle { font-size: 0.75rem; opacity: 0.7; }

.sidebar-nav {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }
.sidebar-link {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px;
    color: rgba(255,255,255,0.7);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
    border-right: 3px solid transparent;
    text-decoration: none;
}
.sidebar-link:hover,
.sidebar-link.active {
    color: #fff;
    background: rgba(255,255,255,0.08);
}
.sidebar-link.active {
    border-right-color: var(--color-primary);
    background: rgba(26,115,232,0.15);
}
.sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 8px 16px;
}

.sidebar-footer {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-user { display: flex; align-items: center; gap: 8px; flex: 1; }
.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--color-primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem; font-weight: 700; color: #fff;
}
.user-info { flex: 1; min-width: 0; }
.user-name {
    font-size: 0.85rem; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-role { font-size: 0.7rem; opacity: 0.6; }
.sidebar-logout {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; color: rgba(255,255,255,0.5);
    border-radius: 50%;
    transition: all 0.2s;
}
.sidebar-logout:hover { color: #fff; background: rgba(255,255,255,0.1); }

/* ===== Cards ===== */
.card {
    background: var(--color-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 16px;
    margin-bottom: 12px;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px;
}
.card-title {
    font-size: 1rem; font-weight: 700;
    color: var(--color-text);
}

/* ===== Stat Cards ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
@media (min-width: 768px) {
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
}
.stat-card {
    background: var(--color-card);
    border-radius: var(--radius-md);
    padding: 14px;
    box-shadow: var(--shadow-sm);
    border-right: 4px solid var(--color-primary);
    display: flex; flex-direction: column; gap: 4px;
}
.stat-card.border-green  { border-right-color: #1E8E3E; }
.stat-card.border-red    { border-right-color: #D93025; }
.stat-card.border-blue   { border-right-color: #1A73E8; }
.stat-card.border-orange { border-right-color: #E8710A; }
.stat-card.border-purple { border-right-color: #9334E6; }
.stat-card.border-teal   { border-right-color: #007B83; }
.stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-label { font-size: 0.75rem; color: var(--color-text-muted); }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 20px;
    font-size: 0.875rem; font-weight: 600;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    white-space: nowrap;
    text-decoration: none;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #C5221F; }
.btn-success { background: var(--color-success); color: #fff; }
.btn-outline {
    background: transparent; color: var(--color-primary);
    border: 1.5px solid var(--color-primary);
}
.btn-outline:hover { background: var(--color-primary-light); }
.btn-ghost { background: transparent; color: var(--color-text); }
.btn-ghost:hover { background: var(--color-surface); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-icon {
    width: 36px; height: 36px; padding: 0;
    border-radius: 50%;
}

/* ===== Forms ===== */
.form-group { margin-bottom: 14px; }
.form-label {
    display: block;
    font-size: 0.85rem; font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.95rem;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-card);
    color: var(--color-text);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}
.form-textarea { min-height: 80px; resize: vertical; }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 12px center; padding-left: 36px; }

/* ===== Search Bar ===== */
.search-bar {
    display: flex; gap: 8px; margin-bottom: 12px;
}
.search-input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: var(--color-card);
}
.search-input:focus { outline: none; border-color: var(--color-primary); }

/* ===== Filter Bar ===== */
.filter-bar {
    display: flex; flex-wrap: wrap; gap: 8px;
    margin-bottom: 12px;
    padding: 10px;
    background: var(--color-surface);
    border-radius: var(--radius-sm);
}
.filter-bar select, .filter-bar input {
    padding: 8px 10px;
    font-size: 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-card);
}

/* ===== Tables ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    background: var(--color-card);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.data-table th {
    background: var(--color-surface);
    padding: 10px 12px;
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
    border-bottom: 2px solid var(--color-border);
}
.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border);
}
.data-table tr:hover td { background: var(--color-primary-light); }

/* Mobile: Card-based table */
@media (max-width: 768px) {
    .data-table thead { display: none; }
    .data-table, .data-table tbody, .data-table tr, .data-table td {
        display: block;
    }
    .data-table tr {
        background: var(--color-card);
        border-radius: var(--radius-sm);
        margin-bottom: 8px;
        padding: 10px;
        box-shadow: var(--shadow-sm);
    }
    .data-table td {
        display: flex; justify-content: space-between;
        padding: 6px 0;
        border: none;
    }
    .data-table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--color-text-muted);
        margin-left: 8px;
        text-align: right;
        min-width: 80px;
    }
    [dir="rtl"] .data-table td::before {
        margin-left: 0;
        margin-right: 8px;
        text-align: right;
    }
}

/* ===== Pagination ===== */
.pagination {
    display: flex; align-items: center; justify-content: center; gap: 4px;
    margin-top: 16px;
    flex-wrap: wrap;
}
.pagination button {
    min-width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--color-card);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.15s;
}
.pagination button:hover { background: var(--color-surface); }
.pagination button.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Toast ===== */
#toast-container {
    position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
    z-index: 9999;
    display: flex; flex-direction: column; gap: 8px;
    max-width: 90vw;
}
.toast {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    font-size: 0.9rem; font-weight: 600;
    animation: slideDown 0.3s ease;
    min-width: 280px;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}
.toast-success { background: var(--color-success); color: #fff; }
.toast-error { background: var(--color-danger); color: #fff; }
.toast-warning { background: var(--color-warning); color: #fff; }
.toast-info { background: var(--color-info); color: #fff; }

/* ===== Modal ===== */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 3000;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.modal,
.modal-content {
    background: var(--color-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    background: var(--color-surface);
    border-radius: 50%;
    font-size: 1.2rem; color: var(--color-text);
    transition: background 0.2s;
}
.modal-close:hover { background: var(--color-danger); color: #fff; }
.modal-body { padding: 20px; }

/* ===== Skeleton Loading ===== */
.skeleton {
    background: linear-gradient(90deg, var(--color-surface) 25%, var(--color-border) 50%, var(--color-surface) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
    height: 16px;
    margin-bottom: 8px;
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.5; }
.empty-state-title { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.empty-state-desc { font-size: 0.85rem; }

/* ===== Status Badges ===== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem; font-weight: 600;
    white-space: nowrap;
}
.badge-green  { background: var(--color-success-light); color: var(--color-success); }
.badge-red    { background: var(--color-danger-light); color: var(--color-danger); }
.badge-blue   { background: var(--color-info-light); color: var(--color-info); }
.badge-orange { background: var(--color-warning-light); color: var(--color-warning); }

/* ===== FAB ===== */
.fab {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 16px);
    left: 16px;
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-lg);
    font-size: 1.5rem;
    z-index: 50;
    transition: transform 0.2s, box-shadow 0.2s;
}
.fab:hover { transform: scale(1.05); box-shadow: 0 6px 20px rgba(0,0,0,0.2); }
@media (min-width: 1024px) {
    .fab { bottom: 24px; left: 24px; }
}

/* ===== Pull-to-Refresh (AID-SPA Style) ===== */
.ptr-indicator {
    position: fixed;
    top: -60px;
    left: 0;
    right: 0;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    font-size: 13px;
    gap: 8px;
    z-index: 110;
    pointer-events: none;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-bottom: 1px solid rgba(0,0,0,0.05);
}
.ptr-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: ptr-spin 0.8s linear infinite;
    display: none;
}
.ptr-indicator.ptr-refreshing .ptr-spinner { display: block; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }

/* ===== Utility Classes ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--color-text-muted); }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ===== RTL fixes ===== */
[dir="rtl"] .sidebar-link { border-right: 3px solid transparent; border-left: none; }
[dir="rtl"] .stat-card { border-right-width: 4px; }
[dir="rtl"] .sidebar-link.active { border-right-color: var(--color-primary); }

/* ===== Login Screen (AID-SPA Style) ===== */
body.login-page #app-header,
body.login-page #bottom-nav,
body.login-page #sidebar,
body.login-page .fab { display: none !important; }

.login-screen {
    position: fixed; inset: 0; z-index: 10000;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 16px; padding: 16px;
    background: #f5f5f0;
    overflow-y: auto;
}
.login-card {
    position: relative;
    background: #FFFFFF;
    border-radius: 16px;
    padding: 32px 24px 20px;
    width: 100%; max-width: 380px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
    text-align: center;
    overflow: hidden;
}
.login-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, #1A73E8, #4A90D9);
}
.login-logo { text-align: center; margin-bottom: 10px; margin-top: 4px; }
.login-logo img { max-width: 90px; height: auto; display: block; margin: 0 auto; }
.login-logo-placeholder {
    width: 56px; height: 56px; border-radius: 50%;
    background: #E8F0FE; color: #1A73E8;
    display: flex; align-items: center; justify-content: center;
    font-size: 26px; margin: 0 auto;
}
.login-title { font-size: 1.1rem; font-weight: 800; color: #1A1A1A; margin-bottom: 4px; line-height: 1.3; }
.login-subtitle { font-size: 0.8rem; color: #666; margin-bottom: 16px; }
.login-footer { text-align: center; margin-top: 16px; font-size: 10px; color: #999; }
.login-bigscreen-link { text-align: center; margin-top: 12px; }
.bigscreen-tab {
    display: inline-block;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #1a1040, #3b1f6e);
    border-radius: 10px;
    text-decoration: none;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(59, 31, 110, 0.4);
}
.bigscreen-tab:hover {
    background: linear-gradient(135deg, #2a1860, #5b2fa6);
    box-shadow: 0 6px 20px rgba(59, 31, 110, 0.6);
    transform: translateY(-1px);
}
.login-error { color: var(--color-danger); font-size: 0.85rem; margin-top: 8px; display: none; }

/* ═══════════════════════════════════════════════════════════
   AID-SPA Style - List Design (مستوحى من تصميم AID-SPA)
   ═══════════════════════════════════════════════════════════ */

/* ─── Action Bar ─────────────────────────────────────────── */
.action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.action-bar-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--color-text);
}
.action-bar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ─── Search Bar ─────────────────────────────────────────── */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.search-input-wrap {
    flex: 1;
    min-width: 200px;
    max-width: 500px;
    position: relative;
}
.search-input-wrap .search-icon {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    pointer-events: none;
    font-size: 1rem;
}
.search-input-wrap .form-input { padding-right: 38px; }
.search-bar .form-select { flex: 0 1 180px; min-width: 140px; }

/* ─── Filters Row ────────────────────────────────────────── */
.filters-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.filters-row .form-select { min-width: 140px; flex: 1; max-width: 200px; }

/* ─── Results Count ──────────────────────────────────────── */
.results-count {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-bottom: 8px;
    font-weight: 600;
}

/* ─── List Item (AID-SPA style) ──────────────────────────── */
.list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    transition: background 0.15s;
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--color-surface); }
.list-item-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--color-primary-light);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
    overflow: hidden;
}
.list-item-content { flex: 1; min-width: 0; }
.list-item-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.list-item-subtitle {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.list-item-meta {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* ─── List Container Card ─────────────────────────────────── */
.list-card {
    background: var(--color-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.list-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}
.list-card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}

/* ─── Skeleton Card ──────────────────────────────────────── */
.skeleton-card {
    height: 60px;
    margin: 4px 12px;
    border-radius: 8px;
    background: linear-gradient(90deg, var(--color-surface) 25%, var(--color-border) 50%, var(--color-surface) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ─── Detail Screen (AID-SPA style) ──────────────────────── */
.detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--color-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}
.detail-header-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--color-primary-light);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.5rem;
    flex-shrink: 0;
}
.detail-header-info { flex: 1; min-width: 0; }
.detail-header-name { font-size: 1.3rem; font-weight: 800; color: var(--color-text); }
.detail-header-sub { font-size: 0.85rem; color: var(--color-text-secondary); margin-top: 4px; }
.detail-header-actions { flex-shrink: 0; }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    padding: 16px 20px;
}
.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.detail-item-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-muted);
}
.detail-item-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text);
}

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 480px) {
    .list-item { gap: 8px; padding: 10px 12px; }
    .list-item-avatar { width: 36px; height: 36px; font-size: 0.85rem; }
    .list-item-title { font-size: 0.85rem; }
    .list-item-subtitle { font-size: 0.75rem; }
    .list-item-meta { flex-direction: row; }
    .detail-header { flex-direction: column; text-align: center; }
    .detail-header-actions { width: 100%; }
    .detail-grid { grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px 14px; }
    .detail-item { flex-direction: row; align-items: center; gap: 8px; padding: 6px 0; }
    .detail-item-label { font-size: 0.7rem; min-width: 60px; }
    .detail-item-value { font-size: 0.82rem; }
    .action-bar-title { font-size: 1rem; }
    .search-input-wrap { min-width: 140px; }
    .search-bar .form-select { flex: 1 1 100%; min-width: 0; }
    .filters-row { grid-template-columns: 1fr; }
    .filters-row .form-select { min-width: 0; max-width: none; width: 100%; }
}

/* ═══════════════════════════════════════════════════════════
   Dashboard (AID-SPA Style)
   ═══════════════════════════════════════════════════════════ */

/* ─── Welcome Card ───────────────────────────────────────── */
.welcome-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, var(--color-primary) 0%, #185ABC 100%);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}
.welcome-card::before {
    content: '';
    position: absolute;
    top: -50%; right: -20%;
    width: 200px; height: 200px;
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
    pointer-events: none;
}
.welcome-card::after {
    content: '';
    position: absolute;
    bottom: -30%; left: -10%;
    width: 120px; height: 120px;
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
    pointer-events: none;
}
.welcome-avatar {
    width: 48px; height: 48px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1.1rem;
    flex-shrink: 0; position: relative; z-index: 1;
}
.welcome-text { flex: 1; min-width: 0; position: relative; z-index: 1; }
.welcome-greeting { font-size: 1.05rem; font-weight: 700; }
.welcome-role { font-size: 0.8rem; opacity: 0.85; margin-top: 2px; }
.welcome-stats {
    display: flex; gap: 8px; width: 100%;
    position: relative; z-index: 1; margin-top: 4px;
}
@media (min-width: 769px) {
    .welcome-stats { width: auto; flex: 0 0 auto; margin-top: 0; margin-right: auto; }
    .welcome-text { max-width: 40%; }
    .welcome-card { padding: 20px 28px; }
}
.welcome-stat {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    background: rgba(255,255,255,0.12);
    border-radius: var(--radius-md);
    padding: 10px 6px;
    backdrop-filter: blur(4px);
    transition: all 0.2s;
    cursor: pointer;
}
.welcome-stat:hover { background: rgba(255,255,255,0.2); transform: translateY(-1px); }
.welcome-stat-icon { font-size: 20px; line-height: 1; }
.welcome-stat-value { font-size: 0.95rem; font-weight: 800; line-height: 1.2; direction: ltr; }
.welcome-stat-label { font-size: 9px; opacity: 0.85; white-space: nowrap; }
@media (max-width: 480px) {
    .welcome-stat-label { font-size: 8px; white-space: normal; }
}

/* ─── Quick Actions ──────────────────────────────────────── */
.quick-actions {
    display: flex; gap: 8px; margin-bottom: 16px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; padding: 4px 0;
}
.quick-actions::-webkit-scrollbar { display: none; }
.quick-action-btn {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 10px 16px; background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer; transition: all 0.15s;
    white-space: nowrap; flex-shrink: 0; min-width: 80px;
}
.quick-action-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.quick-action-icon { font-size: 22px; line-height: 1; }
.quick-action-label { font-size: 11px; font-weight: 600; color: var(--color-text-secondary); }

/* ─── Dashboard Grid ─────────────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
@media (min-width: 769px) { .dashboard-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1200px) { .dashboard-grid { grid-template-columns: repeat(6, 1fr); } }
.dash-stat-card {
    background: var(--color-card);
    border-radius: var(--radius-md);
    padding: 12px;
    box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; gap: 4px;
    cursor: pointer; transition: all 0.15s;
    border-right: 4px solid var(--color-primary);
    min-width: 0;
}
.dash-stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.dash-stat-card.success { border-color: var(--color-success); }
.dash-stat-card.warning { border-color: var(--color-warning); }
.dash-stat-card.danger  { border-color: var(--color-danger); }
.dash-stat-card.info    { border-color: var(--color-info); }
.dash-stat-icon { font-size: 22px; }
.dash-stat-value { font-size: 1.2rem; font-weight: 800; color: var(--color-text); line-height: 1; }
.dash-stat-label { font-size: 0.7rem; color: var(--color-text-secondary); font-weight: 600; white-space: nowrap; }

/* ─── Dashboard Weekly Chart ─────────────────────────────── */
.dashboard-weekly-card { margin-bottom: 16px; }
.dashboard-weekly-body { padding: 8px 0; }
.weekly-chart-svg { width: 100%; height: auto; max-height: 220px; }

/* ─── Dashboard Pie Charts ───────────────────────────────── */
.dashboard-charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}
@media (max-width: 768px) { .dashboard-charts-row { grid-template-columns: 1fr; } }
.dashboard-pie-wrap { display: flex; align-items: center; gap: 16px; padding: 12px 16px; }
.dashboard-pie-svg { flex-shrink: 0; }
.pie-legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.75rem; margin-bottom: 4px; }
.pie-legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.pie-legend-label { color: var(--color-text-secondary); flex: 1; }
.pie-legend-value { font-weight: 700; color: var(--color-text); }
.pie-legend-pct { color: var(--color-text-muted); font-size: 0.7rem; }

/* ─── Dashboard Recent ───────────────────────────────────── */
.dashboard-recent-card { margin-bottom: 16px; }
.dash-recent-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px; border-bottom: 1px solid var(--color-border);
    cursor: pointer; transition: background 0.15s;
}
.dash-recent-item:last-child { border-bottom: none; }
.dash-recent-item:hover { background: var(--color-surface); }

/* ═══════════════════════════════════════════════════════════
   Tab Card Grid — Search & Reports
   ═══════════════════════════════════════════════════════════ */
.tab-card-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 12px;
}
.tab-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 10px 6px;
    background: var(--color-card);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    min-height: 64px;
}
.tab-card:hover { border-color: var(--color-primary); background: var(--color-primary-light); }
.tab-card.active {
    border-color: var(--color-primary);
    background: var(--color-primary);
    color: #fff;
}
.tab-card.active .tab-card-label { color: #fff; }
.tab-card-icon { font-size: 1.3rem; line-height: 1; }
.tab-card-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    line-height: 1.2;
}
@media (max-width: 480px) {
    .tab-card-grid { grid-template-columns: repeat(3, 1fr); gap: 4px; }
    .tab-card { padding: 8px 4px; min-height: 56px; }
    .tab-card-icon { font-size: 1.1rem; }
    .tab-card-label { font-size: 0.65rem; }
}
@media (min-width: 768px) {
    .tab-card-grid { grid-template-columns: repeat(6, 1fr); }
}

/* ═══════════════════════════════════════════════════════════
   Visit Screens Responsive (Mobile ≤ 480px)
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    /* Collapse 2-column grids to 1 column */
    .resp-grid-2 { grid-template-columns: 1fr !important; }
    /* Shrink modals to fit screen */
    .resp-modal { max-width: 95vw !important; margin: 0 8px !important; max-height: 85vh !important; }
    /* Wrap action buttons */
    .resp-actions { flex-wrap: wrap !important; }
    /* Reduce record button text on mobile */
    .resp-record-btn { padding: 8px 8px !important; }
    .resp-record-btn span:first-child { font-size: 0.82rem !important; }
    .resp-record-btn span:last-child { font-size: 0.65rem !important; }
}

/* ═══════════════════════════════════════════════════════════
   Print Styles (AID-SPA Style)
   ═══════════════════════════════════════════════════════════ */
@media print {
    body { background: #fff !important; font-size: 12px; }
    #app-header, #bottom-nav, #sidebar, .no-print, .fab { display: none !important; }
    #app-main { margin: 0 !important; padding: 0 !important; max-width: 100% !important; }
    .print-page { page-break-after: always; padding: 0; }
    .print-page:last-child { page-break-after: auto; }
    @page { margin: 10mm; }
}
.print-controls {
    position: fixed; top: 0; left: 0; right: 0; z-index: 510;
    background: #333; color: #fff; padding: 10px 16px;
    display: flex; align-items: center; gap: 8px;
}
.print-controls .btn { color: #fff !important; border-color: rgba(255,255,255,0.3); }
.print-controls .btn:hover { background: rgba(255,255,255,0.15); }
.print-view { padding-top: 56px; }
.print-controls .btn:hover { background: rgba(255,255,255,0.15); }
.print-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    padding-bottom: 12px; border-bottom: 2px solid #1A73E8; margin-bottom: 12px;
    gap: 12px;
}
.print-logo { flex-shrink: 0; margin-inline-end: 16px; }
.print-logo img { max-width: 70px; max-height: 70px; object-fit: contain; }
.print-header-text { flex: 1; min-width: 0; }
.print-inst-name { font-size: 19px; font-weight: 800; color: #1A73E8; word-break: break-word; }
.print-inst-sub { font-size: 14px; color: #555; word-break: break-word; }
.print-inst-detail { font-size: 12px; color: #777; word-break: break-word; }
.print-request-box {
    text-align: right; font-size: 13px; color: #555;
    border: 1px solid #ddd; padding: 8px 12px; border-radius: 6px;
    flex-shrink: 0; white-space: nowrap;
}
@media (max-width: 600px) {
    .print-header {
        flex-direction: column;
        align-items: stretch;
    }
    .print-logo {
        margin-inline-end: 0;
        text-align: center;
    }
    .print-logo img { max-width: 50px; max-height: 50px; }
    .print-request-box {
        white-space: normal;
    }
    .print-header-text {
        text-align: center;
    }
    .print-inst-name { font-size: 16px; }
    .print-inst-sub { font-size: 13px; }
}
.print-section { margin-top: 12px; }
.print-section-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.print-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.print-table th, .print-table td {
    border: 1px solid #ddd; padding: 5px 8px; text-align: right;
}
.print-table th { background: #f0f0f0; font-weight: 700; }
.print-table tr:nth-child(even) td { background: #fafafa; }
.print-footer {
    margin-top: 16px; padding-top: 8px; border-top: 1px solid #ddd;
    font-size: 11px; color: #999; text-align: center;
}

/* ═══════════════════════════════════════
   Patrol Plan Highlight
   ═══════════════════════════════════════ */
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.08); }
}
.sidebar-link-highlight {
    background: linear-gradient(135deg, rgba(255,152,0,0.18), rgba(244,67,54,0.12));
    border-right: 3px solid #ff9800;
    border-radius: 0;
    color: #ffcc80;
}
.sidebar-link-highlight svg {
    color: #ff9800;
}
.sidebar-link-highlight:hover,
.sidebar-link-highlight.active {
    background: linear-gradient(135deg, rgba(255,152,0,0.28), rgba(244,67,54,0.20));
    color: #fff;
}
.print-loading { text-align: center; padding: 40px; font-size: 1rem; color: #666; }
.print-signatures { display: flex; justify-content: space-between; }

/* ═══════════════════════════════════════════════════════════
   Admin Grid (بطاقات الإعدادات والإدارة) - نمط AID-SPA
   ═══════════════════════════════════════════════════════════ */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
@media (min-width: 481px) {
    .admin-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 769px) {
    .admin-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1200px) {
    .admin-grid { grid-template-columns: repeat(6, 1fr); }
}
.admin-card {
    background: var(--color-card);
    border-radius: var(--radius-md);
    padding: 20px 12px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    text-align: center;
    border: 1.5px solid transparent;
    min-width: 0;
}
.admin-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--color-primary);
}
.admin-card:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}
.admin-card-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    background: var(--color-primary-light);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    flex-shrink: 0;
}
.admin-card-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.3;
}

/* ═══════════════════════════════════════════════════════════
   Form Row (حقول جنب بعض)
   ═══════════════════════════════════════════════════════════ */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
@media (max-width: 480px) {
    .form-row { grid-template-columns: 1fr; }
}

/* ─── Card Body ─────────────────────────────────────────── */
.card-body { padding: 16px; }

/* ═══════════════════════════════════════════════════════════
   Attachments & Media Capture — Responsive (RTL)
   ═══════════════════════════════════════════════════════════ */

/* Attachment cards in list */
.att-card { cursor: default !important; }
.att-card:hover { background: var(--color-surface); }
.att-name {
    word-break: break-all;
    line-height: 1.3;
}
.att-meta {
    font-size: 11px;
    color: var(--color-text-muted);
}
.att-buttons { flex-shrink: 0; }

/* Attachment action buttons row */
.att-actions-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    align-items: center;
}
.att-action-btn {
    min-height: 38px;
    font-size: 0.82rem;
    white-space: nowrap;
}

/* Branch accordion */
.branch-item {
    border-bottom: 1px solid var(--color-border);
}
.branch-item:last-child { border-bottom: none; }
.branch-toggle:hover { background: var(--color-surface); }
.branch-chevron {
    transition: transform 0.2s;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}
.branch-att-count {
    font-size: 0.7rem;
    color: var(--color-text-muted);
}

/* Media capture modals */
.media-modal-overlay {
    z-index: 10002;
}
.media-modal {
    background: var(--color-card);
    border-radius: var(--radius-lg);
    width: 95%;
    max-width: 640px;
    max-height: 95vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.media-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    background: var(--color-card);
    z-index: 1;
}
.media-modal-body { padding: 16px; }

/* Close button for modals */
.modal-close-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff;
    font-size: 20px;
    width: 36px; height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.modal-close-btn:hover { background: rgba(255,255,255,0.3); }
.media-modal .modal-close-btn {
    background: var(--color-surface);
    border: none;
    color: var(--color-text);
    font-size: 18px;
    width: 32px; height: 32px;
    border-radius: 50%;
}

/* Attachment modal content (image/video viewer) */
.att-modal-content { position: relative; max-width: 90vw; max-height: 90vh; }
.att-modal-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    color: #fff;
    flex-wrap: wrap;
    gap: 8px;
}
.att-modal-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ─── Responsive: Mobile ─── */
@media (max-width: 768px) {
    .att-actions-row {
        gap: 6px;
    }
    .att-action-btn {
        min-height: 44px;
        font-size: 0.78rem;
        padding: 8px 10px;
        flex: 1 1 auto;
        min-width: 0;
    }
    .att-buttons {
        flex-wrap: wrap;
        gap: 4px;
    }
    .att-buttons .btn {
        padding: 6px 8px;
        font-size: 0.72rem;
        min-height: 34px;
    }
    .att-card .list-item-content {
        flex: 2;
    }
    .att-name {
        font-size: 12px !important;
    }
    .att-meta {
        font-size: 10px;
    }
    /* Media modal fullscreen on mobile */
    .media-modal {
        width: 100%;
        max-width: 100%;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
    }
    .media-modal-overlay {
        padding: 0;
        align-items: stretch;
    }
    /* Branch toggle touch area */
    .branch-toggle {
        padding: 14px 10px;
        min-height: 48px;
    }
    /* Attachment modal full width */
    .att-modal-content {
        max-width: 100vw;
        max-height: 100vh;
    }
    .att-modal-bar {
        padding: 0 8px;
    }
}

@media (max-width: 390px) {
    .att-actions-row {
        flex-direction: column;
        gap: 6px;
    }
    .att-action-btn {
        width: 100%;
        justify-content: center;
    }
    .att-meta {
        display: none;
    }
    .att-buttons .btn {
        padding: 5px 6px;
        font-size: 0.7rem;
        min-height: 30px;
    }
}
