/* Premium Settings Components */
.settings-premium-box {
    background: white;
    padding: 20px;
    border-radius: 15px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.day-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 8px 16px;
    border-radius: 50px;
    border: 1px solid #cbd5e1;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 700;
    transition: all 0.2s ease;
    user-select: none;
}

.day-checkbox:has(input:checked) {
    background: #0f172a;
    color: white;
    border-color: #0f172a;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.2);
}

.day-checkbox input {
    accent-color: white;
    width: 16px;
    height: 16px;
}

/* Break Separator Animation */
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: translateY(-50%) scale(0.8);
    }

    to {
        opacity: 0.9;
        transform: translateY(-50%) scale(1);
    }
}

.schedule-end-preview #calculated-end-time {
    text-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
}

/* Modern Context Menu Styles */
.modern-context-menu {
    position: fixed;
    z-index: 10000;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    width: 220px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px;
    font-family: 'Tajawal', sans-serif;
    transform: scale(0.95);
    transform-origin: top right;
    transition: transform 0.15s ease, opacity 0.15s ease;
    direction: rtl;
}

.modern-context-menu:not(.hidden) {
    transform: scale(1);
    opacity: 1;
}

.context-menu-header {
    padding: 8px 12px;
    font-size: 0.75rem;
    font-weight: 800;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 6px;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 700;
    color: #334155;
    transition: all 0.2s ease;
}

.context-menu-item i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    opacity: 0.7;
}

.context-menu-item:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.context-menu-item.danger {
    color: #ef4444;
}

.context-menu-item.danger:hover {
    background: #fef2f2;
}

.context-menu-item.primary {
    color: #2563eb;
}

.context-menu-item.primary:hover {
    background: #eff6ff;
}

.context-menu-item.warning {
    color: #f59e0b;
}

.context-menu-item.warning:hover {
    background: #fffbeb;
}

.context-menu-divider {
    height: 1px;
    background: #f1f5f9;
    margin: 6px 0;
}

/* Highlighting Selected Cell */
.timetable-cell-selected {
    outline: 3px solid #3b82f6 !important;
    outline-offset: -3px;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
    z-index: 5;
}

.swap-source-active {
    animation: swapPulse 1.5s infinite ease-in-out;
    outline: 3px dashed #10b981 !important;
}

@keyframes swapPulse {
    0% {
        opacity: 0.8;
    }

    50% {
        opacity: 0.4;
    }

    100% {
        opacity: 0.8;
    }
}

