:root {
    --timetable-slot-height: 48px;
    --timetable-time-column-width: 80px;
    --timetable-location-min-width: 150px;
    --timetable-day-title-offset: 100px;
}

#timetableContent.timetable-fullbleed {
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    padding-left: 0 !important;
    padding-right: 0 !important;
    box-sizing: border-box;
}

.timetable-page-header {
    padding: 0 1rem;
}

.timetable-manager-btn {
    right: 1rem;
}

.timetable-empty {
    margin-left: 1rem;
    margin-right: 1rem;
}

.timetable-wrapper {
    background: #f8f9fa;
    border-radius: 14px;
    overflow: hidden;
    width: 100%;
    max-width: none;
    margin: 0;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
}

.timetable-scroll {
    overflow: auto;
    width: 100%;
    max-width: 100%;
    max-height: 80vh;
    background: #dee2e6;
}

.timetable-header {
    display: grid;
    grid-template-columns: var(--timetable-grid-columns);
    gap: 1px;
    background: #cfd4da;
    width: max-content;
    min-width: 100%;
    position: sticky;
    top: 0;
    z-index: 40;
}

.time-column-header,
.location-header,
.time-column,
.location-column {
    background: #f8f9fa;
}

.time-column-header {
    background: #4b525a;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    border-right: 2px solid #3c4248;
}

.location-header {
    background: #4b525a;
    color: #fff;
    padding: 12px 10px;
    text-align: center;
    min-height: 64px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
}

.location-header strong {
    font-size: 0.95rem;
    line-height: 1.15;
}

.location-header .location-type {
    font-size: 0.72rem;
    padding: 2px 8px;
}

.location-details-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffd700;
    border: 1px solid rgba(255, 215, 0, 0.45);
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    padding: 3px 8px;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.location-details-link:hover {
    color: #23272b;
    background: #ffd700;
}

