/* ============================================
   نظام إدارة المختبر - أنماط احترافية
   Lab LIMS Professional Styles
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;600;700;800&display=swap');

:root {
    /* الألوان الأساسية */
    --primary: #0d9488;
    --primary-dark: #0f766e;
    --primary-light: #14b8a6;
    --secondary: #475569;
    --accent: #f59e0b;

    /* ألوان الخلفيات */
    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-header: #0f172a;
    --bg-input: #f8fafc;

    /* ألوان الحدود */
    --border: #e2e8f0;
    --border-focus: #0d9488;

    /* ألوان النصوص */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;

    /* حالات الطلب والدفع */
    --status-new: #3b82f6;
    --status-progress: #f59e0b;
    --status-completed: #22c55e;
    --status-cancelled: #ef4444;
    --status-unpaid: #ef4444;
    --status-partial: #f59e0b;
    --status-paid: #22c55e;

    /* الظلال */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.08);

    /* أحجام */
    --sidebar-width: 260px;
    --header-height: 60px;
    --radius: 10px;
    --radius-sm: 6px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    direction: rtl;
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
}

/* ============================================
   صفحة تسجيل الدخول والإعداد الأولي
   ============================================ */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.85) 0%, rgba(15, 118, 110, 0.75) 100%), url('icons/bg3.png') center/cover no-repeat;
    padding: 20px;
}

.login-container {
    max-width: 420px;
    width: 100%;
    padding: 40px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

.login-container h1 {
    margin: 0 0 30px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.login-logo-wrapper {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 2px solid var(--border);
}

.login-logo-wrapper img {
    max-height: 80px;
    max-width: 200px;
    object-fit: contain;
    margin-bottom: 12px;
    display: block;
    margin-left: auto;
    margin-right: auto;
    transition: transform 0.2s;
}

.login-logo-wrapper img:hover {
    transform: scale(1.05);
}

.login-lab-name {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 4px;
}

.login-lab-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
}

/* روابط التنقل في صفحة تسجيل الدخول */
.login-nav-links {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.login-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--primary);
    text-decoration: none;
    padding: 14px 10px;
    border-radius: 12px;
    border: 1px solid rgba(13, 148, 136, 0.25);
    background: rgba(255, 255, 255, 0.6);
    transition: all 0.2s ease;
}

.login-nav-item:hover {
    background: rgba(13, 148, 136, 0.08);
    border-color: rgba(13, 148, 136, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.15);
}

.login-nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: var(--primary);
}

.login-nav-icon svg {
    width: 28px;
    height: 28px;
}

.login-nav-text {
    font-size: 0.8rem;
    font-weight: 500;
    text-align: center;
    color: var(--text-primary);
}

.login-nav-item:hover .login-nav-text {
    color: var(--primary);
}

@media (max-width: 480px) {
    .login-nav-links {
        grid-template-columns: repeat(2, 1fr);
    }
}

.login-container .form-group {
    margin-bottom: 20px;
}

.login-container .remember-me-row {
    margin-bottom: 20px;
}

.login-container .remember-me-row label {
    margin: 0;
    font-weight: normal;
    cursor: pointer;
    display: inline-flex !important;
    align-items: center;
    gap: 3px;
    width: fit-content;
}

.login-container label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.login-container input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--bg-input);
}

.login-container input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-width: 18px;
    max-width: 18px;
    padding: 0;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 3px;
    box-sizing: border-box;
    flex-shrink: 0;
    cursor: pointer;
}

.login-container input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.login-container input[type="checkbox"]:focus {
    box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.25);
}

.login-container button {
    width: 100%;
    margin-top: 24px;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-inverse);
    font-size: 1.05rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.login-container button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.4);
}

