:root {
    --primary: #315d69;
    --primary-dark: #244650;
    --secondary: #8ba7a8;
    --accent: #c9a86a;
    --navy: #1d3440;
    --background: #f5f8f8;
    --surface: #ffffff;
    --soft: #edf3f2;
    --border: #dce7e6;
    --text: #1e3037;
    --muted: #6f8187;
    --danger: #a94f55;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    font-family: 'Cairo', sans-serif;
    color: var(--text);
    background: var(--background);
}

a {
    text-decoration: none;
}

.main-header {
    position: sticky;
    top: 0;
    z-index: 1030;
    width: 100%;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.navbar-brand strong {
    display: block;
    color: var(--navy);
    font-size: 1rem;
}

.navbar-brand small {
    font-size: 0.76rem;
}

.brand-logo {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    color: #ffffff;
    font-size: 1.3rem;
    background: linear-gradient(135deg,
            var(--primary),
            var(--secondary));
    box-shadow: 0 10px 25px rgba(49, 93, 105, 0.2);
}

.nav-link {
    color: #3d5158;
    font-weight: 600;
}

.nav-link:hover {
    color: var(--primary);
}

.emergency-link {
    color: var(--danger);
}

.btn {
    border-radius: 12px;
    font-weight: 700;
}

.btn-primary {
    color: #ffffff;
    background: var(--primary);
    border-color: var(--primary);
}

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

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    color: #ffffff;
    background: var(--primary);
    border-color: var(--primary);
}

.btn-outline-danger {
    color: var(--danger);
    border-color: var(--danger);
}