.location-type[data-type="indoor"] { background-color: #0d6efd; }
.location-type[data-type="outdoor"] { background-color: #198754; }
.location-type[data-type="external"] { background-color: #fd7e14; }

.day-section {
    margin: 0;
    position: relative;
    overflow: visible;
    z-index: 0;
}

.day-section + .day-section {
    border-top: none;
}

.day-header {
    display: none;
}

.timetable-grid {
    display: grid;
    grid-template-columns: var(--timetable-grid-columns);
    gap: 1px;
    background: #cfd4da;
    width: max-content;
    min-width: 100%;
}

.time-column {
    position: sticky;
    left: 0;
    z-index: 20;
    border-right: 2px solid #3c4248;
}

.time-slot {
    height: var(--timetable-slot-height);
    padding: 8px 10px;
    background: #f4f6f8;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
    font-size: 0.9rem;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #495057;
}

.night-break-slot {
    background: #eceff3;
}

.location-column {
    position: relative;
    overflow: visible;
}

.hour-block {
    height: var(--timetable-slot-height);
    min-height: var(--timetable-slot-height);
    border-bottom: 1px solid #dee2e6;
    position: relative;
    overflow: visible;
    box-sizing: border-box;
}

.event-block {
    color: white;
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    border: 1px solid #0a58ca;
    position: absolute;
    overflow: hidden;
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
    z-index: 5;
    box-sizing: border-box;
    background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);
}

.event-block:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
}

.event-block.event-soon {
    background: linear-gradient(135deg, #ffc107 0%, #ffb300 100%);
    border-color: #ff9800;
}

.event-block.event-progress {
    background: linear-gradient(135deg, #28a745 0%, #218838 100%);
    border-color: #1e7e34;
    box-shadow: 0 0 12px rgba(40, 167, 69, 0.45);
}

.event-block.event-finished {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    border-color: #545b62;
    opacity: 0.72;
}

.event-block.event-delayed {
    background: linear-gradient(135deg, #f7c7cc 0%, #ef9aa3 100%);
    border-color: #dc7a85;
    color: #4a1f24;
}

.event-block.event-overnight-start {
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    border-bottom-width: 1px;
    z-index: 20;
}

.event-block.event-overnight-continuation {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-top-width: 0;
    margin-top: -1px;
    z-index: 21;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
}

.event-block.event-overnight-continuation.event-progress {
    background: linear-gradient(135deg, #28a745 0%, #218838 100%);
    border-color: #1e7e34;
}

.event-block.event-overnight-continuation.event-soon {
    background: linear-gradient(135deg, #ffc107 0%, #ffb300 100%);
    border-color: #ff9800;
}

.event-block.event-overnight-continuation.event-finished {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    border-color: #545b62;
    opacity: 0.72;
}

.event-block.event-overnight-continuation .overnight-continuation-midnight {
    display: none;
}

.event-block.event-overnight-continuation .event-content,
.event-block.event-overnight-continuation .event-progress-bar {
    display: block;
}

.event-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.9);
    width: 0%;
    transition: width 0.1s linear;
    z-index: 2;
}

.event-content {
    position: relative;
    z-index: 3;
    font-size: 0.85rem;
    transition: transform 0.2s ease-out;
}

.event-admin-edit-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.55);
    background: rgba(0, 0, 0, 0.28);
    color: #fff;
    font-size: 0.72rem;
    line-height: 1;
    text-decoration: none;
}

.event-admin-edit-btn:hover {
    background: #ffc107;
    color: #1f2328;
    border-color: #ffd54f;
}

.event-block.event-delayed .event-admin-edit-btn {
    border-color: rgba(74, 31, 36, 0.45);
    background: rgba(255, 255, 255, 0.28);
    color: #4a1f24;
}

.event-block.event-delayed .event-admin-edit-btn:hover {
    background: #dc3545;
    border-color: #dc3545;
    color: #fff;
}

.event-content strong {
    display: block;
    font-weight: 700;
    margin-bottom: 2px;
}

.event-time {
    font-size: 0.75rem;
    opacity: 0.9;
    margin-bottom: 2px;
}

.event-time-old {
    text-decoration: line-through;
    opacity: 0.82;
    margin-right: 6px;
}

.event-time-new {
    font-weight: 700;
}

.event-time-old,
.event-time-new {
    display: inline-block;
}

.event-remaining {
    font-size: 0.75rem;
    opacity: 0.85;
    font-style: italic;
}

.current-time-indicator {
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    background: #dc3545;
    box-shadow: 0 0 6px rgba(220, 53, 69, 0.8);
    z-index: 10;
    display: none;
    pointer-events: none;
}

.current-time-indicator::before,
.current-time-indicator::after {
    content: '';
    position: absolute;
    top: -6px;
    width: 12px;
    height: 12px;
    background: #dc3545;
    border-radius: 50%;
    box-shadow: 0 0 4px rgba(220, 53, 69, 0.8);
}

.current-time-indicator::before { left: -6px; }
.current-time-indicator::after { right: -6px; }

.modal-header {
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
}

.modal-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: #495057;
}

.modal-body {
    padding: 20px;
}

.modal-body p {
    margin-bottom: 12px;
    line-height: 1.6;
    color: #212529;
}

.modal-body strong {
    color: #495057;
}

.hour-block.night-break-slot {
    background: #eceff3;
    display: flex;
    align-items: center;
    justify-content: center;
}

.night-break-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #5f6770;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.day-bg-text {
    font-size: 1.1rem;
    font-weight: 800;
    color: rgba(120, 130, 140, 0.25);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    pointer-events: none;
    user-select: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    text-align: center;
    z-index: 1;
}

