/* CS Case Dashboard Styles */

.cs-dashboard-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 48px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background-color: #f8fafc;
}

/* Navigation Tabs */
.dashboard-nav {
    border-bottom: 1px solid #e9ecef;
}

.dashboard-nav .nav-tabs {
    border-bottom: none;
}

.dashboard-nav .nav-link {
    color: #6c757d;
    border: none;
    padding: 12px 24px;
    font-weight: 500;
    border-radius: 8px 8px 0 0;
    margin-inline-end: 4px; /* Ye English main Right aur Hebrew main Left ban jayega */
    transition: all 0.3s ease;
}

.dashboard-nav .nav-link:hover {
    color: #495057;
    background-color: #f8f9fa;
    border-color: transparent;
}

.dashboard-nav .nav-link.active {
    color: #0073ea;
    background-color: transparent;
    border-bottom: 3px solid #0073ea;
    font-weight: 600;
}

/* Work Center Header */
.dashboard-header {
    background: linear-gradient(135deg, #0073ea 0%, #019cd2 100%);
    border-radius: 16px;
    padding: 32px;
    color: white;
    margin-bottom: 32px;
}

.dashboard-header h2 {
    color: white;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 1.75rem;
}

.dashboard-header p {
    color: #e3e3e3 !important;
    opacity: 0.9;
    margin-bottom: 0;
}

.user-avatar img {
    border: 3px solid rgba(255, 255, 255, 0.3);
}

/* Statistics Cards */
.stats-section {
    margin-bottom: 40px;
}

.stat-card {
    background: white;
    border-radius: 16px;
    padding: 32px 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    text-align: center;
    position: relative;
    overflow: hidden;
    border: 1px solid #f1f5f9;
    transition: all 0.3s ease;
    height: 160px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--card-color, #0073ea);
}

.stat-card.draft {
    --card-color: #f59e0b;
}

.stat-card.draft::before {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.stat-card.treatment {
    --card-color: #10b981;
}

.stat-card.treatment::before {
    background: linear-gradient(90deg, #10b981, #34d399);
}

.stat-card.completed {
    --card-color: #6b7280;
}

.stat-card.completed::before {
    background: linear-gradient(90deg, #6b7280, #9ca3af);
}

.stat-number {
    font-size: 3rem;
    font-weight: 700;
    color: var(--card-color, #0073ea);
    margin: 0;
    line-height: 1;
}

.stat-label {
    color: #64748b;
    font-weight: 500;
    font-size: 1.1rem;
    margin-top: 8px;
}

/* Main Cards */
.card {
    border: none;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.card-header {
    background: white;
    border-bottom: 1px solid #f1f5f9;
    padding: 20px 24px;
    border-radius: 16px 16px 0 0 !important;
}

.card-header h5 {
    color: #1e293b;
    font-weight: 600;
    font-size: 1.125rem;
    margin-bottom: 0;
}

.card-body {
    padding: 24px;
    overflow: visible;
}

/* Case Lists Styling */
#pending-cases-list,
#under-review-cases-list,
#cases_to_be_received_list,
#received_cases_list {
    max-height: 400px;
    overflow-y: auto;
}

.pending-case-item {
    padding: 16px 24px;
    border-bottom: 1px solid #f1f5f9;
    transition: all 0.2s ease;
    cursor: pointer;
}

.pending-case-item:hover {
    background: linear-gradient(90deg, #f8fafc, #f1f5f9);
    border-left: 4px solid #0073ea;
    padding-left: 20px;
}

.pending-case-item:last-child {
    border-bottom: none;
}

.case-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0073ea 0%, #0873e6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.case-info h6 {
    color: #1e293b;
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 1rem;
}

.case-info small {
    color: #64748b;
    font-size: 0.875rem;
}

.case-status {
    font-size: 0.8rem;
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 500;
    text-align: center;
    min-width: 90px;
}

.status-draft {
    background: #fef3c7;
    color: #92400e;
}

.status-pending, .status-submitted {
    background: #dbeafe;
    color: #1e40af;
}

.status-approved {
    background: #d1fae5;
    color: #065f46;
}

.status-rejected {
    background: #fee2e2;
    color: #dc2626;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state i {
    font-size: 4rem;
    color: #cbd5e1;
    margin-bottom: 24px;
}

.empty-state p {
    color: #64748b;
    font-size: 1.1rem;
    margin: 0;
}

/* Badges */
.badge {
    font-weight: 500;
    font-size: 0.8rem;
    padding: 6px 10px;
    border-radius: 20px;
}

.bg-primary {
    background-color: #0073ea !important;
}

.bg-warning {
    background-color: #f59e0b !important;
}

.bg-info {
    background-color: #0073ea !important;
}

/* Loading States */
.spinner-border {
    width: 2rem;
    height: 2rem;
}

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Buttons */
.btn {
    border-radius: 10px;
    font-weight: 500;
    padding: 12px 24px;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #0073ea;
    border: none;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1.1rem;
}

/* Notifications */
#dashboard-notification {
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    border: none;
}

/* Scrollbar Styling */
#pending-cases-list::-webkit-scrollbar,
#under-review-cases-list::-webkit-scrollbar,
#cases_to_be_received_list::-webkit-scrollbar,
#received_cases_list::-webkit-scrollbar {
    width: 6px;
}

#pending-cases-list::-webkit-scrollbar-track,
#under-review-cases-list::-webkit-scrollbar-track,
#cases_to_be_received_list::-webkit-scrollbar-track,
#received_cases_list::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

#pending-cases-list::-webkit-scrollbar-thumb,
#under-review-cases-list::-webkit-scrollbar-thumb,
#cases_to_be_received_list::-webkit-scrollbar-thumb,
#received_cases_list::-webkit-scrollbar-thumb { 
    background: #cbd5e1;
    border-radius: 3px;
}

#pending-cases-list::-webkit-scrollbar-thumb:hover,
#under-review-cases-list::-webkit-scrollbar-thumb:hover,
#cases_to_be_received_list::-webkit-scrollbar-thumb:hover,
#received_cases_list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Responsive Design */
@media (max-width: 768px) {
    .cs-dashboard-container {
        padding: 16px;
    }

    .dashboard-header {
        text-align: center;
        padding: 24px 20px;
    }

    .dashboard-header h2 {
        font-size: 1.5rem;
    }

    .dashboard-header .row > div:last-child {
        margin-top: 20px;
    }

    .stat-card {
        padding: 24px 20px;
        margin-bottom: 16px;
        height: 140px;
    }

    .stat-number {
        font-size: 2.5rem;
    }

    .case-avatar {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .pending-case-item {
        padding: 12px 16px;
    }

    .dashboard-nav .nav-link {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
}

@media (max-width: 576px) {
    .case-info h6 {
        font-size: 0.9rem;
    }

    .case-info small {
        font-size: 0.8rem;
    }

    .case-status {
        font-size: 0.75rem;
        padding: 4px 8px;
        min-width: 80px;
    }

    .btn-lg {
        padding: 12px 20px;
        font-size: 1rem;
    }
}

/* Animation Classes */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stat-card {
    animation: fadeInUp 0.6s ease-out;
}

.stat-card:nth-child(2) {
    animation-delay: 0.1s;
}

.stat-card:nth-child(3) {
    animation-delay: 0.2s;
}

/* Focus States for Accessibility */
.pending-case-item:focus {
    outline: 2px solid #4f46e5;
    outline-offset: 2px;
    background: linear-gradient(90deg, #f8fafc, #f1f5f9);
}

.nav-link:focus {
    outline: 2px solid #0073ea;
    outline-offset: 2px;
}

.btn:focus {
    outline: 2px solid #0073ea;
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* CSS for the new Cases Tab */
.cases-sub-nav {
    display: flex;
    gap: 1.5rem;
    border-bottom: 0;
}
.cases-sub-nav-link {
    text-decoration: none;
    color: #6c757d;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid transparent;
    font-weight: 500;
    transition: all 0.2s ease-in-out;
}
.cases-sub-nav-link:hover {
    color: #0073ea;
}
.cases-sub-nav-link.active {
    color: #0073ea;
    border-bottom-color: #0073ea;
}
#cases-search-input {
    max-width: 250px;
}
.cs-cases-table th {
    background-color: #f8f9fa;
    font-weight: 600;
}
.cs-cases-table td {
    vertical-align: middle;
}
.cases-pagination .page-item.active .page-link {
    background-color: #0073ea;
    border-color: #0073ea;
}

/* Case Action Menu - COMPLETELY FIXED VERSION */
.pending-case-item,
.cs-cases-table tr {
    position: relative;
    z-index: 1;
}

/* When menu is open, increase parent z-index */
.pending-case-item.menu-is-open,
.cs-cases-table tr.menu-is-open {
    z-index: 1060 !important;
    position: relative;
}

.case-action-menu {
    position: relative;
    z-index: 1;
}

.case-action-menu .btn {
    color: #6c757d;
    border: none !important;
    background: none !important;
    font-size: 1.1rem;
    line-height: 1;
    padding: 8px;
    box-shadow: none !important;
    position: relative;
    z-index: 1;
}

.case-action-menu .btn:hover,
.case-action-menu .btn:focus,
.case-action-menu .btn.show {
    color: #495057 !important;
    background-color: rgba(0,0,0,0.05) !important;
}

/* CRITICAL: Fixed dropdown positioning */
.case-action-menu .dropdown-menu {
    min-width: 200px;
    box-shadow: 0 0.5rem 1.5rem rgba(0,0,0,0.2);
    border: 1px solid rgba(0,0,0,0.1);
    z-index: 1070 !important;
    background-color: #ffffff;
}

/* For scrollable containers */
#pending-cases-list,
#under-review-cases-list,
#cases_to_be_received_list,
#received_cases_list {
    position: relative;
    overflow-y: auto;
    overflow-x: visible;
}

.case-action-menu .dropdown-item {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.case-action-menu .dropdown-item:hover {
    background-color: #f8f9fa;
}

.case-action-menu .dropdown-item i {
    width: 20px;
    text-align: center;
    color: #6c757d;
}


/* --- Styles for Preview Modal (Phase 3) --- */
#case-preview-content-modal .card-header h5 {
    margin-bottom: 0;
    font-size: 1.1rem;
    color: #0073ea;
}

#case-preview-content-modal .preview-row {
    display: flex;
    flex-wrap: wrap;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e9ecef;
}

#case-preview-content-modal .preview-row:last-child {
    border-bottom: none;
}

#case-preview-content-modal .preview-row dt {
    font-weight: 600;
    color: #343a40;
}

#case-preview-content-modal .preview-row dd {
    margin-bottom: 0;
    text-transform: capitalize;
}

