/* Timetable Engine Web Interface Styles */

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.container {
    max-width: 1500px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    background: linear-gradient(135deg, #000000 0%, #EEB412 100%);
    color: white;
    padding: 2rem 0;
    text-align: center;
    margin-bottom: 2rem;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

.nav-tabs {
    display: flex;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    overflow: hidden;
}

.nav-tab {
    flex: 1;
    padding: 1rem 2rem;
    background: white;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    border-right: 1px solid #eee;
}

.nav-tab:last-child {
    border-right: none;
}

.nav-tab:hover {
    background: #f8f9fa;
}

.nav-tab.active {
    background: #667eea;
    color: white;
}

.tab-content {
    display: none;
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

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

.step {
    margin-bottom: 2rem;
    padding: 1.5rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    background: #f8f9fa;
}

.step.completed {
    border-color: #28a745;
    background: #d4edda;
}

.step.current {
    border-color: #667eea;
    background: #e3f2fd;
}

.step h3 {
    color: #667eea;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
}

.step-number {
    background: #667eea;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1rem;
    font-weight: bold;
}

.step.completed .step-number {
    background: #28a745;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.file-upload {
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    background: #f8f9fa;
    transition: all 0.3s ease;
    cursor: pointer;
}

.file-upload:hover {
    border-color: #667eea;
    background: #e3f2fd;
}

.file-upload.dragover {
    border-color: #667eea;
    background: #e3f2fd;
}

.file-list {
    margin-top: 1rem;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: white;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin-bottom: 0.5rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5a6fd8;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Time patterns section */
.time-patterns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.pattern-item {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 1rem;
}

.pattern-item strong {
    color: #495057;
    font-size: 1.1rem;
    display: block;
    margin-bottom: 0.5rem;
}

.pattern-details {
    font-size: 0.9rem;
    color: #6c757d;
}

.pattern-details div {
    margin-bottom: 0.25rem;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.3s ease;
}

.status-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.status-indicator.success {
    background: #28a745;
}

.status-indicator.warning {
    background: #ffc107;
}

.status-indicator.error {
    background: #dc3545;
}

.status-indicator.info {
    background: #17a2b8;
}

.alert {
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1rem;
}

.alert-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.alert-warning {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
}

.alert-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.alert-info {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

/* Calendar-Style Schedule Grid */
.calendar-container {
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: visible;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin: 1rem 0;
    min-height: 600px;
    width: 100%;
    max-width: 1400px;
}

.calendar-header {
    display: grid;
    grid-template-columns: 120px repeat(5, 1fr);
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    min-width: 1000px;
}

.time-column-header, .day-column-header {
    padding: 12px 8px;
    font-weight: bold;
    color: #495057;
    text-align: center;
    border-right: 1px solid #dee2e6;
}

.day-column-header {
    background-color: #e9ecef;
}

.calendar-body {
    display: grid;
    grid-template-columns: 120px 1fr;
    overflow-x: visible;
    min-height: 600px;
}

.time-column {
    background-color: #f8f9fa;
    border-right: 2px solid #dee2e6;
}

.time-slot {
    min-height: 60px; /* Use min-height instead of height to allow expansion */
    padding: 8px 12px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #495057;
    position: relative;
    overflow: visible;
    font-weight: 500;
}

/* Time is now displayed directly in the content, no need for ::before */

.time-slot:has(.calendar-event) {
    height: auto;
    min-height: 60px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
}

.day-column {
    border-right: 1px solid #e9ecef;
    overflow: visible;
}

.day-column .time-slot {
    border-bottom: 1px solid #f1f3f4;
    background-color: white;
}

.day-column .time-slot:nth-child(even) {
    background-color: #fafafa;
}

/* Calendar Event Styles */
.calendar-event {
    position: absolute;
    top: 0;
    left: 0;
    /* right: 0; - Removed so width can be set by JavaScript for overlapping events */
    margin: 1px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: none;
    z-index: 10;
    min-height: 20px;
    /* Default width when no overlaps - will be overridden by JS for overlapping events */
    width: calc(100% - 4px);
    /* Rotate text 90 degrees clockwise */
    writing-mode: vertical-rl;
    text-orientation: mixed;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
}

.calendar-event:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    z-index: 20;
    background-color: #fff3cd !important;
    border: 2px solid #ffc107 !important;
}

/* Custom instant tooltip */
.custom-tooltip {
    display: none;
    position: fixed;
    background: #f5f5f5;
    color: #000;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid #ffc107;
    font-size: 13px;
    z-index: 10000;
    pointer-events: none;
    white-space: normal;
    min-width: 220px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    line-height: 1.6;
    text-align: left;
}

.event-title {
    font-weight: bold;
    font-size: 11px;
    color: #333;
    margin-bottom: 2px;
    line-height: 1.2;
}

.event-time {
    font-size: 10px;
    color: #666;
    margin-bottom: 1px;
}

.event-room {
    font-size: 9px;
    color: #888;
    font-style: italic;
}

/* Rotated text for narrow events */
.calendar-event.narrow {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(0deg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
}

.calendar-event.narrow .event-title {
    font-size: 10px;
    font-weight: 600;
    line-height: 1.2;
    color: black;
}

.calendar-event.narrow .event-time {
    font-size: 9px;
    margin-top: 2px;
    color: black;
}

.calendar-event.narrow .event-room {
    font-size: 8px;
    margin-top: 1px;
    opacity: 0.9;
    color: black;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .calendar-header {
        grid-template-columns: 60px repeat(5, 1fr);
    }
    
    .calendar-body {
        grid-template-columns: 60px 1fr;
    }
    
    .time-slot {
        height: 35px;
        font-size: 10px;
    }
    
    .calendar-event {
        font-size: 10px;
    }
    
    .event-title {
        font-size: 10px;
    }
    
    .event-time, .event-room {
        font-size: 8px;
    }
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.metric-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.metric-value {
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 0.5rem;
}

.metric-label {
    color: #666;
    font-size: 0.9rem;
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.hidden {
    display: none;
}

.tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 200px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 8px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: none;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

.code-block {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    overflow-x: auto;
    margin: 1rem 0;
}

.sample-data {
    background: #e8f5e8;
    border: 1px solid #c3e6cb;
    border-radius: 5px;
    padding: 1rem;
    margin: 1rem 0;
}

.sample-data h4 {
    color: #155724;
    margin-bottom: 0.5rem;
}

.sample-data pre {
    background: white;
    padding: 0.5rem;
    border-radius: 3px;
    font-size: 0.8rem;
    overflow-x: auto;
}

.template-editor-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: hidden;
}

.template-editor-dialog {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    background: #fff;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.template-editor-header {
    flex: 0 0 auto;
    padding: 4px 10px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 0;
}

.template-editor-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
}

.template-editor-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.template-editor-title-help {
    font-size: 0.68rem;
    line-height: 1.25;
    color: #4b5563;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 60vw;
}

/* Compact buttons in editor (global .btn is very tall) */
.template-editor-dialog .btn {
    padding: 0.2rem 0.45rem;
    font-size: 0.78rem;
    font-weight: 500;
    border-radius: 4px;
    line-height: 1.2;
    white-space: nowrap;
}

.template-editor-source-row {
    flex: 0 0 auto;
    padding: 6px 8px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    border-bottom: 1px solid #e5e7eb;
    background: #f8fafc;
}

.template-editor-source-row .btn {
    flex-shrink: 0;
}

/* Inline status + validation to the right of Upload button */
.template-editor-inline-messages {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    flex: 1 1 auto;
    min-width: 260px;
}

.template-editor-inline-messages .template-editor-status-col,
.template-editor-inline-messages .template-editor-validation-col {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    max-height: 2.2rem;
    overflow-y: auto;
    scrollbar-width: thin;
}

.template-editor-inline-messages .template-editor-validation-col {
    border-left: 1px solid #e8e8e8;
    padding-left: 8px;
}

.template-editor-inline-messages .alert {
    margin: 0;
    padding: 0.2rem 0.4rem;
    font-size: 0.7rem;
    line-height: 1.2;
}

.template-editor-controls {
    flex: 0 0 auto;
    padding: 4px 8px;
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    border-bottom: 1px solid #e5e7eb;
    min-height: 0;
}

.template-editor-controls label {
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.template-editor-help {
    flex: 0 0 auto;
    margin: 0;
    padding: 4px 10px 6px;
    font-size: 0.7rem;
    line-height: 1.4;
    color: #4b5563;
    border-bottom: 1px solid #e5e7eb;
    background: #fafafa;
}

.template-editor-help strong {
    color: #374151;
    font-weight: 600;
}

.template-editor-controls select {
    font-size: 0.78rem;
    padding: 2px 6px;
    max-height: 28px;
    border-radius: 4px;
    flex-shrink: 0;
}

.template-editor-version-select {
    min-width: 140px;
    max-width: 220px;
}

/* Status (edit lock) left 50%; validation (errors/warnings) right 50% — one row */
.template-editor-messages {
    flex: 0 0 auto;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 8px;
    max-height: 4.5rem;
    overflow: hidden;
    padding: 2px 8px 4px;
    border-bottom: 1px solid #eee;
    min-height: 0;
}

.template-editor-status-col {
    flex: 1 1 0;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
}

.template-editor-validation-col {
    flex: 1 1 0;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    border-left: 1px solid #e8e8e8;
    padding-left: 8px;
}

.template-editor-messages .alert {
    padding: 0.3rem 0.45rem;
    margin-bottom: 0.2rem;
    font-size: 0.72rem;
    line-height: 1.25;
    border-radius: 4px;
}

.template-editor-messages .alert:last-child {
    margin-bottom: 0;
}

.template-editor-status-col .alert:last-child,
.template-editor-validation-col .alert:last-child {
    margin-bottom: 0;
}

.template-editor-validation-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.5rem;
}

.template-editor-validation-row strong {
    flex: 0 0 auto;
}

.template-editor-validation-inline {
    flex: 1 1 auto;
    min-width: 0;
}

.template-editor-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.template-editor-sheet-tabs {
    border-bottom: 1px solid #e5e7eb;
    overflow-x: auto;
    white-space: nowrap;
    padding: 4px 6px;
    display: flex;
    gap: 4px;
    flex: 0 0 auto;
    align-items: center;
    min-height: 0;
}

.template-sheet-tab {
    text-align: center;
    margin-bottom: 0;
    flex: 0 0 auto;
    padding: 0.15rem 0.4rem !important;
    font-size: 0.75rem !important;
}

.template-sheet-tab.active {
    background: #667eea;
    color: #fff;
}

.template-editor-sheet-grid {
    flex: 1;
    min-height: 0;
    overflow-x: auto;
    overflow-y: auto;
    padding: 10px;
    scrollbar-gutter: stable both-edges;
}

.template-grid-table {
    width: max-content;
    min-width: max-content;
    border-collapse: collapse;
    table-layout: auto;
}

.template-grid-table th,
.template-grid-table td {
    border: 1px solid #e5e7eb;
    padding: 4px 5px;
    vertical-align: top;
}

/* Match body typography + thin dark outline like native form controls */
.template-grid-table input,
.template-grid-table select {
    padding: 4px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.25;
    border: 1px solid #000;
    border-radius: 2px;
    background: #fff;
    color: #333;
}

.template-grid-table input {
    width: 100%;
}

.template-grid-table select {
    width: 100%;
    max-width: none;
}

/* Patterns / timeslots: 24h HH:MM shown in grid; stored as minutes server-side */
.template-grid-table input.template-grid-time-input {
    font-variant-numeric: tabular-nums;
    min-width: 7ch;
}

.template-grid-table input.template-grid-readonly-field {
    background: #f1f3f5;
    color: #495057;
    cursor: default;
}
.template-grid-table input.template-grid-readonly-field:disabled {
    opacity: 1;
}

/* Timeslots: compact hour + minute on one row (no text field) */
.template-timeslot-time-cell {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    min-width: 0;
    max-width: 100%;
}
.template-timeslot-time-dropdowns {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 2px;
    flex-wrap: nowrap;
    min-width: 0;
}
.template-grid-table .template-timeslot-time-cell select.template-timeslot-hour,
.template-grid-table .template-timeslot-time-cell select.template-timeslot-minute {
    width: auto;
    min-width: 2.6rem;
    max-width: 3.4rem;
    padding: 3px 2px;
    font-size: 0.875rem;
    flex: 0 0 auto;
}
.template-timeslot-sep {
    font-variant-numeric: tabular-nums;
    user-select: none;
    color: #495057;
    flex: 0 0 auto;
    padding: 0 1px;
    font-size: 0.9rem;
}

/* Patterns: start_times — horizontal dropdowns, + at end */
.template-patterns-start-times {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.template-patterns-st-slot {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 2px;
    flex: 0 0 auto;
}
.template-grid-table .template-patterns-st-select {
    width: auto;
    min-width: 4.25rem;
    max-width: 5.5rem;
    padding: 3px 4px;
    font-size: 0.875rem;
}
.template-patterns-st-remove {
    padding: 2px 6px;
    line-height: 1.2;
    flex-shrink: 0;
}
.template-patterns-st-add {
    padding: 2px 8px;
    line-height: 1.2;
    flex-shrink: 0;
    font-weight: 600;
}

/* Patterns: days — single dropdown */
.template-patterns-days-cell {
    min-width: 0;
}
.template-grid-table .template-patterns-days-select {
    width: 100%;
    max-width: 100%;
    font-size: 0.875rem;
}

/* Compact multi-selects (e.g., required_features / cohorts) to reduce row height.
   Expands on focus for easier editing. */
.template-grid-table select[multiple].template-editor-multiselect-compact {
    height: 2.2em;
    overflow-y: auto;
}
.template-grid-table select[multiple].template-editor-multiselect-compact:focus {
    height: 10em;
}

/* Sections: instructor_id — same font/border as other grid selects (wrapper draws border; select is invisible) */
.template-instructor-cell {
    position: relative;
    width: 100%;
    box-sizing: border-box;
    display: block;
    min-height: calc(1.25em + 10px);
    border: 1px solid #000;
    border-radius: 2px;
    background: #fff;
    color: #333;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.25;
}

.template-instructor-cell:has(.template-instructor-select:disabled) {
    background: #e9ecef;
    color: #495057;
}

/* Dropdown affordance (native arrow hidden with invisible select) */
.template-instructor-cell::after {
    content: '';
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid #495057;
    pointer-events: none;
    z-index: 2;
}

.template-instructor-cell .template-instructor-display {
    position: absolute;
    left: 4px;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 1;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.25;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Full-cell hit target; opacity 0 keeps id + chevron visible “through” the select */
.template-instructor-cell .template-instructor-select {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    min-height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    opacity: 0;
    z-index: 3;
    cursor: pointer;
    background: transparent;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 1rem;
    font-weight: 400;
    box-sizing: border-box;
}

.template-instructor-cell .template-instructor-select:disabled {
    cursor: not-allowed;
}

.template-instructor-cell:focus-within {
    outline: 2px solid #667eea;
    outline-offset: 0;
    border-color: #667eea;
}

.template-grid-table th {
    max-width: 96px;
    min-width: 72px;
    white-space: normal;
    word-break: break-word;
    line-height: 1.1;
    vertical-align: top;
    text-align: left;
    position: sticky;
    top: 0;
    background: #f8f9fa;
    z-index: 2;
}

/* Stacked one-word-per-line headers; width set in JS from longest word */
.template-grid-table th.template-header-wrapped {
    text-align: center;
    line-height: 1.15;
    word-break: normal;
    overflow-wrap: normal;
    hyphens: none;
    padding: 3px 2px;
}

.template-grid-table td {
    vertical-align: top;
    overflow: visible;
}

/* Override global th { min-width: 72px } so delete column stays narrow */
.template-grid-table th.template-row-actions,
.template-grid-table td.template-row-actions {
    width: 22px;
    min-width: 22px !important;
    max-width: 28px;
    padding: 1px 2px;
    text-align: center;
    vertical-align: middle;
    box-sizing: border-box;
}

.template-row-actions {
    width: 22px;
    min-width: 22px;
    text-align: center;
}

.template-row-actions .btn {
    padding: 1px 4px;
    min-width: 18px;
    line-height: 1;
    font-size: 0.75rem;
}

.stacked-selects {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stacked-select-row {
    display: flex;
    gap: 4px;
    align-items: center;
}

.stacked-select-row select {
    flex: 1 1 auto;
    min-width: 0;
}

.stacked-select-row .btn {
    flex: 0 0 auto;
}

.stacked-select-row .btn,
.stacked-select-actions .btn {
    padding: 2px 6px;
}

body.template-editor-open {
    overflow: hidden;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .nav-tabs {
        flex-direction: column;
    }
    
    .nav-tab {
        border-right: none;
        border-bottom: 1px solid #eee;
    }
    
    .schedule-grid {
        font-size: 0.8rem;
    }
    
    .schedule-cell {
        min-height: 40px;
        padding: 0.25rem;
    }
}

/* Timetable Engine custom dialog (replaces browser confirm so title is not the hostname) */
.timetable-engine-dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 25000;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.timetable-engine-dialog {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-width: 420px;
    width: 100%;
    padding: 1rem 1.15rem;
    border: 1px solid #e5e7eb;
}

.timetable-engine-dialog-title {
    margin: 0 0 0.65rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
}

.timetable-engine-dialog-message {
    margin: 0 0 1rem 0;
    font-size: 0.92rem;
    line-height: 1.45;
    color: #374151;
    white-space: pre-line;
}

.timetable-engine-dialog-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
}