.alert {
    padding: 12px 14px;
    margin-bottom: 20px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.alert-danger {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.alert-info {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

/* ============================================
   الهيدر والشريط العلوي
   ============================================ */

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: var(--header-height);
    padding: 0 24px;
    background: var(--bg-header);
    color: var(--text-inverse);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.top-bar-left strong {
    font-size: 1.15rem;
    font-weight: 700;
}
.header-search { display: flex; gap: 8px; margin-right: 16px; }
.header-search input { background: rgba(255,255,255,0.15); color: #fff; border-color: rgba(255,255,255,0.3); }
.header-search input::placeholder { color: rgba(255,255,255,0.6); }
.header-search button { padding: 6px 14px; background: var(--primary); color: #fff; border: none; border-radius: 6px; cursor: pointer; font-weight: 500; }
.header-search button:hover { background: var(--primary-light); }

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.top-bar-right span {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.9);
}

.top-bar a {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: background 0.2s, color 0.2s;
}

.top-bar a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* ============================================
   التخطيط والـ Sidebar
   ============================================ */

.layout {
    display: flex;
    min-height: calc(100vh - var(--header-height));
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    padding: 20px 0;
    flex-shrink: 0;
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar li {
    margin-bottom: 2px;
}

.sidebar-group {
    font-size: 0.7rem;
    font-weight: 600;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 16px 6px;
    margin-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-group:first-of-type {
    margin-top: 0;
    border-top: none;
    padding-top: 6px;
}

.sidebar li a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    border-right: 3px solid transparent;
}

.sidebar li a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.sidebar li a.active {
    background: rgba(13, 148, 136, 0.25);
    color: var(--primary-light);
    border-right-color: var(--primary-light);
}

/* ============================================
   منطقة المحتوى الرئيسية
   ============================================ */

.content {
    flex: 1;
    padding: 24px;
    overflow-x: auto;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.page-header h1,
.page-header h2,
.content > h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.content > h2 {
    margin-bottom: 20px;
}

/* ============================================
   البطاقات والإحصائيات
   ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card:nth-child(1) { border-top: 4px solid var(--primary); }
.stat-card:nth-child(2) { border-top: 4px solid var(--status-progress); }
.stat-card:nth-child(3) { border-top: 4px solid var(--status-completed); }
.stat-card:nth-child(4) { border-top: 4px solid var(--accent); }

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
}

/* ============================================
   بطاقات الموديولات في لوحة التحكم
   ============================================ */

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.feature-card {
    background: var(--bg-card);
    padding: 24px 22px;
    border-radius: 18px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: rgba(13, 148, 136, 0.35);
}

.feature-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 8px;
}

.feature-icon.green { background: #dcfce7; color: #16a34a; }
.feature-icon.blue { background: #dbeafe; color: #2563eb; }
.feature-icon.purple { background: #ede9fe; color: #7c3aed; }
.feature-icon.orange { background: #ffedd5; color: #ea580c; }
.feature-icon.teal { background: #ccfbf1; color: #0f766e; }
.feature-icon.red { background: #fee2e2; color: #b91c1c; }
.feature-icon.gray { background: #e5e7eb; color: #374151; }
.feature-icon.pink { background: #ffe4e6; color: #db2777; }

.feature-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.feature-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* ============================================
   شريط الإجراءات والأزرار
   ============================================ */

.actions-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    padding: 10px 18px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff !important;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.3);
    transition: transform 0.15s, box-shadow 0.15s;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.35);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    padding: 10px 18px;
    background: var(--bg-card);
    color: var(--text-secondary) !important;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.95rem;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--bg-input);
    border-color: var(--primary);
    color: var(--primary) !important;
}

.btn-link {
    color: var(--primary);
    text-decoration: none;
    margin-left: 8px;
    font-size: 0.9rem;
}

.btn-link:hover {
    text-decoration: underline;
}

/* ============================================
   النماذج
   ============================================ */

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    max-width: 900px;
}

.form-grid .form-group {
    display: flex;
    flex-direction: column;
}

.form-grid label {
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--bg-input);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

.form-grid textarea {
    min-height: 80px;
    resize: vertical;
}

.full-width {
    grid-column: 1 / -1;
}

.form-grid > div {
    display: flex;
    flex-direction: column;
}

.form-grid > div > label {
    margin-bottom: 6px;
}

.form-grid .form-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.form-grid button[type="submit"] {
    padding: 11px 22px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.15s;
}

.form-grid button[type="submit"]:hover {
    transform: translateY(-1px);
}

/* ============================================
   قائمة الفحوصات (checkboxes)
   ============================================ */

.tests-list {
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    background: var(--bg-input);
}

.test-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    margin: 0;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}

.test-item:last-child {
    border-bottom: none;
}

.test-item input {
    width: auto;
    margin: 0;
}

/* نموذج حزمة الفحوصات */
.package-form .package-tests-section { margin-top: 8px; overflow: hidden; }
.package-form .package-tests-search {
    width: 100%;
    margin-bottom: 10px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    background: var(--bg-input);
}
.package-form .package-tests-search:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}
.package-form .package-list-hint {
    display: block;
    color: var(--text-muted);
    font-size: 0.8em;
    margin: 0 0 6px 0;
}
.package-form .package-tests-section .package-tests-list {
    height: 280px !important;
    max-height: 280px !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    background: var(--bg-input);
    flex-shrink: 0;
    scrollbar-width: thin;
}
.package-form .package-tests-list::-webkit-scrollbar {
    width: 8px;
}
.package-form .package-tests-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}
.package-form .package-test-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin: 0 0 2px 0;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}
.package-form .package-test-item:hover {
    background: rgba(13, 148, 136, 0.06);
}
.package-form .package-test-item:last-child {
    margin-bottom: 0;
}
.package-form .package-test-item input {
    width: auto;
    margin: 0;
    flex-shrink: 0;
}
.package-form .package-test-item .test-name {
    flex: 1;
    font-weight: 500;
}
.package-form .package-test-item .test-meta {
    color: var(--text-muted);
    font-size: 0.85em;
}
.form-grid .checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    margin-bottom: 0;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.form-grid .checkbox-label input { margin: 0; width: auto; }
.form-grid .required { color: var(--status-cancelled); }

/* ============================================
   البطاقات (Cards)
   ============================================ */

.card {
    background: var(--bg-card);
    padding: 20px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    border: 1px solid var(--border);
}

.card p {
    margin: 0 0 12px;
    font-size: 0.95rem;
}

.card p:last-child {
    margin-bottom: 0;
}

.section-card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    border: 1px solid var(--border);
    transition: box-shadow 0.2s;
}

.section-card:hover {
    box-shadow: var(--shadow-md);
}

.section-card h2 {
    margin: 0 0 24px 0;
    font-size: 1.25rem;
}

.section-card h3 {
    margin: 0 0 16px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary);
}

/* ============================================
   الجداول
   ============================================ */

.table-wrapper {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: box-shadow 0.2s;
}

.table-wrapper:hover {
    box-shadow: var(--shadow-md);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 14px 16px;
    text-align: right;
    font-size: 0.9rem;
}

.table th {
    background: var(--bg-input);
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 2px solid var(--border);
}

.table td {
    border-bottom: 1px solid var(--border);
}

.table tbody tr:hover {
    background: rgba(13, 148, 136, 0.04);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    margin-left: 8px;
}

.table a:hover {
    text-decoration: underline;
}

.table a:last-child {
    margin-left: 0;
}

/* شارات الحالة */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-new { background: #dbeafe; color: var(--status-new); }
.badge-in_progress { background: #fef3c7; color: #b45309; }
.badge-completed { background: #d1fae5; color: var(--status-completed); }
.badge-cancelled { background: #fee2e2; color: var(--status-cancelled); }
.badge-unpaid { background: #fee2e2; color: var(--status-unpaid); }
.badge-partial { background: #fef3c7; color: var(--status-partial); }
.badge-paid { background: #d1fae5; color: var(--status-paid); }
.badge-pending { background: #e2e8f0; color: var(--text-secondary); }
.badge-validated { background: #d1fae5; color: var(--status-completed); }
.badge-result_entered { background: #dbeafe; color: var(--status-new); }

.alerts-list { display: flex; flex-direction: column; gap: 8px; }
.alerts-list .alert-item a { color: var(--text-primary); text-decoration: none; display: block; padding: 8px 12px; background: var(--bg-input); border-radius: var(--radius-sm); }
.alerts-list .alert-item a:hover { background: #fef3c7; }

/* ============================================
   لوحة التحكم — تنسيق متقدم
   ============================================ */

.dashboard {
    max-width: 1400px;
    margin: 0 auto;
}

.dashboard-header {
    margin-bottom: 28px;
}

.dashboard-header-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
}

.dashboard-welcome {
    flex: 1;
    min-width: 200px;
}

.dashboard-title {
    margin: 0 0 4px;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.dashboard-date {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.dashboard-branch-form {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dashboard-branch-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.dashboard-branch-select {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--bg-card);
    color: var(--text-primary);
}

.dashboard-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.dashboard-btn-primary {
    padding: 10px 20px;
    font-weight: 600;
}

.dashboard-pending-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.badge-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    background: var(--accent);
    color: #fff;
    border-radius: 11px;
    font-size: 0.8rem;
    font-weight: 700;
}

.dashboard-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 16px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.dashboard-section-icon {
    font-size: 1.2rem;
}

.dashboard-alerts {
    margin-bottom: 28px;
}

.alerts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}

.alert-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    border: 1px solid transparent;
    transition: transform 0.2s, box-shadow 0.2s;
}

.alert-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.alert-card-icon {
    font-size: 1.4rem;
}

.alert-card-text {
    font-size: 0.95rem;
    font-weight: 600;
}

.alert-card--warning {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    border-color: #f59e0b;
}

.alert-card--info {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
    border-color: #3b82f6;
}

.alert-card--caution {
    background: linear-gradient(135deg, #ffedd5 0%, #fed7aa 100%);
    color: #9a3412;
    border-color: #ea580c;
}

.alert-card--danger {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #b91c1c;
    border-color: #ef4444;
}

.dashboard-stats,
.dashboard-today {
    margin-bottom: 28px;
}

.stats-grid--dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.stats-grid--today {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
}

.stat-card--primary {
    background: linear-gradient(145deg, #ffffff 0%, #f0fdfa 100%);
    border: 1px solid rgba(13, 148, 136, 0.2);
    border-right: 4px solid var(--primary);
}

.stat-card--teal {
    background: linear-gradient(145deg, #ffffff 0%, #f0fdfa 100%);
    border: 1px solid rgba(20, 184, 166, 0.2);
    border-right: 4px solid var(--primary-light);
}

.stat-card--blue {
    background: linear-gradient(145deg, #ffffff 0%, #eff6ff 100%);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-right: 4px solid #3b82f6;
}

.stat-card--purple {
    background: linear-gradient(145deg, #ffffff 0%, #f5f3ff 100%);
    border: 1px solid rgba(124, 58, 237, 0.2);
    border-right: 4px solid #7c3aed;
}

.stat-card--compact {
    padding: 18px 20px;
}

.stat-card--compact .stat-value--lg {
    font-size: 1.8rem;
}

.stat-card--revenue {
    background: linear-gradient(145deg, #ffffff 0%, #ecfdf5 100%);
    border: 1px solid rgba(34, 197, 94, 0.25);
    border-right: 4px solid var(--status-paid);
    text-decoration: none;
    color: inherit;
}

.stat-card--revenue:hover {
    border-color: rgba(34, 197, 94, 0.4);
}

.stat-value--success {
    color: var(--status-paid) !important;
}

.stat-card-icon {
    font-size: 2rem;
    margin-bottom: 12px;
    opacity: 0.9;
}

.stat-card--primary .stat-card-icon { color: var(--primary); }
.stat-card--teal .stat-card-icon { color: var(--primary-light); }
.stat-card--blue .stat-card-icon { color: #3b82f6; }
.stat-card--purple .stat-card-icon { color: #7c3aed; }

.dashboard-charts {
    margin-bottom: 28px;
}

.charts-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}

.charts-row:last-child {
    margin-bottom: 0;
}

.chart-card {
    flex: 1 1 320px;
    min-width: 280px;
    background: var(--bg-card);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.chart-card--wide {
    flex: 2 1 420px;
}

.chart-title {
    margin: 0 0 16px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.chart-wrapper {
    position: relative;
    height: 240px;
}

.dashboard-features {
    margin-bottom: 24px;
}

.feature-grid--dashboard {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.feature-card--dashboard {
    padding: 20px 18px;
    border-radius: 14px;
}

.feature-card--dashboard:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(13, 148, 136, 0.12);
}

/* ============================================
   صفحة إدارة المرضى
   ============================================ */

.patients-page { max-width: 1400px; margin: 0 auto; padding: 0 8px; }
.patients-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; padding: 0 4px; }
.patients-header h1 { margin: 0; font-size: 1.65rem; font-weight: 800; color: var(--text-primary); }
.patients-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.patients-search-form { display: flex; gap: 10px; align-items: center; }
.patients-search-input { min-width: 260px; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 1rem; background: var(--bg-input); }
.patients-search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.15); }
.patients-stats { display: flex; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.patients-stat-card { background: var(--bg-card); padding: 20px 28px; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); border-right: 4px solid var(--primary); min-width: 160px; }
.patients-stat-card.stat-warning { border-right-color: var(--status-progress); }
.patients-stat-card.stat-danger { border-right-color: var(--status-cancelled); }
.patients-stat-value { display: block; font-size: 2rem; font-weight: 800; color: var(--text-primary); line-height: 1.2; }
.patients-stat-label { display: block; font-size: 0.9rem; color: var(--text-muted); margin-top: 4px; }
.patient-code { background: var(--bg-input); padding: 4px 10px; border-radius: 6px; font-size: 0.9rem; }
.patients-row-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-action { padding: 8px 14px; border-radius: var(--radius-sm); font-size: 0.9rem; font-weight: 600; text-decoration: none; white-space: nowrap; transition: transform 0.15s; }
.btn-action:hover { transform: translateY(-1px); }
.btn-action--view { background: #dbeafe; color: #1d4ed8; }
.btn-action--view:hover { background: #bfdbfe; }
.btn-action--edit { background: #fef3c7; color: #b45309; }
.btn-action--edit:hover { background: #fde68a; }
.btn-action--order { background: #d1fae5; color: #047857; }
.btn-action--order:hover { background: #a7f3d0; }
.btn-action--delete { background: #fee2e2; color: #dc2626; border: none; cursor: pointer; font-family: inherit; }
.btn-action--delete:hover { background: #fecaca; }

/* العروض الموسمية */
.offers-row-expired { background: rgba(0,0,0,.02); opacity: 0.85; }
.offers-row-expired td { color: var(--text-muted); }
.table tbody tr.offers-row-expired:hover { background: rgba(0,0,0,.03); }
.offers-cell-name { min-width: 200px; }
.offers-name-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.offers-desc { display: block; color: var(--text-muted); font-size: 0.85rem; margin-top: 4px; }
.offers-page .table-wrapper { overflow-x: auto; border-radius: var(--radius); }
.offers-page .section-card { padding: 28px 32px; }
.offers-table-wrapper { max-height: 400px; overflow-y: auto; overflow-x: auto; }
.offers-page .table thead th { position: sticky; top: 0; background: var(--bg-input); z-index: 1; box-shadow: 0 1px 0 var(--border); }
.offers-row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.offers-discount { color: var(--status-completed); font-weight: 600; }
.offers-cell-period { white-space: nowrap; }
/* حالة فارغة محسّنة للعروض */
.offers-empty-state {
    text-align: center;
    padding: 48px 32px;
}
.offers-empty-icon { font-size: 4rem; margin-bottom: 16px; line-height: 1; }
.offers-empty-title { font-size: 1.25rem; font-weight: 600; color: var(--text-secondary); margin: 0 0 8px; }
.offers-empty-desc { color: var(--text-muted); font-size: 0.95rem; margin: 0 0 24px; max-width: 380px; margin-left: auto; margin-right: auto; line-height: 1.5; }
.offers-empty-filtered { text-align: center; padding: 32px; color: var(--text-muted); }
.offers-empty-filtered a { margin-top: 12px; }
.patients-empty { padding: 40px 24px; text-align: center; color: var(--text-muted); font-size: 1rem; }
.patients-empty a { color: var(--primary); font-weight: 600; }
.patients-pagination { display: flex; align-items: center; gap: 20px; margin-top: 24px; flex-wrap: wrap; }
.patients-pagination-info { color: var(--text-secondary); font-size: 1rem; }
.patients-form-card .form-grid { max-width: 680px; }
.patients-form-card { padding: 28px 32px; }

.patients-table th,
.patients-table td { padding: 16px 20px; font-size: 1rem; }
.patients-table thead th { font-size: 0.95rem; }
.patients-page .section-card,
.inventory-page .section-card,
.results-page .section-card { padding: 28px 32px; }
.results-enter-card { max-width: 640px; }
.results-enter-info { display: grid; gap: 10px; margin-bottom: 24px; padding: 16px; background: var(--bg-input); border-radius: var(--radius-sm); }
.results-enter-info-row { display: flex; gap: 16px; }
.results-enter-info-row strong { min-width: 120px; }
.form-hint { display: block; margin-top: 8px; font-size: 0.9rem; color: var(--text-muted); }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; padding: 0; text-decoration: underline; font-size: inherit; }
.btn-link:hover { color: var(--primary-dark); }
.results-order-summary h3 { margin: 0 0 4px; }
.results-order-summary .btn-secondary { margin-top: 4px; }
.patients-page .table-wrapper { border-radius: var(--radius); overflow: hidden; }
.required { color: #dc2626; }

.patient-profile-card { margin-bottom: 24px; }
.patient-profile-header { display: flex; flex-wrap: wrap; gap: 28px; align-items: flex-start; }
.patient-profile-qr { text-align: center; }
.patient-profile-qr img { border-radius: 8px; }
.patient-profile-qr p { margin: 8px 0 0; font-size: 0.85rem; color: var(--text-muted); }
.patient-profile-info { flex: 1; min-width: 240px; }
.patient-profile-name { margin: 0 0 4px; font-size: 1.35rem; font-weight: 700; }
.patient-profile-code { margin: 0 0 16px; font-size: 0.9rem; }
.patient-profile-dl { display: grid; grid-template-columns: auto 1fr; gap: 10px 28px; margin: 0; font-size: 1rem; }
.patient-profile-dl dt { color: var(--text-muted); font-weight: 500; }
.patient-profile-dl dd { margin: 0; }
.patient-profile-card { padding: 28px 32px; }

.attachments-list { list-style: none; padding: 0; margin: 0; }
.attachments-list li { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.attachments-list li:last-child { border-bottom: none; }
.attachment-link { color: var(--primary); text-decoration: none; flex: 1; }
.attachment-link:hover { text-decoration: underline; }
.attachment-date { font-size: 0.85rem; color: var(--text-muted); }

/* نتائج خارج المدى - تمييز أحمر */
.result-out-of-range {
    background-color: #fef2f2 !important;
}
.result-out-of-range td {
    color: #b91c1c;
    font-weight: 600;
}

/* ============================================
   صفحة الطباعة
   ============================================ */

.print-page body {
    background: #fff;
}

.report-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px;
}

.report-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border);
}

.report-title {
    text-align: center;
    margin: 20px 0;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
}

.report-patient {
    margin-bottom: 24px;
    padding: 16px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}

.report-header-left {
    text-align: left;
}

.report-footer {
    margin-top: 40px;
    display: flex;
    justify-content: space-between;
    padding-top: 24px;
    border-top: 1px dashed var(--border);
}

.no-print {
    margin-bottom: 16px;
}

.no-print button {
    padding: 10px 24px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.no-print button:hover {
    background: var(--primary-dark);
}

@media print {
    body { background: #fff !important; }
    .no-print { display: none !important; }
    .report-container { padding: 0; }
}

/* ============================================
   التصميم المتجاوب
   ============================================ */

@media (max-width: 768px) {
    .dashboard-title { font-size: 1.35rem; }
    .dashboard-header-inner { flex-direction: column; align-items: stretch; }
    .dashboard-actions { justify-content: flex-start; }
    .stats-grid--dashboard,
    .stats-grid--today { grid-template-columns: 1fr 1fr; }
    .chart-card, .chart-card--wide { flex: 1 1 100%; min-width: 100%; }
    .feature-grid--dashboard { grid-template-columns: repeat(2, 1fr); }
    
    .layout {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        padding: 10px 0;
    }
    
    .sidebar ul {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        padding: 0 12px;
    }
    
    .sidebar li {
        margin: 0;
    }
    
    .sidebar li a {
        padding: 8px 12px;
        border-radius: var(--radius-sm);
        border-right: none;
        border-bottom: 3px solid transparent;
    }
    
    .sidebar li a.active {
        border-right: none;
        border-bottom-color: var(--primary-light);
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .table-wrapper {
        overflow-x: auto;
    }
    
    .table {
        min-width: 600px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .top-bar {
        flex-wrap: wrap;
        height: auto;
        padding: 12px 16px;
    }
}

/* ============================================
   الإعدادات
   ============================================ */

.settings-section {
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    border: 1px solid var(--border);
}

.settings-section h3 {
    margin: 0 0 8px;
    font-size: 1.15rem;
}
.settings-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0 0 20px;
}
.print-settings-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 24px; }

.settings-section .form-grid {
    max-width: 100%;
}

.settings-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
}

.settings-checkbox input {
    width: auto;
}

/* صفحة تعديل الصلاحيات — مرتبة بأقسام */
.roles-permissions-form { max-width: 100%; }
.roles-section {
    margin-bottom: 28px;
}
.roles-section:last-of-type { margin-bottom: 24px; }
.roles-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0 0 14px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary);
    letter-spacing: 0.02em;
}
.roles-section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
}
.roles-perm-group {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.roles-perm-group:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px rgba(13, 148, 136, 0.1);
}
.roles-perm-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}
.roles-perm-group .settings-checkbox {
    margin-bottom: 10px;
    font-size: 0.9rem;
}
.roles-perm-group .settings-checkbox:last-child {
    margin-bottom: 0;
}
.roles-form-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    padding-top: 20px;
    margin-top: 8px;
    border-top: 2px solid var(--border);
}

/* ============================================
   حالة فارغة ورسائل
   ============================================ */

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

/* ============================================
   التوافق مع الصفحات الموجودة
   ============================================ */

/* دعم البنية القديمة للنماذج */
.form-grid > div:not(.form-group):not(.full-width) label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
}

.form-grid .form-group label {
    display: block;
}

/* ============================================
   الوضع الداكن (Dark Mode)
   ============================================ */
body.dark-mode {
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --bg-sidebar: #020617;
    --bg-header: #020617;
    --bg-input: #1e293b;
    --border: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 4px 6px rgba(0,0,0,0.3);
    --shadow-md: 0 10px 15px rgba(0,0,0,0.3);
}

.btn-icon-dark {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: inherit;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
}
.btn-icon-dark:hover { background: rgba(255,255,255,0.2); }

/* نتيجة حرجة - تمييز بصري */
.result-critical { background: #fef2f2 !important; color: #991b1b !important; font-weight: 600; }
body.dark-mode .result-critical { background: #7f1d1d !important; color: #fecaca !important; }
.result-high { color: #dc2626; }
.result-low { color: #2563eb; }
