/* ألوان الهوية الرسمية — CLIVO | MS */
:root {
    /* Primary brand */
    --brand: #073763;          /* Primary Navy — أزرار وعناوين */
    --brand-dark: #052A4F;     /* Dark Navy — القائمة الجانبية والأسطح الداكنة */
    --brand-light: #E8F8F6;    /* Light Teal — إبراز خفيف */
    --accent: #0FB5A5;         /* Brand Teal — الحالات النشطة */
    --accent-dark: #0C9488;

    /* Neutral */
    --ink: #172B3A;            /* Main Text */
    --muted: #667785;          /* Secondary */
    --muted-bg: #DCE6EF;       /* Muted */
    --line: #E4EAF0;           /* Border */
    --bg: #F6F9FC;             /* Background */
    --card: #FFFFFF;           /* Surface */

    /* Semantic */
    --success: #16A34A;
    --warning: #F59E0B;
    --danger: #DC2626;
    --info: #2563EB;

    --sidebar: #FFFFFF;
    --sidebar-hover: #E8F8F6;

    /* Bootstrap */
    --bs-primary: #073763;
    --bs-primary-rgb: 7, 55, 99;
    --bs-success: #16A34A;
    --bs-success-rgb: 22, 163, 74;
    --bs-warning: #F59E0B;
    --bs-warning-rgb: 245, 158, 11;
    --bs-danger: #DC2626;
    --bs-danger-rgb: 220, 38, 38;
    --bs-info: #2563EB;
    --bs-info-rgb: 37, 99, 235;
    --bs-body-color: #172B3A;
    --bs-body-bg: #F6F9FC;
    --bs-border-color: #E4EAF0;
    --bs-secondary-color: #667785;
    --bs-link-color: #073763;
    --bs-link-color-rgb: 7, 55, 99;
    --bs-link-hover-color: #0FB5A5;
    --bs-link-hover-color-rgb: 15, 181, 165;
}

/* Bootstrap components على ألوان الهوية */
.btn-primary {
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-dark);
    --bs-btn-hover-border-color: var(--brand-dark);
    --bs-btn-active-bg: var(--brand-dark);
    --bs-btn-active-border-color: var(--brand-dark);
    --bs-btn-disabled-bg: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
}

.btn-outline-primary {
    --bs-btn-color: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-bg: var(--brand-dark);
    --bs-btn-active-border-color: var(--brand-dark);
}

.btn-success {
    --bs-btn-bg: var(--success);
    --bs-btn-border-color: var(--success);
    --bs-btn-hover-bg: #15803D;
    --bs-btn-hover-border-color: #15803D;
}

.btn-info {
    --bs-btn-bg: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-color: #fff;
    --bs-btn-hover-bg: var(--accent-dark);
    --bs-btn-hover-border-color: var(--accent-dark);
    --bs-btn-hover-color: #fff;
}

.btn-outline-info {
    --bs-btn-color: var(--accent-dark);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--accent);
    --bs-btn-hover-border-color: var(--accent);
    --bs-btn-hover-color: #fff;
}

.form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

.form-check-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 181, 165, .18);
}

.nav-pills .nav-link.active,
.nav-pills .show > .nav-link {
    background-color: var(--brand);
}

.nav-tabs .nav-link.active {
    color: var(--brand);
    border-bottom-color: transparent;
    box-shadow: inset 0 -3px 0 var(--accent);
}

.nav-tabs .nav-link {
    color: var(--muted);
}

.page-link {
    color: var(--brand);
}

.page-item.active .page-link {
    background-color: var(--brand);
    border-color: var(--brand);
}

.dropdown-item.active,
.dropdown-item:active {
    background-color: var(--brand);
}

.progress-bar {
    background-color: var(--accent);
}

.text-primary { color: var(--brand) !important; }
.bg-primary { background-color: var(--brand) !important; }
.border-primary { border-color: var(--brand) !important; }
.bg-info { background-color: var(--accent) !important; }
.text-info { color: var(--accent-dark) !important; }