.hero-section {
    position: relative;
    overflow: hidden;
    padding: 92px 0;
    background:
        radial-gradient(circle at 15% 20%,
            rgba(201, 168, 106, 0.17),
            transparent 32%),
        linear-gradient(135deg,
            #f9fbfb 0%,
            #eaf2f1 100%);
}

.hero-section::after {
    content: '';
    position: absolute;
    left: -90px;
    bottom: -100px;
    width: 280px;
    height: 280px;
    border: 45px solid rgba(49, 93, 105, 0.06);
    border-radius: 50%;
}

.hero-badge {
    display: inline-flex;
    margin-bottom: 18px;
    padding: 9px 16px;
    border: 1px solid rgba(49, 93, 105, 0.15);
    border-radius: 999px;
    color: var(--primary-dark);
    background: rgba(255, 255, 255, 0.72);
    font-size: 0.9rem;
    font-weight: 700;
}

.hero-section h1 {
    max-width: 760px;
    margin-bottom: 22px;
    font-size: clamp(2.4rem, 5vw, 4.5rem);
    font-weight: 800;
    line-height: 1.25;
}

.hero-section h1 span {
    color: var(--primary);
}

.hero-section p {
    max-width: 680px;
    color: var(--muted);
    font-size: 1.15rem;
    line-height: 2;
}

.hero-visual {
    position: relative;
    padding: 44px 30px;
    text-align: center;
    border: 1px solid rgba(49, 93, 105, 0.12);
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 28px 80px rgba(29, 52, 64, 0.12);
}

.dental-chair {
    width: 150px;
    height: 150px;
    margin: 0 auto 25px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #ffffff;
    font-size: 4.5rem;
    background: linear-gradient(145deg,
            var(--primary),
            var(--secondary));
    box-shadow: 0 25px 50px rgba(49, 93, 105, 0.22);
}

.hero-visual h3 {
    margin-bottom: 6px;
    font-weight: 800;
}

.hero-visual p {
    margin: 0 auto;
    font-size: 1rem;
}

.section-space {
    padding: 78px 0;
}

.soft-section {
    background: var(--soft);
}

.section-heading {
    max-width: 680px;
    margin: 0 auto 45px;
    text-align: center;
}

.section-heading.text-start {
    margin-right: 0;
    text-align: right !important;
}

.section-heading>span,
.dashboard-heading>span {
    color: var(--primary);
    font-size: 0.92rem;
    font-weight: 800;
}

.section-heading h2,
.section-heading h1,
.dashboard-heading h1 {
    margin: 10px 0;
    font-weight: 800;
}

.section-heading p {
    color: var(--muted);
    line-height: 1.9;
}

.service-card,
.feature-card,
.page-card,
.dashboard-card,
.registration-card {
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: 0 14px 42px rgba(29, 52, 64, 0.06);
}

.service-card {
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.service-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 22px 52px rgba(29, 52, 64, 0.1);
}

.service-icon,
.page-icon {
    width: 56px;
    height: 56px;
    margin-bottom: 20px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    color: var(--primary);
    background: var(--soft);
    font-size: 1.45rem;
}

.service-card h4,
.feature-card h4 {
    font-weight: 800;
}

.service-card p,
.feature-card p,
.page-card p,
.dashboard-card p {
    color: var(--muted);
    line-height: 1.85;
}

.duration {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 8px;
    padding: 7px 11px;
    border-radius: 10px;
    color: var(--primary-dark);
    background: var(--soft);
    font-size: 0.88rem;
    font-weight: 700;
}

.feature-card {
    height: 100%;
    text-align: center;
}

.feature-card>i {
    display: block;
    margin-bottom: 16px;
    color: var(--accent);
    font-size: 2rem;
}

.page-card {
    max-width: 900px;
    margin: auto;
}

.site-footer {
    margin-top: auto;
    color: #ffffff;
    background: var(--navy);
}

.site-footer a {
    display: block;
    margin-bottom: 9px;
    color: #dce6e8;
}

.site-footer a:hover {
    color: #ffffff;
}

.auth-section {
    min-height: calc(100vh - 140px);
    padding: 60px 0;
    display: grid;
    place-items: center;
    background:
        linear-gradient(135deg,
            #eef4f3,
            #f9fbfb);
}

.auth-box {
    max-width: 980px;
    margin: auto;
    display: grid;
    grid-template-columns: 0.9fr 1.1fr;
    overflow: hidden;
    border-radius: 28px;
    background: #ffffff;
    box-shadow: 0 28px 90px rgba(29, 52, 64, 0.14);
}

.auth-information {
    padding: 52px;
    color: #ffffff;
    background:
        linear-gradient(145deg,
            var(--navy),
            var(--primary));
}

.auth-icon {
    display: inline-grid;
    place-items: center;
    width: 76px;
    height: 76px;
    margin-bottom: 28px;
    border-radius: 22px;
    color: var(--accent);
    background: rgba(255, 255, 255, 0.09);
    font-size: 2.2rem;
}

.auth-information h2 {
    font-weight: 800;
}

.auth-information p {
    color: rgba(255, 255, 255, 0.75);
    line-height: 1.9;
}

.auth-form {
    padding: 52px;
}

.auth-form h1 {
    margin-bottom: 28px;
    font-weight: 800;
}

.registration-card {
    max-width: 900px;
    margin: auto;
}

.form-control,
.form-select {
    min-height: 50px;
    border-color: #d5e1e0;
    border-radius: 12px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.22rem rgba(49, 93, 105, 0.12);
}

.dashboard-layout {
    display: flex;
    min-height: calc(100vh - 80px);
}

.sidebar {
    width: 280px;
    flex-shrink: 0;
    padding: 24px 16px;
    color: #ffffff;
    background: linear-gradient(180deg, var(--navy) 0%, #172a33 100%);
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.1);
    z-index: 10;
    position: sticky;
    top: 85px;
    height: calc(100vh - 85px);
    overflow-y: auto;
}

.sidebar::-webkit-scrollbar {
    width: 5px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.sidebar-heading {
    margin-bottom: 30px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-heading strong {
    display: block;
    font-size: 1.1rem;
    color: #ffffff;
}

.sidebar-heading small {
    display: block;
    margin-top: 2px;
    color: #8ba7a8;
    font-size: 0.85rem;
}

.sidebar-icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    color: #ffffff;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    box-shadow: 0 4px 12px rgba(49, 93, 105, 0.25);
}

.sidebar-menu {
    display: grid;
    gap: 6px;
}

.sidebar-menu a {
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-radius: 14px;
    color: #b9c9cd;
    font-weight: 600;
    transition: all 0.3s ease;
}

.sidebar-menu a i {
    font-size: 1.25rem;
    transition: transform 0.3s ease;
}

.sidebar-menu a:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(-4px);
}

.sidebar-menu a:hover i {
    color: var(--accent);
    transform: scale(1.15);
}

.sidebar-menu .logout-link {
    margin-top: 20px;
    color: #f28b82;
    background: rgba(242, 139, 130, 0.08);
}

.sidebar-menu .logout-link:hover {
    background: rgba(242, 139, 130, 0.18);
    color: #ffb4ab;
}

.dashboard-content {
    flex: 1;
    min-width: 0;
    padding: 20px;
}

.dashboard-heading {
    margin-bottom: 25px;
}

@media (max-width: 991px) {
    .auth-box {
        grid-template-columns: 1fr;
    }

    .auth-information {
        display: none;
    }

    .dashboard-layout {
        display: block;
    }

    .sidebar {
        width: 100%;
    }

    .hero-section {
        padding: 65px 0;
    }
}

@media (max-width: 575px) {
    .auth-form {
        padding: 30px 22px;
    }

    .dashboard-content {
        padding: 22px;
    }

    .hero-visual {
        padding: 32px 20px;
    }
}

/* =========================================================
   تنسيقات الجداول الخاصة بلوحة التحكم (نفس التصميم المطلوب)
========================================================= */

.dashboard-content .table {
    border-collapse: separate !important;
    border-spacing: 0 !important;
    width: 100% !important;
    background: #ffffff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 25px;
    border: 1px solid var(--border);
}

.dashboard-content .table thead th {
    background-color: var(--navy) !important;
    color: #ffffff !important;
    font-weight: 700;
    padding: 16px;
    text-align: center;
    border: none;
    white-space: nowrap;
    border-bottom: 3px solid var(--primary);
    font-size: 0.95rem;
}

.dashboard-content .table tbody td {
    padding: 14px 16px;
    vertical-align: middle;
    text-align: center;
    border-bottom: 1px solid #edf0f2;
    color: var(--text);
    font-weight: 600;
    font-size: 0.9rem;
}

.dashboard-content .table tbody tr:last-child td {
    border-bottom: none;
}

.dashboard-content .table tbody tr:hover td {
    background-color: rgba(49, 93, 105, 0.04);
}

/* =========================================================
   تنسيقات الأزرار في لوحة التحكم (أزرار واضحة)
========================================================= */

.dashboard-content .btn-sm {
    border-radius: 8px !important;
    font-weight: bold;
    padding: 6px 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.dashboard-content .btn-sm i {
    font-size: 1.1rem;
}

.dashboard-content .btn-sm:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}

/* تنسيقات الأزرار الشفافة بخطوط ملونة (Outline) مثل الصورة */
.dashboard-content .btn-outline-primary {
    color: var(--primary);
    border: 2px solid var(--primary);
}

.dashboard-content .btn-outline-danger {
    color: var(--danger);
    border: 2px solid var(--danger);
}

.dashboard-content .btn-outline-success {
    color: #198754;
    border: 2px solid #198754;
}

.dashboard-content .btn-outline-warning {
    color: #ffc107;
    border: 2px solid #ffc107;
}

/* شريط الإجراءات العلوي في لوحة التحكم */
.dashboard-content .card-header {
    background: #ffffff;
    border-bottom: 1px solid #edf0f2;
    padding: 18px 24px;
    border-radius: 12px 12px 0 0 !important;
}

/* =========================================================
   تعديلات الهيكل المطلوبة: جعل الجانبية تمتد للأعلى بالكامل
   والرأسية داكنة وتكون بجانب القائمة وليس فوقها!
========================================================= */

body[data-notification-role="admin"],
body[data-notification-role="patient"] {
    background-color: #f4f7f6;
}

/* جعل القائمة العلوية متجاورة مع الجانبية وملونة بنفس اللون - معطلة الآن لأن الشق العام مفصول */
body.dashboard-layout .main-header {
    position: fixed !important;
    top: 0;
    left: 0;
    width: calc(100% - 280px) !important;
    margin: 0 !important;
    background: #1d3440 !important;
    /* لون موحد مع الجانبية */
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 1040;
    height: 76px;
}

body.dashboard-layout .main-header .navbar {
    height: 100%;
}

body.dashboard-layout .main-header .navbar-brand strong,
body.dashboard-layout .main-header .nav-link {
    color: #ffffff !important;
}

body.dashboard-layout .main-header .navbar-brand small {
    color: #8ba7a8 !important;
}

body.dashboard-layout .main-header .nav-link:hover {
    color: var(--accent) !important;
}

body.dashboard-layout .main-header .nav-link.active {
    border-bottom-color: var(--accent) !important;
    color: var(--accent) !important;
}

/* الجانبية ممتدة من أعلى لأسفل ومثبتة في اليمين ونفس اللون  */
body[data-notification-role="admin"] .sidebar,
body[data-notification-role="patient"] .sidebar {
    position: fixed !important;
    top: 0;
    right: 0;
    width: 280px !important;
    height: 100vh !important;
    margin: 0 !important;
    background: #1d3440 !important;
    /* نفس اللون */
    z-index: 1050;
    border-radius: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.02);
    transition: transform 0.3s ease-in-out !important;
}

/* إزاحة قسم المحتوى ليكون بجانب الجانبية وتحت الهيدر الثابت */
body[data-notification-role="admin"] .dashboard-layout,
body[data-notification-role="patient"] .dashboard-layout {
    display: block !important;
    padding-right: 280px !important;
    padding-top: 76px !important;
    /* مساحة الهيدر لكي لا يختبئ المحتوى */
}

/* تنسيق أزرار الهيدر */
body[data-notification-role="admin"] .main-header .btn-outline-primary,
body[data-notification-role="patient"] .main-header .btn-outline-primary {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2);
}

