:root {
    --sidebar-width: 250px;
    --primary-color: #1a5f7a;
    --primary-light: #e8f4fc;
    --secondary-color: #159895;
    --accent-color: #57c5b6;
    --success-color: #2ecc71;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --light-bg: #f8f9fa;
    --border-color: #e9ecef;
    --text-primary: #2c3e50;
    --text-secondary: #6c757d;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --gradient-primary: linear-gradient(135deg, #1a5f7a 0%, #159895 100%);
    --gradient-accent: linear-gradient(135deg, #57c5b6 0%, #2ecc71 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Inter", "Segoe UI", sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f8ff 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    font-size: 14px;
    padding-top: 70px;
}

/* تحسين الشريط العلوي */
.top-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    padding: 0 20px;
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    width: 40px;
    height: 40px;
    background: var(--gradient-primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    box-shadow: 0 3px 8px rgba(26, 95, 122, 0.3);
}

.brand-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.lab-name {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
    font-weight: 500;
}

/* تصميم التبويبات الرئيسية */
.tabs-container {
    background: white;
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    margin: 20px auto;
    max-width: 1400px;
    overflow: visible; /* 🔥 الحل */
    border: 1px solid rgba(0, 0, 0, 0.05);
    padding: 40px;
    padding-bottom: 80px;
}

.tabs-header {
    display: flex;
    background: white;
    border-bottom: 2px solid var(--light-bg);
    padding: 0 20px;
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs-header::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    padding: 18px 28px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.tab-btn i {
    font-size: 16px;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    color: var(--primary-color);
}

.tab-btn:hover i {
    transform: translateY(-2px);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--accent-color);
    background: linear-gradient(
        to bottom,
        rgba(87, 197, 182, 0.05),
        transparent
    );
}

.tab-btn.active i {
    color: var(--accent-color);
}

.tab-indicator {
    position: absolute;
    bottom: -3px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-accent);
    border-radius: 3px 3px 0 0;
    transition: all 0.3s ease;
}

.tab-content {
    /* padding: 30px; */
    display: none;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tab-content.active {
    display: block;
}

/* تصميم محتوى التبويب الأول */
.tab1-content {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

@media (max-width: 992px) {
    .tab1-content {
        grid-template-columns: 1fr;
    }
}

.form-card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
    /* transition: transform 0.3s ease, box-shadow 0.3s ease; */
}

.card-header {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f8ff 100%);
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.card-header i {
    color: var(--primary-color);
    font-size: 18px;
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

.card-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.card-body {
    padding: 25px;
}

/* تحسين حقول النموذج */
.form-group {
    margin-bottom: 22px;
}

.form-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-label.required::after {
    content: "*";
    color: var(--danger-color);
    margin-left: 4px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    font-family: "Inter", sans-serif;
    transition: all 0.3s ease;
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px rgba(87, 197, 182, 0.15);
}

/* تحسين حقول التاريخ */
.date-input-wrapper {
    position: relative;
}

.date-input-wrapper i {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--accent-color);
    font-size: 16px;
    pointer-events: none;
}

.date-input-wrapper input[type="date"] {
    padding-left: 16px;
    padding-right: 50px;
    height: 48px;
    background: white;
    cursor: pointer;
}

.date-input-wrapper input[type="date"]::-webkit-calendar-picker-indicator {
    background: transparent;
    position: absolute;
    right: 10px;
    width: 24px;
    height: 24px;
    cursor: pointer;
}

.image-upload-container:hover {
    border-color: var(--accent-color);
    background: #f8f9fa;
}

.image-upload-container i {
    font-size: 48px;
    color: var(--accent-color);
    margin-bottom: 15px;
}

.image-upload-container h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.image-upload-container p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 15px;
}

.upload-btn {
    display: inline-block;
    background: var(--gradient-primary);
    color: white;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(26, 95, 122, 0.3);
}