/* Quick Flash for Swap Success */
.cell-swap-flash {
    animation: quickFlash 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

@keyframes quickFlash {
    0% {
        background-color: #10b981;
        transform: scale(1.05);
        z-index: 10;
    }

    100% {
        background-color: transparent;
        transform: scale(1);
        z-index: 1;
    }
}

/* Master Matrix Custom Cell Styling (Context Menu Items) */
.cell-subject-meeting {
    background-color: var(--subject-bg, #fee2e2) !important;
    border: 1px solid var(--subject-color, #ef4444) !important;
    color: var(--subject-color, #991b1b) !important;
    position: relative;
    font-weight: 800;
}

.cell-subject-meeting::after {
    content: "اجتماع";
    font-size: 0.6rem;
    position: absolute;
    bottom: 1px;
    left: 2px;
    opacity: 0.7;
}

.cell-academic-support {
    background-color: var(--subject-bg, #dcfce7) !important;
    border: 1px solid var(--subject-color, #10b981) !important;
    color: var(--subject-color, #166534) !important;
    position: relative;
    font-weight: 800;
}

.cell-academic-support::after {
    content: "دعم";
    font-size: 0.6rem;
    position: absolute;
    bottom: 1px;
    left: 2px;
    opacity: 0.7;
}

.cell-project {
    background-color: var(--subject-bg, #e0f2fe) !important;
    border: 1px solid var(--subject-color, #3b82f6) !important;
    color: var(--subject-color, #075985) !important;
    position: relative;
    font-weight: 800;
}

.cell-project::after {
    content: "مشروع";
    font-size: 0.6rem;
    position: absolute;
    bottom: 1px;
    left: 2px;
    opacity: 0.7;
}

.cell-custom {
    background-color: #f3f4f6 !important;
    color: #374151 !important;
    position: relative;
    font-weight: 800;
}

.cell-custom::after {
    content: attr(data-custom-text);
    font-size: 0.55rem;
    position: absolute;
    bottom: 1px;
    left: 2px;
    max-width: 90%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    opacity: 0.7;
}

/* --- Matrix Highlighting Engine Styles (v2.0) --- */
.matrix-col-highlight {
    background-color: rgba(37, 99, 235, 0.08) !important;
    border-left: 1px dashed rgba(37, 99, 235, 0.3) !important;
    border-right: 1px dashed rgba(37, 99, 235, 0.3) !important;
}

.matrix-row-highlight {
    background-color: rgba(37, 99, 235, 0.05) !important;
}

.matrix-row-highlight .sticky-col {
    background-color: #eff6ff !important;
    box-shadow: inset -4px 0 0 #2563eb !important;
    color: #1e40af !important;
}

.matrix-intersection {
    background-color: rgba(37, 99, 235, 0.2) !important;
    box-shadow: inset 0 0 0 2px #2563eb !important;
    transform: scale(1.02);
    z-index: 5;
    position: relative;
    border-radius: 4px;
}

.matrix-cell-conflict {
    /* Kill the old 2px red frame */
    box-shadow: none !important;
    background-color: transparent !important;
}

@keyframes matrix-conflict-glow {
    from { box-shadow: 0 0 10px rgba(239, 68, 68, 0.3); transform: scale(1.02); }
    to { box-shadow: 0 0 20px rgba(239, 68, 68, 0.6); transform: scale(1.05); }
}

.highlight-pulse {
    animation: highlight-pulse-anim 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes highlight-pulse-anim {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* --- Visual Polish & Alignment --- */

/* 1. Universal Spacing for Icons and Text (RTL Optimized) */
.nav-item,
.modern-badge,
.badge-unallocated-modern,
.stat-card,
.btn-add-modern,
.btn-setup-action,
.modern-switch-row,
.cand-name-row,
.teacher-meta,
.report-card-modern h4 {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    justify-content: flex-start;
}

/* Padding-right for labels after icons in RTL */
.nav-item span,
.modern-badge span,
.badge-unallocated-modern span,
.stat-info h3,
.stat-info p,
.setup-step-content h4,
.cand-name,
.teacher-name,
.subject-tag,
.quota-tag {
    padding-right: 12px !important;
}

/* 2. Flex Layout for extreme ends */
.modern-switch-row,
.stat-card,
.nav-item {
    justify-content: space-between !important;
}

/* 3. Master Matrix Cell Centering (Anti-Overlap) */
.matrix-data-cell {
    padding: 0 !important;
    /* Content will handle padding */
    min-height: 50px;
    height: 50px;
    position: relative;
    background-color: #fff;
    transition: background-color 0.2s ease;
}

.matrix-data-cell:hover {
    background-color: #f1f5f9;
}

.matrix-cell-content {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    width: 100%;
    height: 100%;
    gap: 2px;
    padding: 6px;
}

/* Adjust pseudo-labels for meetings/projects */
.matrix-data-cell.cell-subject-meeting .matrix-cell-content::after,
.matrix-data-cell.cell-academic-support .matrix-cell-content::after,
.matrix-data-cell.cell-project .matrix-cell-content::after,
.matrix-data-cell.cell-custom .matrix-cell-content::after {
    display: block !important;
    font-size: 0.55rem !important;
    line-height: 1;
    margin-top: 1px;
    padding: 2px 4px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 3px;
    width: fit-content;
    font-weight: 800;
}

.matrix-data-cell.cell-subject-meeting .matrix-cell-content::after {
    content: "اجتماع";
}

.matrix-data-cell.cell-academic-support .matrix-cell-content::after {
    content: "دعم";
}

.matrix-data-cell.cell-project .matrix-cell-content::after {
    content: "مشروع";
}

.matrix-data-cell.cell-custom .matrix-cell-content::after {
    content: attr(data-custom-text);
}


/* Locked icon styling inside matrix */
.matrix-data-cell i.fa-lock {
    font-size: 0.6rem;
    color: rgba(0, 0, 0, 0.4);
    order: -1;
    /* Above text */
}

/* =============================================================
   💎 3D NEUMORPHIC TIMETABLE OVERHAUL (General Timetable)
   ============================================================= */

/* 1. Global Table Cleanup: Remove all harsh/red borders */
.master-matrix-table {
    border-collapse: separate !important;
    border-spacing: 4px 6px !important; /* Space between card-cells for floating effect */
    background: #f1f5f9 !important; /* Soft slate background to make white cards pop */
    border: none !important;
}

.master-matrix-table td, 
.master-matrix-table th {
    border: none !important; /* KILLER of red borders */
    padding: 2px !important;
    background: transparent !important;
    vertical-align: middle;
}

/* 2. Neumorphic Card Styling for Cell Content */
.matrix-cell-content {
    background: #ffffff !important;
    border-radius: 10px !important; /* Rounded corners for modern feel */
    border: none !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    min-height: 44px;
    padding: 8px !important;
    font-weight: 800 !important;
    font-size: 0.85rem !important; /* Clearer text */
    
    /* Neumorphic shadow (Soft depth) */
    box-shadow: 
        4px 4px 8px rgba(148, 163, 184, 0.3), 
        -2px -2px 6px rgba(255, 255, 255, 0.9) !important;
    
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

/* 3. Hover Effect: Floating Card Lift */
.matrix-data-cell:hover .matrix-cell-content {
    transform: translateY(-5px) scale(1.06) !important;
    z-index: 200 !important;
    box-shadow: 
        10px 12px 24px rgba(100, 116, 139, 0.3), 
        -5px -5px 12px rgba(255, 255, 255, 1) !important;
}

/* 4. Active Effect: Pressed/Inset Look */
.matrix-data-cell:active .matrix-cell-content {
    transform: translateY(-1px) scale(0.96) !important;
    box-shadow: 
        inset 4px 4px 8px rgba(148, 163, 184, 0.4), 
        inset -2px -2px 6px rgba(255, 255, 255, 0.8) !important;
}

/* 5. Empty Cells: Subtle and depressed */
.matrix-cell-empty {
    background: rgba(248, 250, 252, 0.6) !important;
    box-shadow: 
        inset 2px 2px 5px rgba(148, 163, 184, 0.15), 
        inset -2px -2px 5px rgba(255, 255, 255, 0.4) !important;
    color: #cbd5e1 !important;
    font-size: 1rem !important;
    font-weight: 400 !important;
    opacity: 0.6;
}

/* 6. Soft Card Colors (Maintaining existing palettes but in 'Card' format) */
.matrix-data-cell.report-cell-science .matrix-cell-content   { background: linear-gradient(135deg, #dcfce7, #bbf7d0) !important; color: #166534 !important; }
.matrix-data-cell.report-cell-islamic .matrix-cell-content  { background: linear-gradient(135deg, #dbeafe, #bfdbfe) !important; color: #1e40af !important; }
.matrix-data-cell.report-cell-ccdi .matrix-cell-content     { background: linear-gradient(135deg, #f1f5f9, #e2e8f0) !important; color: #334155 !important; }
.matrix-data-cell.report-cell-literary .matrix-cell-content { background: linear-gradient(135deg, #e0f2fe, #bae6fd) !important; color: #0369a1 !important; }
.matrix-data-cell.report-cell-language .matrix-cell-content { background: linear-gradient(135deg, #f3e8ff, #e9d5ff) !important; color: #7e22ce !important; }
.matrix-data-cell.report-cell-activity .matrix-cell-content { background: linear-gradient(135deg, #fef3c7, #fde68a) !important; color: #c2410c !important; }
.matrix-data-cell.report-cell-math .matrix-cell-content     { background: linear-gradient(135deg, #e0f2fe, #bae6fd) !important; color: #0284c7 !important; }
.matrix-data-cell.report-cell-arabic .matrix-cell-content   { background: linear-gradient(135deg, #fef9c3, #fef08a) !important; color: #854d0e !important; }
.matrix-data-cell.report-cell-english .matrix-cell-content  { background: linear-gradient(135deg, #ede9fe, #ddd6fe) !important; color: #5b21b6 !important; }
.matrix-data-cell.report-cell-history .matrix-cell-content  { background: linear-gradient(135deg, #fee2e2, #fecaca) !important; color: #991b1b !important; }
.matrix-data-cell.report-cell-other .matrix-cell-content    { background: linear-gradient(135deg, #f3f4f6, #e5e7eb) !important; color: #4b5563 !important; }

/* 7. Special Highlighting Intersection: Glow Effect */
.matrix-intersection .matrix-cell-content {
    box-shadow: 0 0 25px rgba(59, 130, 246, 0.5) !important;
    transform: scale(1.12) translateY(-2px) !important;
    border: 2px solid #3b82f6 !important;
    z-index: 300 !important;
}

/* 8. Conflict Handling - Neumorphic Style */
.matrix-cell-conflict .matrix-cell-content {
    background: linear-gradient(135deg, #fff1f2, #ffe4e6) !important;
    box-shadow: inset 0 0 10px rgba(239, 68, 68, 0.15) !important;
    border: 1px solid rgba(239, 68, 68, 0.2) !important;
    color: #be123c !important;
    position: relative;
    /* Removed animation and aggressive markers as per user request */
}

/* Conflict Marker Removed */

@keyframes matrix-card-alert {
    from { transform: scale(1); box-shadow: 0 5px 15px rgba(239, 68, 68, 0.15); }
    to { transform: scale(1.04); box-shadow: 0 8px 25px rgba(239, 68, 68, 0.35); }
}

/* 9. Sticky Column & Header Enhancement */
.master-matrix-table th.sticky-col,
.master-matrix-table td.sticky-col {
    background: #ffffff !important;
    box-shadow: 6px 0 20px rgba(0, 0, 0, 0.08) !important;
    z-index: 150 !important;
    border-radius: 0 12px 12px 0 !important; /* Rounded edge for leading col */
}

.master-matrix-table thead th {
    background: #ffffff !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05) !important;
    border-radius: 0 0 12px 12px !important;
}

/* Day separators: Soft dashed lines */
.day-separator {
    border-left: 2px dashed #cbd5e1 !important;
    padding-left: 8px !important;
}

/* --- Absence Sync Styles --- */
.status-pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: statusPulse 2s infinite;
}

.status-pulse.busy {
    background: #f59e0b;
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
    animation-name: statusPulseYellow;
}

.status-pulse.error {
    background: #ef4444;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    animation-name: statusPulseRed;
}

@keyframes statusPulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes statusPulseYellow {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

@keyframes statusPulseRed {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.settings-absence-setup input:focus {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}