#case-preview-content-modal .preview-image-wrapper {
    text-align: center;
    border: 1px solid #dee2e6;
    padding: 5px;
    border-radius: 0.25rem;
}

#case-preview-content-modal .preview-image-wrapper img {
    aspect-ratio: 1 / 1;
    object-fit: cover;
    cursor: pointer;
}

#case-preview-content-modal .preview-image-caption {
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 5px;
    text-transform: capitalize;
}

#case-preview-content-modal .preview-file-list {
    list-style: none;
    padding-left: 0;
}

#case-preview-content-modal .preview-file-list li {
    background-color: #f8f9fa;
    padding: 0.5rem 1rem;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    margin-bottom: 0.5rem;
}

/* Lightbox Modal styles */
#imageLightboxModal .modal-content {
    background: transparent;
    border: none;
}

#imageLightboxModal .modal-body {
    padding: 0;
}

#lightboxImage {
    max-height: 90vh;
    width: auto;
}

/* --- Styles for Special Preview Grids --- */
.preview-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
    padding-top: 5px;
}
.preview-grid-item {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 4px;
    text-align: center;
    font-size: 0.9rem;
    background-color: #f8fafc;
}
.preview-grid-key {
    display: block;
    font-weight: 600;
    color: #4f46e5;
    font-size: 0.8rem;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 2px;
    padding-bottom: 2px;
}
.preview-grid-value {
    display: block;
    color: #334155;
}