.image-preview {
    display: none;
    margin-top: 20px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.image-preview img {
    width: 100%;
    height: auto;
    display: block;
}

/* تصميم محتوى التبويب الثاني - المحررات */
.tab2-content {
    background: white;
    border-radius: 12px;
    padding-bottom: 20px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* تحسين محررات Quill مع الحفاظ على الحجم المطلوب */
.editor-section {
    margin-bottom: 25px;
    border-bottom: 1px solid var(--border-color);
    background-color: white;
    padding-bottom: 25px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);

}

.editor-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    padding: 15px 20px;
    background: linear-gradient(to right, #f8fafc, #f1f8ff);
    border-radius: 10px;
}

.editor-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.editor-icon {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: 16px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

.editor-title-text h4 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 3px;
}

.editor-title-text p {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0;
}

.editor-actions {
    display: flex;
    gap: 10px;
}

.editor-btn {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: "Inter", sans-serif;
}

.editor-btn:hover {
    background: #f8f9fa;
    color: var(--primary-color);
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

/* تعديل حجم محررات Quill كما هو مطلوب */
.editor-container {
    padding: 0 20px;
}

.ql-container {
    min-height: 50px !important;
    max-height: 80px !important;
    transition: all 0.3s ease !important;
    border-radius: 0 0 10px 10px !important;
    border: 2px solid var(--border-color) !important;
    border-top: none !important;
    max-height: 400px !important;
}

.ql-toolbar {
    border-radius: 10px 10px 0 0 !important;
    border: 2px solid var(--border-color) !important;
    background: #f8f9fa !important;
    padding: 10px !important;
}

.ql-editor {
    min-height: 50px !important;
    max-height: 80px !important;
    overflow-y: hidden !important;
    transition: all 0.3s ease !important;
    padding: 12px 15px !important;
    font-size: 14px !important;
    font-family: "Inter", sans-serif !important;
    max-height: 400px !important;
    overflow-y: auto !important;
}

.ql-container:hover,
.ql-container:focus-within {
    max-height: 400px !important;
}

.ql-editor:hover,
.ql-editor:focus {
    max-height: 400px !important;
    overflow-y: auto !important;
}

/* تحديد خاص لكل محرر */
#clinical-editor .ql-container:focus-within,
#clinical-editor .ql-container:hover {
    max-height: 300px !important;
}

#gross-editor .ql-container:focus-within,
#gross-editor .ql-container:hover {
    max-height: 350px !important;
}

#microscopic-editor .ql-container:focus-within,
#microscopic-editor .ql-container:hover {
    max-height: 500px !important;
}

#diagnosis-editor .ql-container:focus-within,
#diagnosis-editor .ql-container:hover {
    max-height: 200px !important;
}