a {
    color: var(--brand);
}

a:hover {
    color: var(--accent-dark);
}

h1, h2, h3, h4, h5, h6 {
    color: var(--brand);
}

.card h1, .card h2, .card h3, .card h4, .card h5, .card h6,
.modal h5, .modal h6 {
    color: inherit;
}

* {
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
}

html, body {
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
}

/* ---------- Layout shell ---------- */

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* القائمة الجانبية — فاتحة: أبيض مع لمسة تيل خفيفة، والنص كحلي */
.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: linear-gradient(180deg, #FFFFFF 0%, #F7FBFC 55%, #EEF8F7 100%);
    border-left: 1px solid var(--line);
    color: var(--ink);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar .brand {
    padding: 0 0 10px;
    border-bottom: 1px solid var(--line);
}

/* صورة الهوية «dashboard sidebar» أعلى القائمة */
.sidebar .brand-banner {
    display: block;
    width: 100%;
    height: auto;
}

.sidebar .brand-clinic {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 2px 14px 0;
    padding: 6px 10px;
    background: var(--brand-light);
    border-radius: 9px;
    color: var(--brand);
    font-size: 12.5px;
    font-weight: 700;
}

.sidebar .brand-clinic i {
    color: var(--accent);
}

.sidebar .nav-section {
    padding: 14px 18px 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    letter-spacing: .4px;
}

.sidebar a.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    margin: 1px 10px;
    color: var(--ink);
    text-decoration: none;
    font-size: 14.5px;
    border-radius: 10px;
    border-right: 3px solid transparent;
    transition: background .15s, color .15s;
}

.sidebar a.nav-item .ic {
    width: 20px;
    text-align: center;
    font-size: 16px;
    color: var(--muted);
}

.sidebar a.nav-item:hover {
    background: var(--brand-light);
    color: var(--brand);
}

.sidebar a.nav-item:hover .ic {
    color: var(--accent);
}

.sidebar a.nav-item.active {
    background: var(--brand-light);
    color: var(--brand);
    border-right-color: var(--accent);
    font-weight: 700;
}

.sidebar a.nav-item.active .ic {
    color: var(--accent);
}

.sidebar .sub-chip {
    background: #fff;
    border: 1px solid var(--line);
    color: var(--muted);
}

.sidebar .sub-chip .fw-bold {
    color: var(--brand);
}

.sidebar .sidebar-footer {
    margin-top: auto;
    padding: 14px 18px;
    border-top: 1px solid var(--line);
    font-size: 12.5px;
    color: var(--muted);
}

.sidebar .sidebar-footer .user-name {
    color: var(--brand);
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--line);
    padding: 12px 22px;
    display: flex;
    align-items: center;
    gap: 14px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar .page-title {
    font-size: 17px;
    font-weight: 700;
    margin: 0;
}

.content {
    padding: 22px;
    flex: 1;
}

/* ---------- Cards & stats ---------- */

.card {
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(15,23,42,.04);
}

.card-header {
    background: #fff;
    color: var(--brand);
    border-bottom: 1px solid var(--line);
    font-weight: 700;
    padding: 13px 16px;
    border-radius: 12px 12px 0 0 !important;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    height: 100%;
}

.stat-card .stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 21px;
    flex-shrink: 0;
}

.stat-card .stat-value {
    font-size: 24px;
    font-weight: 800;
    line-height: 1.1;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--muted);
}

