/**
 * SIKKHALAY INSTITUTE PORTAL — UNIVERSAL ALL-CLASS WEEKLY ROUTINE STYLES
 * File: css/universal_weekly_routine.css
 * 
 * High-Fidelity All-Class Period-Wise Master Timetable Matching Institutional Standard (media_1791199956351.jpg)
 */

/* ==========================================================================
   1. STUDIO CONTAINER & WORKSPACE CONTROLS
   ========================================================================== */

#view-universal-weekly-routine {
    margin-bottom: 24px;
    animation: fadeInSlide 0.25s ease-out;
}

@keyframes fadeInSlide {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.uwr-studio-toolbar {
    background: var(--bg-surface, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: var(--radius-lg, 12px);
    padding: 14px 18px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .uwr-studio-toolbar {
    background: #0f172a;
    border-color: #334155;
}

.uwr-studio-title {
    font-size: 15px;
    font-weight: 800;
    color: var(--text-main, #0f172a);
    display: flex;
    align-items: center;
    gap: 8px;
}

[data-theme="dark"] .uwr-studio-title {
    color: #f8fafc;
}

.uwr-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.uwr-btn {
    padding: 7px 13px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-decoration: none;
}

.uwr-btn-outline {
    background: var(--bg-surface, #ffffff);
    border-color: var(--border-color, #cbd5e1);
    color: var(--text-main, #334155);
}

[data-theme="dark"] .uwr-btn-outline {
    background: #1e293b;
    border-color: #475569;
    color: #f1f5f9;
}

.uwr-btn-outline:hover {
    border-color: var(--brand-primary, #059669);
    color: var(--brand-primary, #059669);
    background: rgba(5, 150, 105, 0.05);
}

.uwr-btn-primary {
    background: linear-gradient(135deg, #059669, #10b981);
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
}

.uwr-btn-primary:hover {
    background: linear-gradient(135deg, #047857, #059669);
    transform: translateY(-1px);
}

.uwr-btn-print {
    background: #0f172a;
    color: #ffffff;
    border: none;
}

.uwr-btn-print:hover {
    background: #1e293b;
    transform: translateY(-1px);
}

/* Sheet Wrapper (Canvas) */
.uwr-sheet-wrapper {
    background: var(--bg-surface, #f8fafc);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: var(--radius-lg, 12px);
    padding: 20px;
    overflow-x: auto;
    display: flex;
    justify-content: center;
}

[data-theme="dark"] .uwr-sheet-wrapper {
    background: #0b1120;
    border-color: #1e293b;
}

/* ==========================================================================
   2. HIGH-FIDELITY OFFICIAL ROUTINE SHEET (A4 LANDSCAPE MASTER CANVAS)
   ========================================================================== */

.uwr-paper-container {
    width: 100%;
    max-width: 1120px;
    background: #ffffff !important;
    color: #000000 !important;
    border: 1.5px solid #000000;
    border-radius: 0;
    padding: 14px 18px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    font-family: 'Hind Siliguri', 'Arial', sans-serif !important;
}

/* Watermark */
.uwr-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 320px;
    height: 320px;
    opacity: 0.05;
    pointer-events: none;
    z-index: 1;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
}

/* Sheet Header */
.uwr-header {
    text-align: center;
    margin-bottom: 6px;
    position: relative;
    z-index: 2;
}

.uwr-inst-emblem-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 2px;
}

.uwr-inst-emblem-img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 50%;
    border: 1px solid #000000;
    padding: 1px;
    background: #ffffff;
}

.uwr-inst-title {
    font-size: 19px;
    font-weight: 800;
    color: #000000 !important;
    margin: 0 0 1px 0;
    letter-spacing: -0.2px;
    line-height: 1.2;
}

.uwr-routine-title {
    font-size: 14px;
    font-weight: 700;
    color: #000000 !important;
    margin: 0 0 1px 0;
    line-height: 1.2;
}

.uwr-inst-subtitle {
    font-size: 11px;
    font-weight: 600;
    color: #222222 !important;
    margin: 0 0 6px 0;
}

/* ==========================================================================
   3. UNIVERSAL MASTER TABLE (GRID & CELLS)
   ========================================================================== */

.uwr-table-wrapper {
    position: relative;
    z-index: 2;
    overflow-x: auto;
    margin-bottom: 0px;
}

.uwr-master-table {
    width: 100%;
    border-collapse: collapse !important;
    border: 1.5px solid #000000 !important;
    font-size: 11px;
    color: #000000 !important;
    table-layout: fixed;
    background: transparent;
}

.uwr-master-table th,
.uwr-master-table td {
    border: 1px solid #000000 !important;
    padding: 3px 3px;
    vertical-align: middle;
    text-align: center;
    line-height: 1.25;
    color: #000000 !important;
    position: relative;
}

/* Headers */
.uwr-master-table thead th {
    background: #f8fafc !important;
    font-weight: 800;
    color: #000000 !important;
    padding: 4px 2px;
}

.uwr-master-table thead .period-name-th {
    font-size: 12.5px;
    font-weight: 800;
}

.uwr-master-table thead .period-time-th {
    font-size: 9.5px;
    font-weight: 600;
    color: #222222 !important;
    display: block;
    margin-top: 1px;
}

/* Left Assembly Column (Vertical Text) */
.uwr-assembly-col {
    width: 26px;
    max-width: 26px;
    padding: 4px 1px !important;
    font-size: 10px;
    font-weight: 800;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    background: #ffffff !important;
    letter-spacing: 0.5px;
    text-align: center;
    white-space: nowrap;
    cursor: pointer;
}

.uwr-assembly-col:hover {
    background: #f0fdf4 !important;
}

/* Class Column */
.uwr-class-th {
    width: 76px;
    font-size: 12px;
    font-weight: 800;
}

.uwr-class-td {
    width: 76px;
    font-size: 11.5px;
    font-weight: 800;
    background: #ffffff !important;
    white-space: nowrap;
    cursor: pointer;
}

.uwr-class-td:hover {
    background: #f0fdf4 !important;
    color: #059669 !important;
}

/* Recess / Break Vertical Column */
.uwr-break-td {
    width: 26px;
    max-width: 26px;
    padding: 3px 1px !important;
    font-size: 11px;
    font-weight: 800;
    background: #ffffff !important;
    text-align: center;
}

/* Right Split Note Column */
.uwr-notes-col {
    width: 22px;
    max-width: 22px;
    font-size: 9px;
    font-weight: 700;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    background: #ffffff !important;
    padding: 3px 1px !important;
    text-align: center;
    line-height: 1.1;
}

/* Interactive Subject / Slot Cells */
.uwr-slot-cell {
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 11px;
    font-weight: 600;
    min-height: 26px;
    word-break: break-word;
}

.uwr-slot-cell:hover {
    background: #f0fdf4 !important;
    outline: 1.5px dashed #059669;
}

.uwr-slot-main {
    font-weight: 700;
    color: #000000;
}

.uwr-slot-teacher {
    font-size: 10px;
    font-weight: 800;
    color: #000000;
    margin-left: 2px;
}

/* Split Days inside a single Cell (রবি-মঙ্গল / বুধ-বৃহ) */
.uwr-split-cell-grid {
    display: flex;
    flex-direction: column;
    gap: 1px;
    font-size: 9.5px;
    text-align: left;
    padding: 0;
}

.uwr-split-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    border-bottom: 1px dotted #999999;
    padding-bottom: 1px;
}

.uwr-split-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.uwr-split-day-tag {
    font-size: 8.5px;
    font-weight: 800;
    color: #444444;
    margin-right: 3px;
    white-space: nowrap;
}

/* Empty Cell State */
.uwr-slot-empty {
    color: #94a3b8;
    font-style: italic;
    font-size: 9.5px;
}

/* Teacher Highlight Filter Styles */
.uwr-slot-highlighted {
    background: #dcfce7 !important;
    outline: 2px solid #059669 !important;
    font-weight: 800 !important;
    transform: scale(1.015);
    z-index: 10;
}

.uwr-slot-dimmed {
    opacity: 0.28 !important;
    filter: grayscale(0.6);
}

/* ==========================================================================
   4. BOTTOM SECTIONS: TEACHER LOAD STRIP & DUTY ROSTER TABLE
   ========================================================================== */

/* Teacher Short Code Load Strip (Boxed Cells matching reference image) */
.uwr-teacher-summary-strip {
    border: 1.5px solid #000000 !important;
    border-top: none !important;
    background: #ffffff;
    display: flex;
    flex-wrap: nowrap;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    z-index: 2;
}

.uwr-teacher-box {
    flex: 1;
    border-right: 1px solid #000000;
    padding: 2.5px 1px;
    text-align: center;
    font-size: 9.5px;
    font-weight: 700;
    color: #000000;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1px;
}

.uwr-teacher-box:last-child {
    border-right: none;
}

.uwr-teacher-box:hover {
    background: #f1f5f9;
}

.uwr-teacher-box-active {
    background: #059669 !important;
    color: #ffffff !important;
    font-weight: 900 !important;
}

.uwr-t-code {
    font-weight: 800;
}

.uwr-t-sep {
    opacity: 0.7;
}

.uwr-t-count {
    font-weight: 800;
}

/* Bottom Duty Roster Table */
.uwr-duty-table-wrapper {
    margin-top: 4px;
    position: relative;
    z-index: 2;
    cursor: pointer;
}

.uwr-duty-table {
    width: 100%;
    border-collapse: collapse !important;
    border: 1.5px solid #000000 !important;
    font-size: 9.5px;
    color: #000000 !important;
    table-layout: fixed;
}

.uwr-duty-table th,
.uwr-duty-table td {
    border: 1px solid #000000 !important;
    padding: 2px 3px;
    text-align: center;
    vertical-align: middle;
    line-height: 1.2;
    color: #000000 !important;
}

.uwr-duty-table thead th {
    background: #f8fafc !important;
    font-weight: 800;
}

.uwr-duty-day-th {
    width: 102px;
    font-weight: 800;
    background: #f8fafc !important;
}

/* Signatures Strip */
.uwr-signatures-strip {
    display: flex;
    justify-content: space-between;
    margin-top: 18px;
    padding: 0 24px;
    font-size: 11px;
    font-weight: 700;
    color: #000000;
    position: relative;
    z-index: 2;
}

.uwr-sign-box {
    text-align: center;
    width: 180px;
}

.uwr-sign-line {
    border-top: 1px solid #000000;
    margin-bottom: 4px;
}

.uwr-sign-title {
    font-weight: 700;
    font-size: 10.5px;
}

/* ==========================================================================
   5. PRINT STYLING (A4 LANDSCAPE STRICT 1-PAGE FIT & EXACT DESIGN PARITY)
   ========================================================================== */

@media print {
    @page {
        size: A4 landscape;
        margin: 4mm 6mm;
    }

    *,
    *::before,
    *::after {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        box-sizing: border-box !important;
    }

    body.print-mode-universal-weekly-routine {
        background: #ffffff !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        color: #000000 !important;
    }

    /* Hide Navigation, Headers, Modals and UI Chrome */
    body.print-mode-universal-weekly-routine .sidebar,
    body.print-mode-universal-weekly-routine .top-header,
    body.print-mode-universal-weekly-routine .header,
    body.print-mode-universal-weekly-routine .admin-sub-nav,
    body.print-mode-universal-weekly-routine .routine-hero,
    body.print-mode-universal-weekly-routine .routine-view-tabs,
    body.print-mode-universal-weekly-routine .routine-navigator-panel,
    body.print-mode-universal-weekly-routine .uwr-studio-toolbar,
    body.print-mode-universal-weekly-routine .modal-overlay,
    body.print-mode-universal-weekly-routine .active-filter-bar,
    body.print-mode-universal-weekly-routine .mobile-scroll-hint,
    body.print-mode-universal-weekly-routine #view-routine-matrix,
    body.print-mode-universal-weekly-routine #view-routine-workload,
    body.print-mode-universal-weekly-routine .no-print {
        display: none !important;
    }

    /* Keep parent layout wrappers transparent and unconstrained */
    body.print-mode-universal-weekly-routine #app,
    body.print-mode-universal-weekly-routine .main-content,
    body.print-mode-universal-weekly-routine .content-area,
    body.print-mode-universal-weekly-routine #view-universal-weekly-routine,
    body.print-mode-universal-weekly-routine .uwr-sheet-wrapper {
        display: block !important;
        position: static !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        overflow: visible !important;
    }

    /* Master Paper Container (Full-page canvas) */
    body.print-mode-universal-weekly-routine #uwrPaperContainer {
        display: block !important;
        position: relative !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 4px 8px !important;
        border: 1.5px solid #000000 !important;
        box-shadow: none !important;
        background: #ffffff !important;
        color: #000000 !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        page-break-after: avoid !important;
        break-after: avoid !important;
    }

    body.print-mode-universal-weekly-routine .uwr-watermark {
        opacity: 0.04 !important;
    }

    body.print-mode-universal-weekly-routine .uwr-header {
        margin-bottom: 4px !important;
    }

    body.print-mode-universal-weekly-routine .uwr-inst-emblem-img {
        width: 32px !important;
        height: 32px !important;
        border: 1px solid #000000 !important;
    }

    body.print-mode-universal-weekly-routine .uwr-inst-title {
        font-size: 15pt !important;
        margin-bottom: 1px !important;
        color: #000000 !important;
    }

    body.print-mode-universal-weekly-routine .uwr-routine-title {
        font-size: 11pt !important;
        margin-bottom: 1px !important;
        color: #000000 !important;
    }

    body.print-mode-universal-weekly-routine .uwr-inst-subtitle {
        font-size: 8pt !important;
        margin-bottom: 4px !important;
        color: #222222 !important;
    }

    /* Master Timetable Grid with Crisp 100% Visible Borders */
    body.print-mode-universal-weekly-routine .uwr-table-wrapper {
        overflow: visible !important;
        margin-bottom: 0 !important;
    }

    body.print-mode-universal-weekly-routine .uwr-master-table {
        width: 100% !important;
        border-collapse: collapse !important;
        border: 1.5px solid #000000 !important;
        font-size: 8.5pt !important;
        table-layout: fixed !important;
        background: #ffffff !important;
    }

    body.print-mode-universal-weekly-routine .uwr-master-table th,
    body.print-mode-universal-weekly-routine .uwr-master-table td {
        border: 1px solid #000000 !important;
        padding: 1.5px 2px !important;
        line-height: 1.18 !important;
        color: #000000 !important;
        background: #ffffff !important;
        vertical-align: middle !important;
        text-align: center !important;
    }

    body.print-mode-universal-weekly-routine .uwr-master-table thead th {
        background: #f1f5f9 !important;
        border: 1px solid #000000 !important;
        font-weight: 800 !important;
        padding: 3px 2px !important;
    }

    body.print-mode-universal-weekly-routine .period-name-th {
        font-size: 9.5pt !important;
        font-weight: 800 !important;
    }

    body.print-mode-universal-weekly-routine .period-time-th {
        font-size: 7.5pt !important;
        font-weight: 600 !important;
        color: #111111 !important;
    }

    body.print-mode-universal-weekly-routine .uwr-assembly-col {
        border: 1px solid #000000 !important;
        font-size: 8pt !important;
        font-weight: 800 !important;
        writing-mode: vertical-rl !important;
        transform: rotate(180deg) !important;
        width: 24px !important;
        max-width: 24px !important;
        padding: 2px 1px !important;
        text-align: center !important;
        white-space: nowrap !important;
        background: #ffffff !important;
    }

    body.print-mode-universal-weekly-routine .uwr-class-th,
    body.print-mode-universal-weekly-routine .uwr-class-td {
        border: 1px solid #000000 !important;
        width: 68px !important;
        font-size: 8.5pt !important;
        font-weight: 800 !important;
        white-space: nowrap !important;
    }

    body.print-mode-universal-weekly-routine .uwr-break-td {
        border: 1px solid #000000 !important;
        width: 24px !important;
        max-width: 24px !important;
        padding: 2px 1px !important;
        text-align: center !important;
        background: #ffffff !important;
    }

    body.print-mode-universal-weekly-routine .uwr-notes-col {
        border: 1px solid #000000 !important;
        font-size: 7.5pt !important;
        font-weight: 700 !important;
        writing-mode: vertical-rl !important;
        transform: rotate(180deg) !important;
        width: 20px !important;
        max-width: 20px !important;
        padding: 2px 1px !important;
        text-align: center !important;
        background: #ffffff !important;
    }

    body.print-mode-universal-weekly-routine .uwr-slot-cell {
        border: 1px solid #000000 !important;
        font-size: 8.5pt !important;
        font-weight: 600 !important;
        padding: 1.5px 2px !important;
    }

    body.print-mode-universal-weekly-routine .uwr-slot-main {
        font-weight: 700 !important;
        color: #000000 !important;
    }

    body.print-mode-universal-weekly-routine .uwr-slot-teacher {
        font-weight: 800 !important;
        color: #000000 !important;
        font-size: 8pt !important;
    }

    body.print-mode-universal-weekly-routine .uwr-split-cell-grid {
        font-size: 7.8pt !important;
    }

    body.print-mode-universal-weekly-routine .uwr-split-row {
        border-bottom: 1px dashed #444444 !important;
        display: flex !important;
        align-items: baseline !important;
        justify-content: space-between !important;
        padding-bottom: 1px !important;
    }

    body.print-mode-universal-weekly-routine .uwr-split-row:last-child {
        border-bottom: none !important;
    }

    body.print-mode-universal-weekly-routine .uwr-split-day-tag {
        font-size: 7pt !important;
        font-weight: 800 !important;
        color: #222222 !important;
    }

    /* Teacher Summary Ledger Boxed Row */
    body.print-mode-universal-weekly-routine .uwr-teacher-summary-strip {
        border: 1.5px solid #000000 !important;
        border-top: none !important;
        background: #ffffff !important;
        display: flex !important;
        flex-wrap: nowrap !important;
        width: 100% !important;
        font-size: 7.5pt !important;
    }

    body.print-mode-universal-weekly-routine .uwr-teacher-box {
        border-right: 1px solid #000000 !important;
        padding: 1.5px 0.5px !important;
        font-size: 7.5pt !important;
        font-weight: 700 !important;
        color: #000000 !important;
        text-align: center !important;
        flex: 1 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 1px !important;
    }

    body.print-mode-universal-weekly-routine .uwr-teacher-box:last-child {
        border-right: none !important;
    }

    /* Duty Supervision Roster Table */
    body.print-mode-universal-weekly-routine .uwr-duty-table-wrapper {
        margin-top: 3px !important;
        width: 100% !important;
    }

    body.print-mode-universal-weekly-routine .uwr-duty-table {
        width: 100% !important;
        border-collapse: collapse !important;
        border: 1.5px solid #000000 !important;
        font-size: 7.5pt !important;
        table-layout: fixed !important;
        background: #ffffff !important;
    }

    body.print-mode-universal-weekly-routine .uwr-duty-table th,
    body.print-mode-universal-weekly-routine .uwr-duty-table td {
        border: 1px solid #000000 !important;
        padding: 1.5px 2px !important;
        line-height: 1.15 !important;
        text-align: center !important;
        color: #000000 !important;
        background: #ffffff !important;
    }

    body.print-mode-universal-weekly-routine .uwr-duty-table thead th,
    body.print-mode-universal-weekly-routine .uwr-duty-day-th {
        background: #f1f5f9 !important;
        border: 1px solid #000000 !important;
        font-weight: 800 !important;
        width: 85px !important;
    }

    /* Signatures Block */
    body.print-mode-universal-weekly-routine .uwr-signatures-strip {
        display: flex !important;
        justify-content: space-between !important;
        margin-top: 12px !important;
        padding: 0 20px !important;
        font-size: 8pt !important;
        font-weight: 700 !important;
        color: #000000 !important;
    }

    body.print-mode-universal-weekly-routine .uwr-sign-box {
        text-align: center !important;
        width: 160px !important;
    }

    body.print-mode-universal-weekly-routine .uwr-sign-line {
        border-top: 1px solid #000000 !important;
        margin-bottom: 2px !important;
    }

    body.print-mode-universal-weekly-routine .uwr-sign-title {
        font-size: 7.5pt !important;
        font-weight: 700 !important;
    }
}

/* ==========================================================================
   6. RESPONSIVE OPTIMIZATIONS (TABLETS & MOBILE < 400PX)
   ========================================================================== */

@media (max-width: 900px) {
    .uwr-studio-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px;
    }

    .uwr-toolbar-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .uwr-btn {
        justify-content: center;
        text-align: center;
        padding: 6px 8px;
        font-size: 11px;
    }

    .uwr-btn-primary, .uwr-btn-print {
        grid-column: 1 / -1;
    }

    .uwr-sheet-wrapper {
        padding: 8px;
    }
}

@media (max-width: 480px) {
    .uwr-toolbar-actions {
        grid-template-columns: 1fr;
    }

    .uwr-btn {
        width: 100%;
    }
}