body[data-notification-role="admin"] .main-header .btn-outline-primary:hover,
body[data-notification-role="patient"] .main-header .btn-outline-primary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* استجابة الجوال */
@media (max-width: 991px) {

    body[data-notification-role="admin"] .sidebar,
    body[data-notification-role="patient"] .sidebar {
        transform: translateX(100%);
    }

    body[data-notification-role="admin"] .sidebar.show,
    body[data-notification-role="patient"] .sidebar.show {
        transform: translateX(0);
        box-shadow: -10px 0 35px rgba(0, 0, 0, 0.5);
    }

    body[data-notification-role="admin"] .dashboard-layout,
    body[data-notification-role="patient"] .dashboard-layout {
        padding-right: 0 !important;
        padding-top: 0 !important;
    }
}

/* =========================================================
   تحسين النوافذ المنبثقة (SaaS Modals)
   ========================================================= */

.modal-content {
    border: none;
    border-radius: 16px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.modal-header {
    background: linear-gradient(135deg, #1d3440, #2b4d5e);
    color: #fff;
    border-bottom: none;
    padding: 18px 24px;
}

.modal-header h1.modal-title,
.modal-header h5.modal-title,
.modal-header .modal-title {
    font-weight: 700;
    font-size: 1.25rem !important;
    margin: 0;
}

/* جعل زر الإغلاق أبيض ليتناسب مع الخلفية الغامقة */
.modal-header .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
    opacity: 0.8;
}

.modal-header .btn-close:hover {
    opacity: 1;
}

.modal-body {
    padding: 24px;
    background-color: #f8fbfc;
}

.modal-body label,
.modal-body .form-label {
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.modal-body .form-control,
.modal-body .form-select {
    border: 1px solid #d1d9e6;
    border-radius: 10px;
    padding: 10px 14px;
    background-color: #fff;
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

.modal-body .form-control:focus,
.modal-body .form-select:focus {
    border-color: #0b5ed7;
    box-shadow: 0 0 0 4px rgba(11, 94, 215, 0.15);
    background-color: #fff;
}

.modal-footer {
    border-top: 1px solid #eef2f6;
    padding: 16px 24px;
    background-color: #fff;
}

.modal-footer .btn {
    padding: 8px 20px;
    border-radius: 8px;
    font-weight: 600;
}

/* =========================================================
   أيقونات التواصل الاجتماعي في الفوتر (Social Icons)
   ========================================================= */

.social-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    color: #fff !important;
    text-decoration: none;
    font-size: 1.4rem;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.social-circle:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    color: #fff !important;
}

.sc-facebook {
    background-color: #1877F2;
}

.sc-tiktok {
    background-color: #000000;
}

.sc-instagram {
    background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%, #d6249f 60%, #285AEB 90%);
}

.sc-twitter {
    background-color: #14171A;
}

.sc-snapchat {
    background-color: #FFFC00;
    color: #000 !important;
}

/* زر الواتساب العائم */
.floating-whatsapp {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 65px;
    height: 65px;
    background-color: #25D366;
    color: #fff !important;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    box-shadow: 0 8px 25px rgba(37, 211, 102, 0.5);
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.floating-whatsapp:hover {
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 12px 30px rgba(37, 211, 102, 0.6);
}
/* عندما تكون الشاشة أصغر من 600 بكسل */
@media (max-width: 600px) {
  
  /* 1. جعل الهيدر عمودي بدلاً من أفقي */
  #header .nav-container {
    flex-direction: column; 
    gap: 15px; /* مسافة بسيطة بين اللوجو والروابط */
    text-align: center;
  }

  /* 2. تقليل المسافات الكبيرة بين أقسام الموقع */
  section {
    padding: 50px 0 !important; /* تقليل الـ 100px التي وضعتها سابقاً */
  }

  /* 3. تصغير حجم العناوين لكي لا تنكسر */
  h1 {
    font-size: 28px !important;
  }
  
  h2 {
    font-size: 24px !important;
  }

  /* 4. التأكد من أن الصور لا تخرج عن الشاشة */
  img {
    max-width: 100%;
    height: auto;
  }
}

/* =========================================================
   اسم المريض العربي + زر إظهار/إخفاء كلمة المرور
   ========================================================= */

input[data-arabic-name="true"] {
    direction: rtl;
    text-align: right;
}

.password-visibility-wrap {
    position: relative;
    width: 100%;
}

.password-visibility-wrap > input {
    padding-left: 48px !important;
}

.password-visibility-toggle {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #667085;
    cursor: pointer;
    z-index: 5;
    transition: background-color .2s ease, color .2s ease;
}

.password-visibility-toggle:hover,
.password-visibility-toggle:focus-visible {
    background: rgba(11, 94, 215, 0.08);
    color: #0b5ed7;
    outline: none;
}

.password-visibility-toggle i {
    font-size: 1.05rem;
    line-height: 1;
}

/* إبقاء رسائل Bootstrap الخاصة بكلمة المرور ظاهرة بعد إضافة غلاف زر العين */
.was-validated .password-visibility-wrap:has(input:invalid) + .invalid-feedback,
.password-visibility-wrap:has(input.is-invalid) + .invalid-feedback {
    display: block;
}

/* =========================================================
   FINAL RESPONSIVE PATCH - Mobile + Tablet
   مدمج داخل style.css للنسخة النهائية
   ========================================================= */

/* منع أي عنصر عام من توسيع الصفحة خارج الشاشة */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

img,
video,
iframe,
svg {
    max-width: 100%;
}

img,
video {
    height: auto;
}

.container,
.container-fluid,
.dashboard-content,
.card,
.card-body,
.card-header,
.modal-content {
    min-width: 0;
    max-width: 100%;
}

/* الجداول: تبقى مرتبة وتتحرك أفقيًا بدل ضغط الأعمدة */
.table-responsive,
.table-wrapper,
.table-container {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto !important;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.table-responsive::-webkit-scrollbar,
.table-wrapper::-webkit-scrollbar,
.table-container::-webkit-scrollbar {
    height: 7px;
}

.table-responsive::-webkit-scrollbar-thumb,
.table-wrapper::-webkit-scrollbar-thumb,
.table-container::-webkit-scrollbar-thumb {
    background: rgba(49, 93, 105, 0.35);
    border-radius: 999px;
}

.table-responsive > table,
.table-wrapper > table,
.table-container > table {
    margin-bottom: 0;
}

.dashboard-content table th,
.dashboard-content table td {
    vertical-align: middle !important;
}

.dashboard-content table th {
    white-space: nowrap;
}

.dashboard-content table .btn,
.dashboard-content table .badge {
    white-space: nowrap;
}

.action-buttons,
.table-actions,
.actions {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 5px;
}

/* الحقول والنوافذ لا تتجاوز الشاشة */
input,
select,
textarea,
.form-control,
.form-select,
.input-group {
    max-width: 100%;
}

.modal-dialog {
    width: auto;
    max-width: 95vw;
    margin-left: auto;
    margin-right: auto;
}

.modal-body {
    overflow-x: hidden;
}

/* النصوص الطويلة مثل الأكواد وأسماء الملفات */
.alert,
.card-body,
.modal-body,
.text-break,
.filename,
.file-name {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* =========================================================
   Tablet + Mobile
   ========================================================= */
@media (max-width: 991.98px) {
    .container,
    .container-fluid {
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 14px !important;
        padding-right: 14px !important;
    }

    .dashboard-content {
        width: 100%;
        padding: 16px !important;
    }

    /* القائمة الجانبية تبقى Off-canvas ولا تحجز عرض الصفحة */
    body[data-notification-role="admin"] .dashboard-layout,
    body[data-notification-role="patient"] .dashboard-layout {
        width: 100% !important;
        max-width: 100% !important;
        padding-right: 0 !important;
    }

    body[data-notification-role="admin"] .sidebar,
    body[data-notification-role="patient"] .sidebar {
        width: min(300px, 86vw) !important;
        max-width: 86vw !important;
    }

    .dashboard-content .table-responsive > table.table,
    .dashboard-content .table-wrapper > table.table,
    .dashboard-content .table-container > table.table {
        width: 100% !important;
        min-width: 860px !important;
    }

    .dashboard-content .card-header {
        padding: 14px 16px;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.3rem;
    }

    .modal-dialog {
        max-width: calc(100vw - 24px);
        margin: 12px auto;
    }
}

/* =========================================================
   Mobile
   ========================================================= */
@media (max-width: 767.98px) {
    body {
        font-size: 14px;
    }

    .container,
    .container-fluid {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    .dashboard-content {
        padding: 10px !important;
    }

    .dashboard-heading,
    .dashboard-content .d-flex.justify-content-between,
    .dashboard-content .d-flex.justify-content-between.align-items-center,
    .dashboard-content .d-flex.justify-content-between.align-items-center.mb-4 {
        flex-wrap: wrap;
        gap: 10px;
    }

    .card {
        width: 100%;
        max-width: 100%;
        border-radius: 12px;
    }

    .card-header,
    .dashboard-content .card-header {
        padding: 12px !important;
    }

    .card-body {
        padding: 12px;
    }

    /* زر حذف المحدد والعناصر المشابهة لا تتراكب مع عنوان البطاقة */
    .card-header .float-end,
    .card-header .float-start {
        float: none !important;
        margin-top: 8px;
        margin-inline-start: 0 !important;
    }

    .card-header:has(.float-end),
    .card-header:has(.float-start) {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 8px;
    }

    /* أهم إصلاح للصورة التي كان فيها تداخل جدول الحالات الطارئة */
    .dashboard-content .table-responsive,
    .dashboard-content .table-wrapper,
    .dashboard-content .table-container {
        width: 100%;
        max-width: 100%;
        overflow-x: auto !important;
        border-radius: 10px;
    }

    .dashboard-content .table-responsive > table.table,
    .dashboard-content .table-wrapper > table.table,
    .dashboard-content .table-container > table.table {
        width: 100% !important;
        min-width: 820px !important;
        table-layout: auto !important;
        font-size: 12.5px;
    }

    .dashboard-content .table thead th,
    .dashboard-content .table tbody td {
        padding: 9px 10px !important;
        line-height: 1.55;
    }

    .dashboard-content .table tbody td {
        white-space: normal;
        word-break: normal;
    }

    .dashboard-content .table tbody td:last-child,
    .dashboard-content .table thead th:last-child {
        min-width: 135px;
    }

    .dashboard-content .table .btn-sm {
        padding: 6px 9px;
        font-size: 0.76rem;
    }

    .action-buttons,
    .table-actions,
    .actions {
        min-width: 125px;
        flex-wrap: nowrap;
    }

    /* النماذج */
    .form-control,
    .form-select,
    input,
    select,
    textarea {
        font-size: 16px; /* يمنع تكبير Safari التلقائي */
    }

    .btn-group {
        flex-wrap: wrap;
    }

    .toolbar,
    .table-toolbar,
    .page-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .toolbar .btn,
    .table-toolbar .btn,
    .page-actions .btn {
        flex: 1 1 auto;
    }

    /* النافذة المنبثقة */
    .modal-dialog {
        width: calc(100vw - 16px);
        max-width: calc(100vw - 16px);
        margin: 8px auto;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding-left: 12px;
        padding-right: 12px;
    }

    .modal-footer {
        flex-wrap: wrap;
        gap: 8px;
    }

    .modal-footer .btn {
        margin: 0;
    }

    h1 {
        font-size: 1.5rem !important;
    }

    h2 {
        font-size: 1.3rem !important;
    }

    h3 {
        font-size: 1.15rem !important;
    }

    h4 {
        font-size: 1rem;
    }

    /* الموقع العام */
    .main-header .navbar {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .main-header .navbar-brand {
        max-width: calc(100% - 56px);
        gap: 8px !important;
    }

    .main-header .navbar-brand strong,
    .main-header .navbar-brand small {
        white-space: normal;
        line-height: 1.35;
    }

    .main-header .navbar-brand img {
        width: 44px !important;
        height: 44px !important;
        flex: 0 0 44px;
    }

    .floating-whatsapp {
        width: 54px;
        height: 54px;
        right: 16px;
        bottom: 18px;
        font-size: 1.8rem;
    }
}

/* =========================================================
   Small Mobile
   ========================================================= */
@media (max-width: 575.98px) {
    .container,
    .container-fluid {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

    .dashboard-content {
        padding: 8px !important;
    }

    .card-header,
    .card-body {
        padding: 10px !important;
    }

    .dashboard-content .table-responsive > table.table,
    .dashboard-content .table-wrapper > table.table,
    .dashboard-content .table-container > table.table {
        min-width: 780px !important;
        font-size: 12px;
    }

    .dashboard-content .btn-sm,
    .btn.btn-sm {
        font-size: 12px;
    }

    .modal-dialog {
        width: calc(100vw - 10px);
        max-width: calc(100vw - 10px);
        margin: 5px auto;
    }

    .password-visibility-wrap > input {
        padding-left: 44px !important;
    }

    .password-visibility-toggle {
        left: 5px;
        width: 34px;
        height: 34px;
    }
}

/* Admin notifications: prevent long text from breaking mobile layout */
#notificationsList .notification-item,
#notificationsList .notification-item .card-body,
#notificationsList .notification-item .row,
#notificationsList .notification-item .col {
    min-width: 0;
}
#notificationsList .notification-item h5,
#notificationsList .notification-item p,
#notificationsList .notification-item .text-muted,
#notificationsList .notification-item .notification-text {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}
@media (max-width: 575.98px) {
    #notificationsList .notification-item .card-body { padding: 12px; }
    #notificationsList .notification-item .row { --bs-gutter-x: .55rem; }
    #notificationsList .notification-item .col { flex: 1 1 0; width: calc(100% - 74px); }
    #notificationsList .notification-item h5 { font-size: .95rem; line-height: 1.55; }
    #notificationsList .notification-item p { font-size: .88rem; line-height: 1.75; }
    .notification-filter { flex: 1 1 calc(50% - 8px); white-space: normal; }
}


/* ================================================================
   Admin notifications - stable mobile/iPhone layout
   ================================================================ */
.admin-notifications-list,
.admin-notification-item,
.admin-notification-row,
.admin-notification-content,
.admin-notification-text,
.admin-notification-side {
    min-width: 0;
}

.admin-notification-icon {
    width: 48px;
    height: 48px;
}

.admin-notification-title,
.admin-notification-body,
.admin-notification-time {
    max-width: 100%;
    white-space: normal !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
}

.admin-notification-body {
    line-height: 1.8;
}

.admin-notification-actions .btn {
    white-space: nowrap;
}

@media (max-width: 575.98px) {
    .admin-notifications-list {
        border-radius: 14px;
    }

    .admin-notification-item {
        padding: 12px 10px !important;
    }

    .admin-notification-row {
        display: grid !important;
        grid-template-columns: 24px 40px minmax(0, 1fr);
        gap: 8px !important;
        align-items: start !important;
    }

    .admin-notification-check {
        grid-column: 1;
        margin-top: 6px !important;
    }

    .admin-notification-icon {
        grid-column: 2;
        width: 40px;
        height: 40px;
    }

    .admin-notification-content {
        grid-column: 3;
        width: 100% !important;
        max-width: 100% !important;
    }

    .admin-notification-title {
        font-size: .95rem;
        line-height: 1.55;
    }

    .admin-notification-body {
        font-size: .88rem;
        line-height: 1.75;
        margin-top: 7px !important;
    }

    .admin-notification-side {
        width: 100%;
        text-align: right !important;
        margin-top: 2px;
    }

    .admin-notification-time {
        line-height: 1.55;
    }

    .admin-notification-actions {
        width: 100%;
        justify-content: stretch !important;
    }

    .admin-notification-actions .btn {
        flex: 1 1 105px;
    }

    .admin-notification-read {
        width: 100%;
        padding: 3px 0;
    }
}