.si-teal  { background: var(--brand-light); color: var(--accent-dark); }
.si-blue  { background: #DBEAFE; color: var(--info); }
.si-amber { background: #FEF3C7; color: #B45309; }
.si-rose  { background: #FEE2E2; color: var(--danger); }
.si-green { background: #DCFCE7; color: var(--success); }
.si-slate { background: var(--muted-bg); color: var(--brand); }

/* ---------- Tables ---------- */

.table {
    margin-bottom: 0;
}

.table > thead {
    background: var(--bg);
}

.table > thead th {
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
    text-transform: none;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
    padding: 11px 12px;
}

.table > tbody td {
    padding: 11px 12px;
    vertical-align: middle;
    border-color: #EEF2F6;
}

.table-hover > tbody > tr:hover > * {
    background-color: var(--brand-light);
}

.table-wrap {
    overflow-x: auto;
}

/* ---------- Buttons & forms ---------- */

.btn {
    border-radius: 9px;
    font-weight: 600;
    font-size: 14.5px;
}

.btn-brand {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.btn-brand:hover, .btn-brand:focus {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
    color: #fff;
}

.btn-sm {
    font-size: 13px;
    padding: 4px 10px;
}

.form-label {
    font-weight: 600;
    font-size: 13.5px;
    margin-bottom: 5px;
}

.form-control, .form-select {
    border-radius: 9px;
    border-color: var(--muted-bg);
    font-size: 14.5px;
    padding: 8px 12px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 181, 165, .16);
}

.required::after {
    content: " *";
    color: var(--danger);
}

/* ---------- Notifications ---------- */

.notif-btn {
    position: relative;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--muted);
    padding: 4px 8px;
}

.notif-badge {
    position: absolute;
    top: -2px;
    left: -2px;
    background: var(--danger);
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    padding: 0 4px;
}

.notif-dropdown {
    width: 340px;
    max-height: 420px;
    overflow-y: auto;
    padding: 0;
}

.notif-item {
    display: block;
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    text-decoration: none;
    color: var(--ink);
}

.notif-item:hover {
    background: #f8fafc;
}

.notif-item.unread {
    background: var(--brand-light);
    border-right: 3px solid var(--accent);
}

.notif-item .n-title {
    font-weight: 700;
    font-size: 13.5px;
}

.notif-item .n-msg {
    font-size: 13px;
    color: var(--muted);
}

.notif-item .n-time {
    font-size: 11.5px;
    color: #94a3b8;
}

.toast-stack {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ---------- Misc ---------- */

.badge {
    font-weight: 600;
    font-size: 12px;
    padding: 5px 9px;
    border-radius: 7px;
}

.empty-state {
    text-align: center;
    padding: 42px 20px;
    color: var(--muted);
}

.empty-state .es-icon {
    font-size: 42px;
    opacity: .35;
    margin-bottom: 10px;
}

.visit-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--line);
    cursor: pointer;
}

/* ---------- معاينة روشتة الطباعة داخل صفحة الزيارة — نفس تصميم صفحة الطباعة بالضبط ---------- */
.rx-preview-sheet {
    --rx-script-font: 'Caveat', 'Segoe Script', cursive;
    font-size: 12px;
}

.rx-preview-layout {
    display: flex;
    gap: 4mm;
}

.rx-preview-column {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.rx-preview-line {
    display: flex;
    flex-direction: column;
    padding: 2.5mm 0 3mm;
    border-bottom: 1px dotted var(--line);
}

.rx-preview-line:last-child {
    border-bottom: none;
}

/* يبدأ المتن من أقصى يسار البطاقة فعليًا (وليس ملاصقًا للفاصل الأوسط) */
.rx-preview-head {
    justify-content: flex-end;
}

.rx-preview-tag {
    font-family: var(--rx-script-font);
    color: var(--brand);
    font-weight: 700;
    font-size: 23px;
    flex-shrink: 0;
    line-height: 1;
}

.rx-preview-name {
    font-family: 'Times New Roman', Times, serif;
    font-size: 17px;
    font-weight: 700;
    color: var(--ink);
}

.rx-preview-sub {
    color: var(--muted);
    font-size: 11px;
    margin-top: 2px;
}

.rx-preview-sub-edit {
    display: flex;
    gap: 6px;
    margin-top: 3px;
}

.rx-sub-field {
    flex: 1;
    min-width: 0;
    border: none;
    border-bottom: 1px dotted #cbd5e1;
    background: transparent;
    font-size: 11px;
    padding: 1px 2px;
    color: #475569;
}

.rx-sub-field:focus {
    outline: none;
    border-bottom-color: var(--brand);
    background: #f8fafc;
}

/* حدود منطقية (inline-end) لا فعلية — يبقى الفاصل بين العمودين صحيحًا في RTL و LTR */
.rx-preview-sidebar {
    width: 34mm;
    flex-shrink: 0;
    border-inline-end: 1.25px solid var(--ink);
    padding-inline-end: 4mm;
    display: flex;
    flex-direction: column;
}

.rx-preview-sidebar-section {
    border-bottom: 1px solid var(--ink);
    padding: 0 0 3mm;
    margin-bottom: 3mm;
}

.rx-preview-sidebar-section:last-child {
    border-bottom: none;
    flex: 1;
    margin-bottom: 0;
}

.rx-preview-sidebar-title {
    font-weight: 800;
    font-size: 10.5px;
    margin-bottom: 2mm;
}

.rx-preview-checkbox-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 3mm;
}

.rx-preview-circle {
    width: 3.2mm;
    height: 3.2mm;
    border: 1.25px solid var(--ink);
    border-radius: 50%;
    flex-shrink: 0;
}

.rx-sidebar-input {
    width: 100%;
    border: none;
    border-bottom: 1px dotted #cbd5e1;
    background: transparent;
    font-size: 11px;
    font-family: 'Cairo', Tahoma, sans-serif;
    resize: none;
    padding: 1px 2px;
}

.rx-sidebar-input:focus {
    outline: none;
    border-bottom-color: var(--brand);
    background: #f8fafc;
}

.rx-preview-followup {
    margin-top: 4mm;
    padding-top: 3mm;
    border-top: 1px solid var(--line);
    font-size: 12px;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.rx-followup-value {
    font-variant-numeric: tabular-nums;
    direction: ltr;
    display: inline-block;
    border-bottom: 1px dotted #94a3b8;
    min-width: 28mm;
    padding: 0 4px;
}


.mono-num {
    font-variant-numeric: tabular-nums;
    direction: ltr;
    display: inline-block;
}

@media (max-width: 991px) {
    .sidebar {
        position: fixed;
        right: -250px;
        z-index: 1050;
        transition: right .25s;
    }

    .sidebar.open {
        right: 0;
    }

    .content {
        padding: 14px;
    }
}

@media print {
    .sidebar, .topbar, .no-print {
        display: none !important;
    }

    body {
        background: #fff;
    }

    .content {
        padding: 0;
    }
}
/* ---------- صفحة الدخول ----------
   على الشاشات الكبيرة: صورة الهوية (img/brand/login-bg.jpg) هي الخلفية بالكامل،
   والفورم الحقيقي يقع داخل الكارت المرسوم في الصورة بالظبط.
   الصورة 1600×900 والكارت الفارغ داخلها: x 948–1530 / y 198–714.
   على الشاشات الصغيرة: كارت عادي في المنتصف واللوجو فوقه. */

/* الموبايل والشاشات الصغيرة: نفس روح صورة الدخول —
   صورة العيادة متغبّشة + موجة تيل أعلى + موجة كحلي/تيل أسفل */
.login-page {
    min-height: 100vh;
    display: flex;
    position: relative;
    overflow: hidden;
    isolation: isolate;
    background: #F3F7FB;
}

.login-page::before {
    content: "";
    position: absolute;
    inset: -40px;
    background: url("../img/brand/login-bg.jpg") 22% center / cover no-repeat;
    filter: blur(18px) saturate(1.1);
    opacity: .55;
    z-index: -1;
}

.login-stage {
    flex: 1;
    display: flex;
    background:
        url("../img/brand/login-wave-top.svg") top left / 100% 150px no-repeat,
        url("../img/brand/login-wave-bottom.svg") bottom left / 100% 130px no-repeat;
}

.login-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 90px 18px 120px;
}

/* اللوجو بخلفية شفافة (logo-wide.png) */
.login-logo {
    width: 100%;
    max-width: 220px;
    margin-bottom: 14px;
    filter: drop-shadow(0 2px 6px rgba(255,255,255,.8));
}

.login-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 30px 24px 26px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 22px 50px rgba(5, 42, 79, .16);
    color: var(--ink);
    position: relative;
    overflow: hidden;
}

/* الركن التيل أعلى الكارت — مثل الكارت في صورة الدخول */
.login-card::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 120px;
    height: 46px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 46' preserveAspectRatio='none'%3E%3Cpath d='M0 0H120V46C110 18 70 3 0 0Z' fill='%230FB5A5'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
    pointer-events: none;
}