/* Fix z-index issue for open dropdown menus using a JS-added class */
.pending-case-item.menu-is-open,
.cs-cases-table tr.menu-is-open {
    position: relative; /* Yeh line masle ko hal karegi */
    z-index: 10;
}

/* Custom style for the "New cases" button in the header */
.dashboard-header .btn-primary {
    background: #ffffff;
    color: #019cd2;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}

.dashboard-header .btn-primary:hover {
     background: #f1f1f1;
}



/* =================================================== */
/* == STYLES FOR AVATAR & STATUS BADGES (CASES TAB) == */
/* =================================================== */

/* 1. Patient Avatar in Table */
.case-avatar-table {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #eef2ff;
    color: #4f46e5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}

/* 2. Color-coded Status Badges */
.status-badge-cases {
    font-size: 0.75rem;
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
}

.status-badge-draft,
.status-badge-not-submitted {
    background: #fef3c7; color: #92400e;
}

.status-badge-submitted,
.status-badge-pending-review {
    background: #dbeafe; color: #1e40af;
}

.status-badge-under-review {
    background: #e0e7ff; color: #3730a3;
}

.status-badge-on-hold {
    background: #fee2e2; color: #991b1b;
}

.status-badge-approved,
.status-badge-completed,
.status-badge-in-treatment,
.status-badge-treatment-plan-ready {
    background: #d1fae5; color: #065f46;
}

.status-badge-cancelled,
.status-badge-archived {
    background: #e5e7eb; color: #4b5563;
}


/* =================================================== */
/* == RTL SAFE FIXES (ONLY SPACING) == */
/* =================================================== */

/* 1. Navigation Tabs Gap Fix */
/* English main margin-right hota hai, Hebrew main margin-left chahiye */
body.rtl .dashboard-nav .nav-link {
    margin-right: 0 !important;
    margin-left: 4px !important;
}

/* 2. Spacing Classes Fix (me-2, me-3 waghaira) */
/* Agar apka theme Bootstrap RTL load nahi kar raha, tu ye manually gap theek karega */

/* Margin End (Jo English main Right gap hai, Hebrew main Left hona chahiye) */
body.rtl .me-1 { margin-right: 0 !important; margin-left: 0.25rem !important; }
body.rtl .me-2 { margin-right: 0 !important; margin-left: 0.5rem !important; }
body.rtl .me-3 { margin-right: 0 !important; margin-left: 1rem !important; }
body.rtl .me-4 { margin-right: 0 !important; margin-left: 1.5rem !important; }

/* Margin Start (Jo English main Left gap hai, Hebrew main Right hona chahiye) */
body.rtl .ms-1 { margin-left: 0 !important; margin-right: 0.25rem !important; }
body.rtl .ms-2 { margin-left: 0 !important; margin-right: 0.5rem !important; }
body.rtl .ms-3 { margin-left: 0 !important; margin-right: 1rem !important; }

/* 3. Text Alignment */
/* Agar table ka text Hebrew main bhi Left aa raha hai tu ye lagayen */
body.rtl th, 
body.rtl td {
    text-align: right !important;
}

/* 4. Icons Spacing inside Buttons/Links */
/* Aksar icons text ke sath chipak jate hain Hebrew main */
body.rtl .btn i, 
body.rtl .nav-link i,
body.rtl .status-badge-cases i {
    margin-left: 8px !important;
    margin-right: 0 !important;
}

/* 5. Modal Close Button (X) Position */
/* Agar popup ka X button ghalat side par hai */
body.rtl .btn-close {
    margin-left: 0;
    margin-right: auto;
}


/* =================================================== */
/* == FINAL HEBREW (RTL) FIXES - V3 == */
/* =================================================== */

/* 1. BUTTON FIX (Confirming it stays Left) */
body.rtl .dashboard-header .btn-primary,
body.rtl .dashboard-header a.btn {
    margin-left: 0 !important;
    margin-right: auto !important;
    float: left !important;
}

/* 2. TABS ALIGNMENT & GAP FIX */
/* Tabs ke container ka padding khatam karna zaroori hai */
body.rtl .dashboard-nav .nav-tabs {
    padding-right: 0 !important; /* Right side ka extra gap khatam */
}

/* Tabs ki items ka gap Right se hata kar Left par shift karna */
body.rtl .dashboard-nav .nav-link {
    margin-right: 0 !important;
    margin-left: 4px !important;
}

/* =================================================== */
/* == HOVER BORDER FIX - Left → Right in Hebrew     == */
/* =================================================== */

/* English: Blue line LEFT side par, padding-left adjust */
/* Hebrew: Blue line RIGHT side par, padding-right adjust */
body.rtl .pending-case-item:hover {
    background: linear-gradient(-90deg, #f8fafc, #f1f5f9);
    border-left: none !important;
    border-right: 4px solid #0073ea !important;
    padding-left: 24px !important;
    padding-right: 20px !important;
}