.hour-block.day-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Thursday - Purple */
.hour-block[data-block-day="Thursday"][data-time$=":00"], .time-slot[data-block-day="Thursday"][data-time$=":00"] { background: linear-gradient(135deg, #ece4f2 0%, #e0d0eb 100%); }
.hour-block[data-block-day="Thursday"][data-time$=":30"], .time-slot[data-block-day="Thursday"][data-time$=":30"] { background: linear-gradient(135deg, #e0d0eb 0%, #d4bce3 100%); }
.hour-block[data-block-day="Thursday"] .day-bg-text { color: rgba(156, 39, 176, 0.25); }

/* Friday - Blue */
.hour-block[data-block-day="Friday"][data-time$=":00"], .time-slot[data-block-day="Friday"][data-time$=":00"] { background: linear-gradient(135deg, #e0f0fa 0%, #cce5f7 100%); }
.hour-block[data-block-day="Friday"][data-time$=":30"], .time-slot[data-block-day="Friday"][data-time$=":30"] { background: linear-gradient(135deg, #cce5f7 0%, #b8daf4 100%); }
.hour-block[data-block-day="Friday"] .day-bg-text { color: rgba(33, 150, 243, 0.25); }

/* Saturday - Green */
.hour-block[data-block-day="Saturday"][data-time$=":00"], .time-slot[data-block-day="Saturday"][data-time$=":00"] { background: linear-gradient(135deg, #e3f2e3 0%, #d0ebd0 100%); }
.hour-block[data-block-day="Saturday"][data-time$=":30"], .time-slot[data-block-day="Saturday"][data-time$=":30"] { background: linear-gradient(135deg, #d0ebd0 0%, #bbe3bb 100%); }
.hour-block[data-block-day="Saturday"] .day-bg-text { color: rgba(76, 175, 80, 0.25); }

/* Sunday - Orange/Yellow */
.hour-block[data-block-day="Sunday"][data-time$=":00"], .time-slot[data-block-day="Sunday"][data-time$=":00"] { background: linear-gradient(135deg, #fdf0df 0%, #fae2c3 100%); }
.hour-block[data-block-day="Sunday"][data-time$=":30"], .time-slot[data-block-day="Sunday"][data-time$=":30"] { background: linear-gradient(135deg, #fae2c3 0%, #f7d4a6 100%); }
.hour-block[data-block-day="Sunday"] .day-bg-text { color: rgba(255, 152, 0, 0.25); }

@media (max-width: 768px) {
    .timetable-page-header {
        padding: 0 0.75rem;
    }

    :root {
        --timetable-time-column-width: 70px;
        --timetable-location-min-width: 120px;
        --timetable-day-title-offset: 70px;
    }

    .timetable-header,
    .timetable-grid {
        grid-template-columns: var(--timetable-time-column-width) repeat(var(--timetable-location-count), minmax(var(--timetable-location-min-width), 1fr));
    }

    .time-slot {
        height: 40px;
        font-size: 0.8rem;
    }

    .hour-block {
        height: 40px;
        min-height: 40px;
    }

    .event-block {
        padding: 6px;
        font-size: 0.8rem;
    }

    .event-time {
        font-size: 0.7rem;
    }

    .location-header {
        min-height: 50px;
        padding: 8px 4px;
    }

    .location-header strong {
        font-size: 0.85rem;
    }

    .location-header .location-type {
        font-size: 0.7rem;
    }
}

@media (max-width: 576px) {
    :root {
        --timetable-time-column-width: 60px;
        --timetable-location-min-width: 100px;
        --timetable-day-title-offset: 60px;
    }

    .timetable-header,
    .timetable-grid {
        grid-template-columns: var(--timetable-time-column-width) repeat(var(--timetable-location-count), minmax(var(--timetable-location-min-width), 1fr));
    }

    .time-slot {
        height: 36px;
        font-size: 0.75rem;
        padding: 4px;
    }

    .hour-block {
        height: 36px;
        min-height: 36px;
    }

    .event-block {
        padding: 4px;
        font-size: 0.7rem;
        min-height: 40px;
    }

    .event-content strong {
        margin-bottom: 1px;
    }

    .location-header {
        min-height: 45px;
        padding: 6px 2px;
        font-size: 0.75rem;
    }

    .location-header strong {
        font-size: 0.75rem;
    }

    .location-header .location-type {
        font-size: 0.6rem;
        padding: 1px 3px;
    }
}

.timetable-wrapper p {
    color: #212529;
}

.timetable-wrapper .modal-body p {
    color: #212529;
}