.login-card h1 {
    color: var(--brand);
}

.login-card label {
    color: var(--ink);
}

.login-card .text-muted {
    color: var(--muted) !important;
}

.login-card .form-control {
    background: #F4F7FA;
    border-color: var(--line);
    color: var(--ink);
    padding-top: 10px;
    padding-bottom: 10px;
}

.login-card .form-control::placeholder {
    color: #9AAAB8;
}

.login-card .form-control:focus {
    background: #fff;
}

.login-card .input-group-text {
    background: #F4F7FA;
    border-color: var(--line);
    color: var(--muted);
}

.login-card .btn-outline-secondary {
    border-color: var(--line);
    color: var(--muted);
    background: #F4F7FA;
}

.login-card .btn-outline-secondary:hover {
    background: var(--muted-bg);
    color: var(--brand);
}

.login-card .form-check-label {
    color: var(--ink);
}

.login-card .btn-brand {
    background: var(--brand);
    border: none;
    padding-top: 11px !important;
    padding-bottom: 11px !important;
    font-size: 16px;
}

.login-card .btn-brand:hover {
    background: var(--brand-dark);
}

.login-footer {
    margin-top: 18px;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
    background: rgba(255,255,255,.7);
    padding: 4px 12px;
    border-radius: 20px;
}