/* عداد الكلمات */
.word-counter {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding: 10px 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.word-count {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.word-count .count {
    font-weight: 700;
    color: var(--primary-color);
    background: white;
    padding: 2px 10px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.helper-hint {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* شريط الإجراءات السفلي */
.action-bar {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width);
    right: 0;
    background: white;
    border-top: 1px solid var(--border-color);
    padding: 10px 20px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.action-bar-left {
    display: flex;
    gap: 12px;
}

.action-bar-right {
    display: flex;
    gap: 15px;
}

.btn {
    padding: 10px 22px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: bold;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    font-family: "Inter", sans-serif;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-outline:hover {
    background: #f8f9fa;
    color: var(--text-primary);
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

.btn-cancel {
    /* background: transparent; */
    background-color: #ff1900;
    border: 2px solid var(--border-color);
    color: #000;
}

.btn-cancel:hover {
    background: #f8f9fa;
    color: var(--text-primary);
    border-color: var(--accent-color);
    transform: translateY(-3px);
}

.btn-primary {
    width: 100px;
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(26, 95, 122, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #159895 0%, #1a5f7a 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(26, 95, 122, 0.35);
}

.btn-success {
    width: 150px;
    padding: 5px 12px;
    text-align: center;
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: white;
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.25);
}

.btn-success:hover {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    transform: translateY(-2px);
}

.btn-telegram {
    width: 250px;
    padding: 8px 12px;
    background: linear-gradient(135deg, #0088cc, #2ca5e0);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 136, 204, 0.25);
}

.btn-telegram:hover {
    background: linear-gradient(135deg, #2ca5e0, #0088cc);
    transform: translateY(-2px);
}

/* Modal Templates */
.template-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.template-modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.template-modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f8ff 100%);
}

.template-modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--text-primary);
    font-weight: 700;
}

.template-modal-close {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.template-modal-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--danger-color);
    transform: rotate(90deg);
}

.template-list {
    padding: 20px;
    overflow-y: auto;
    max-height: 55vh;
}

.template-item {
    padding: 18px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.template-item:hover {
    border-color: var(--accent-color);
    background: #f8f9fa;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.template-title {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 15px;
}

.template-preview {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.template-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.template-tag {
    background: var(--primary-light);
    color: var(--primary-color);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

/* تحسين شريط التمرير */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .tabs-header {
        padding: 0 10px;
    }

    .tab-btn {
        padding: 15px 20px;
        font-size: 14px;
    }

    .tab-content {
        padding: 20px;
    }

    .action-bar {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }

    .action-bar-left,
    .action-bar-right {
        width: 100%;
        justify-content: center;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .editor-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .editor-actions {
        width: 100%;
        justify-content: space-between;
    }
}

/* =========================
   MOBILE FIX — FINAL
   ========================= */
@media (max-width: 768px) {
    /* تصغير الخط العام */
    body {
        font-size: 12px;
    }

    h3,
    h4 {
        font-size: 14px !important;
    }

    /* الكروت */
    .card-body {
        padding: 16px !important;
    }

    /* العناوين داخل المحررات */
    .editor-header {
        padding: 10px 12px !important;
        gap: 10px;
    }

    .editor-title-text h4 {
        font-size: 13px !important;
    }

    .editor-title-text p,
    .editor-title-text span {
        font-size: 11px !important;
    }

    /* أيقونات العناوين */
    .editor-icon {
        width: 32px !important;
        height: 32px !important;
        font-size: 14px !important;
    }

    /* أزرار المحرر */
    .editor-btn {
        padding: 6px 10px !important;
        font-size: 11px !important;
        border-radius: 6px;
    }

    /* محرر Quill */
    .ql-toolbar {
        padding: 6px !important;
    }

    .ql-toolbar button {
        width: 26px !important;
        height: 26px !important;
    }

    .ql-editor {
        font-size: 12px !important;
        padding: 10px !important;
        line-height: 1.4;
    }

    /* الحقول */
    .form-control {
        padding: 8px 12px !important;
        font-size: 12px !important;
    }

    .form-label {
        font-size: 12px !important;
    }

    /* الشريط السفلي */
    .action-bar {
        padding: 8px 10px !important;
        gap: 8px;
    }

    .action-bar-right {
        gap: 6px;
        flex-wrap: wrap;
    }

    .btn {
        padding: 8px 10px !important;
        font-size: 11px !important;
        border-radius: 8px;
    }

    .btn i {
        font-size: 12px;
    }

    /* إخفاء النص وترك الأيقونة في أصغر الشاشات */
    @media (max-width: 576px) {
        .btn span {
            display: none;
        }
        .btn-text {
            display: none;
        }
    }
}

@media (max-width: 768px) {
    .action-bar {
        left: 0;
    }
}

@media (max-width: 768px) {
    .action-bar {
        flex-direction: row !important;
        padding: 8px !important;
        gap: 8px !important;
    }

    .action-bar-left {
        display: none !important;
    }

    .action-bar-right {
        width: 100%;
        display: flex;
        justify-content: space-between;
    }

    .btn {
        flex: 1;
        padding: 10px !important;
        font-size: 12px !important;
    }
}

/* ===== Mobile Action Bar – FINAL TUNE ===== */
@media (max-width: 768px) {
    /* تصغير الأزرار الأساسية */
    .action-bar {
        padding: 6px 8px !important;
    }

    .action-bar-right {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        width: 100%;
    }

    .action-bar-right .btn {
        padding: 8px 6px !important;
        font-size: 11px !important;
        border-radius: 8px;
        height: 38px;
    }

    .action-bar-right .btn i {
        font-size: 12px;
    }

    /* زر Cancel في صف مستقل */
    .action-bar-left {
        display: block !important;
        width: 100%;
        margin-top: 6px;
    }

    .action-bar-left .btn {
        width: 100%;
        padding: 8px !important;
        font-size: 11px !important;
        height: 36px;
    }
}
@media (max-width: 480px) {
    .action-bar-right .btn span {
        display: none;
    }
}

/* ===============================
   Report Preview – Mobile Fix
================================ */

.report-preview-wrapper {
    width: 100%;
}

/* 📱 عند العرض على الهاتف */
@media (max-width: 576px) {
    /* تصغير الخط العام */
    .report-preview-wrapper {
        font-size: 11px !important;
        line-height: 1.4 !important;
    }

    /* العناوين */
    .report-preview-wrapper h1 {
        font-size: 14px !important;
    }

    /* الجداول */
    .report-preview-wrapper table {
        table-layout: fixed;
        width: 100%;
    }

    .report-preview-wrapper td {
        padding: 6px 8px !important;
        font-size: 11px !important;
        word-wrap: break-word;
        word-break: break-word;
        white-space: normal;
        vertical-align: top;
    }

    /* العناوين داخل الخلايا */
    .report-preview-wrapper td[style*="font-weight: bold"] {
        font-size: 11px !important;
    }

    /* حقول النص الطويل (الأسماء – التشخيص) */
    .report-preview-wrapper td,
    .report-preview-wrapper div {
        overflow-wrap: anywhere;
    }

    /* صندوق التشخيص */
    .report-preview-wrapper .diagnosis-box,
    .report-preview-wrapper
        div[style*="font-weight: bold"][style*="text-align: center"] {
        font-size: 12px !important;
        padding: 10px !important;
    }
}

/* ===============================
   Tabs Header – Mobile Fix
================================ */
@media (max-width: 576px) {
    .tabs-header {
        padding: 0 8px;
    }

    .tab-btn {
        padding: 10px 14px;
        font-size: 12px;
        gap: 6px;
    }

    .tab-btn i {
        font-size: 13px;
    }

    /* خط التاب النشط */
    .tab-btn.active {
        border-bottom-width: 2px;
    }
}
/* ===============================
   Sticky Tabs Header (Smart)
================================ */

.tabs-header {
    position: sticky;
    top: 70px; /* ارتفاع الـ top navbar */
    z-index: 500;
    background: white;
}
@media (max-width: 420px) {
    .tab-btn span,
    .tab-btn:not(.active) {
        font-size: 11px;
    }
}

/* تحسين Flatpickr ليبدو طبي */
.flatpickr-calendar {
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
    font-family: "Inter", sans-serif;
}

.flatpickr-months {
    padding: 8px;
}

.flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year {
    font-size: 14px;
    font-weight: 600;
}

.flatpickr-weekday {
    font-size: 11px;
    color: #6c757d;
}

.flatpickr-day {
    font-size: 12px;
    border-radius: 6px;
}

.flatpickr-day.selected {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

/* //////////////////////////////////////////////////////////////////////////////// */
/* //////////////////////////////////////////////////////////////////////////////// */
/* //////////////////////////////////////////////////////////////////////////////// */
/* //////////////////////////////////////////////////////////////////////////////// */
/* //////////////////////////////////////////////////////////////////////////////// */
/* //////////////////////////////////////////////////////////////////////////////// */
/* //////////////////////////////////////////////////////////////////////////////// */

.report-preview-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    overflow: auto;
}

.report-preview-content {
    background-color: white;
    margin: 20px auto;
    padding: 0;
    width: 90%;
    max-width: 850px;
    position: relative;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    overflow: hidden;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #2c3e50, #4a6491);
    color: white;
    padding: 15px 20px;
    border-bottom: 3px solid #1a252f;
}

.preview-header span {
    font-size: 18px;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.preview-header button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.preview-header button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.preview-body {
    max-height: 80vh;
    overflow-y: auto;
    padding: 0;
}



/* تنسيق التوقيع */
.preview-body div[style*="text-align: right"] {
    background: linear-gradient(to right, transparent, #f8f9fa) !important;
    padding: 20px !important;
    margin-top: 40px !important;
    border-top: 2px solid #2c3e50 !important;
}

/* تحسين التمرير */
.preview-body::-webkit-scrollbar {
    width: 10px;
}

.preview-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.preview-body::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 5px;
}

.preview-body::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.medical-report {
    font-family: "Times New Roman", serif;
    font-size: 14px;
    color: #000;
    background: #fff;
}

/* HEADER TABLE */
 .report-header {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
}

.report-header td {
    border: 1px solid #000;
    padding: 3px 6px;
}

.report-header .label {
    background: #bfe6ff;
    font-weight: bold;
    width: 15%;
}

.report-header .value {
    width: 35%;
}



.info-table td {
    border: 1px solid #000;
    padding: 4px 6px;
}

.info-table .label {
    font-weight: bold;
    width: 25%;
}

.section {
    margin-top: 10px;
}

.section-title {
    font-weight: bold;
    border-bottom: 1px solid #000;
    margin-bottom: 4px;
}

.section-title.center {
    text-align: center;
}

.section-body {
    line-height: 1.5;
}


.photo-row {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.photo-row img {
    width: 160px;
    border: 1px solid #000;
}


/* ===== IMAGE UPLOAD – FINAL CLEAN FIX ===== */

.image-upload-container {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 30px;
    min-height: 260px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #fcfdfd;
}


#previewImage {
    display: block;
    max-width: 100%;
    max-height: 240px;
    object-fit: contain;
    border-radius: 10px;
    margin-top: 10px;
}

.preview-inside {
    display: none;
    max-width: 100%;
    max-height: 200px;
    object-fit: contain;
    margin-top: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.image-upload-container.has-image {
    border-style: solid;
    background: #f8f9fa;
    min-height: 200px;
    padding: 20px;
}

/* //////////////////////////////////////////////////////////////////////////////// */
/* //////////////////////////////////////////////////////////////////////////////// */
/* //////////////////////////////////////////////////////////////////////////////// */
/* //////////////////////////////////////////////////////////////////////////////// */
/* //////////////////////////////////////////////////////////////////////////////// */
/* //////////////////////////////////////////////////////////////////////////////// */
/* //////////////////////////////////////////////////////////////////////////////// */

/* عناصر تحكم الصورة */

.image-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    background: var(--light-bg);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.btn-upload {
    background: var(--gradient-primary);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-upload:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(26, 95, 122, 0.3);
}

.btn-remove {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-remove:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(231, 76, 60, 0.3);
}

.file-info {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    flex-grow: 1;
}

/* شريط عرض الصورة الجانبي */

.image-preview-sidebar {
    width: 60%;
    background: white;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    border: 1px solid #000;
    overflow: hidden; /* مهم */
    height: auto; /* 🔥 ألغِ الارتفاع */
    margin: 0 auto;
}

.preview-header {
    background: linear-gradient(135deg, #159895 0%, #1a5f7a 100%);
    border-bottom: 1px solid var(--border-color);
}

.preview-header h4 {
    margin: 0;
    font-size: 15px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.empty-state {
    text-align: center;
    /* padding: 30px 20px; */
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 48px;
    color: var(--border-color);
    margin-bottom: 15px;
}

.empty-state p {
    font-weight: 600;
    margin-bottom: 5px;
}

.empty-state small {
    font-size: 12px;
    opacity: 0.8;
}

.image-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.preview-img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* أو cover */
    border-radius: 8px;
    object-fit: cover;
}

.image-info {
    background: var(--light-bg);
    border-radius: 8px;
    padding: 10px;
    text-align: left;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 12px;
}

.info-item:last-child {
    margin-bottom: 0;
}

.info-item i {
    color: var(--accent-color);
    width: 16px;
}

.preview-image-wrapper {
    width: 100%;
    background: #000;
}

.preview-img {
    display: block; /* 🔥 مهم */
    width: 100%;
    height: auto; /* لا تجبرها */
    max-height: 280px; /* اختياري */
    object-fit: contain; /* أو cover */
}

.image-info {
    padding: 12px 15px;
    background: var(--light-bg);
    border-top: 1px solid var(--border-color);
}

.info-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    margin-bottom: 6px;
}

/* Responsive */
@media (max-width: 768px) {
    .image-preview-sidebar {
        /* position: static; */
        width: 100%;
        max-height: 300px;
        margin: 10px auto;
        /* margin-top: 10px; */
        /* margin-bottom: 20px; */
    }

    .image-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-upload,
    .btn-remove {
        width: 100%;
        justify-content: center;
    }
}

@page {
    size: A4;
    margin: 20mm;
}

body {
    font-family: "DejaVu Sans", sans-serif;
    font-size: 14px;
    color: #000;
    direction: ltr;
}

.medical-report {
    width: 100%;
    max-width: 210mm;
    margin: 30px auto;
    padding: 0;
}

/* HEADER TABLE */
.report-header {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
    table-layout: fixed;
    /* 🔥 هذا السطر مهم */
}

.report-header td {
    border: 1px solid #000;
    padding: 3px 6px;
}

.report-header .label {
    background: #bfe6ff;
    font-weight: bold;
    width: 15%;
}



/* INFO TABLE */
/* .info-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
}

.info-table td {
    border: 1px solid #000;
    padding: 4px 6px;
}

.info-table .label {
    font-weight: bold;
    width: 25%;
    background: #f0f0f0;
}

.section {
    margin-top: 10px;
}

.section-title {
    font-weight: bold;
    border-bottom: 1px solid #000;
    margin-bottom: 4px;
    padding-bottom: 2px;
}

.section-title.center {
    text-align: center;
}

.section-body {
    line-height: 1.5;
    padding: 4px 0;
}


.photo-row {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 10px 0;
}

.photo-row img {
    width: 160px;
    border: 1px solid #000;
}

.diagnosis-box {
    font-weight: bold;
    background: #eef4ff;
    padding: 6px;
    border: 1px solid #000;
    line-height: 1.5;
} */

.signature {
    text-align: right;
    margin-top: 40px;
}

.signature p {
    margin: 0 0 10px 0;
}

.signature strong {
    font-size: 14px;
}

.signature span {
    font-size: 12px;
    color: #555;
}

.content {
    line-height: 1.6;
    margin: 5px 0;
}

/* For Arabic text */
.arabic-text {
    direction: rtl;
    text-align: right;
    font-family: "Times New Roman", serif;
}

/* Print styles */
@media print {
    body {
        font-size: 13px;
    }

    .medical-report {
        max-width: 100%;
        padding: 0;
    }
}

/* Remove any previous styles */
.clinic-header,
.patient-info-table,
.clinic-name,
.clinic-address {
    display: none;
}

td.colspan {
    width: 50%;
}


/* ===============================
   Quill Headings – Medical Style
================================ */

.ql-editor h1 {
    font-size: 22px;
    font-weight: 700;
    margin: 10px 0;
}

.ql-editor h2 {
    font-size: 18px;
    font-weight: 700;
    margin: 8px 0;
}

.ql-editor h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 6px 0;
}

/* النص العادي */
.ql-editor p {
    font-size: 14px;
    line-height: 1.6;
}


@media (max-width: 768px) {
    .tabs-container {
        max-width: 100% !important;
        margin: 10px !important;
        padding: 16px !important;
        border-radius: 12px;
    }
}

@media (max-width: 768px) {
    .card-body {
        padding: 14px !important;
    }

    .form-card {
        margin-bottom: 14px;
    }
}

@media (max-width: 768px) {
    .row {
        margin-left: 0;
        margin-right: 0;
    }

    [class*="col-md-"] {
        padding-left: 6px;
        padding-right: 6px;
    }
}


/* ===============================
   MOBILE – REMOVE SIDE GAPS (FINAL)
================================ */

@media (max-width: 576px) {

    /* 1️⃣ الحاوية الرئيسية */
    .tabs-container {
        width: 90vw !important;
        max-width: 90vw !important;
        margin: 0 !important;
        padding: 12px !important;
        border-radius: 0 !important;

    background: transparent;
    box-shadow: none;
    margin: 0;
    border: none;
    padding: 100px;
    }

    /* 2️⃣ رأس التبويبات */
    .tabs-header {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: -12px;   /* 🔥 يسحبها للحافة */
        margin-right: -12px;
    }

    /* 3️⃣ محتوى التبويب */
    .tab-content {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* 4️⃣ Bootstrap rows */
    .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* 5️⃣ Bootstrap columns */
    [class*="col-"] {
        padding-left: 4px !important;
        padding-right: 4px !important;
    }

}