.login-footer .brand-ms {
    color: var(--accent);
    font-weight: 700;
}

/* الشاشات الكبيرة: الخلفية بالصورة كاملة */
@media (min-width: 1100px) and (min-height: 600px) {
    .login-page.login-photo {
        position: relative;
        height: 100vh;
        overflow: hidden;
        background: #F3F7FB;
    }

    .login-page.login-photo::before {
        display: none;
    }

    /* مسرح بنسبة 16:9 يغطي الشاشة (مثل background-size: cover)
       ومثبَّت يمين الشاشة حتى يظل الكارت ظاهرًا كاملًا */
    .login-photo .login-stage {
        position: absolute;
        top: 50%;
        right: 0;
        transform: translateY(-50%);
        width: max(100vw, 177.7778vh);
        height: max(100vh, 56.25vw);
        background: url("../img/brand/login-bg.jpg") 0 0 / 100% 100% no-repeat;
    }

    /* الكارت الحقيقي (أصغر من الكارت الأصلي في الصورة) في نفس مكانه:
       مركز الكارت الأصلي في الصورة x 1238 / y 448 من 1600×900 */
    .login-photo .login-panel {
        position: absolute;
        left: 77.4%;
        top: 49.8%;
        transform: translate(-50%, -50%);
        width: clamp(380px, 26.5%, 460px);
        padding: 0;
        align-items: stretch;
    }

    /* أضيق شوية وأطول شوية */
    .login-photo .login-card {
        max-width: none;
        padding: 46px 30px 32px;
    }

    .login-photo .login-card .text-center.mb-4 {
        margin-bottom: 30px !important;
    }

    .login-photo .login-card .mb-3 {
        margin-bottom: 20px !important;
    }

    .login-photo .login-card .btn-brand {
        margin-top: 6px;
    }

    .login-photo .login-logo,
    .login-photo .login-footer {
        display: none;
    }
}

/* سطر «CLIVO | MS v1.0» أسفل الكارت كما في التصميم */
.login-version {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 22px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    direction: ltr;
}

.login-version::before,
.login-version::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
}

.login-version .brand-ms {
    color: var(--accent);
}
