/* DocPoint Timetable Grid Styles */
/*
 * Duration-based sizing: Each event box scales proportionally to its actual duration
 * and is positioned based on its actual start time.
 * Example: 14:00-15:03 (63 min) will span from 14:00 row to 15:03 position
 */
.docpoint-timetable-grid {
    width: 100%;
    margin: 30px 0;
    padding: 0;
}

/* Venue Filter Tags */
.venue-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    padding: 0;
}

.filter-tag {
    display: inline-block;
    padding: 8px 16px;
    background: #f5f5f5;
    color: #666;
    border: 2px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.filter-tag:hover {
    background: #e8e8e8;
    border-color: #ccc;
}

.filter-tag.active {
    background: var(--enfold-main-color-primary, #e74c3c);
    color: #fff;
    border-color: var(--enfold-main-color-primary, #e74c3c);
}

.filter-tag.active:hover {
    background: var(--enfold-main-color-secondary, #c0392b);
    border-color: var(--enfold-main-color-secondary, #c0392b);
}

.filter-tag[data-venue="all"] {
    font-weight: 600;
    background: #fff;
    border-color: #999;
}

.filter-tag[data-venue="all"].active {
    background: var(--enfold-main-color-primary, #e74c3c);
    border-color: var(--enfold-main-color-primary, #e74c3c);
    color: #fff;
}

.timetable-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    cursor: grab;
    position: relative;
}

.timetable-wrapper:active {
    cursor: grabbing;
}

/* Custom scrollbar for desktop browsers - Always visible */
.timetable-wrapper::-webkit-scrollbar {
    height: 14px;
    -webkit-appearance: none;
}

.timetable-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 0 0 8px 8px;
    border: 1px solid #ddd;
}

.timetable-wrapper::-webkit-scrollbar-thumb {
    background: #666;
    border-radius: 7px;
    border: 2px solid #f1f1f1;
    min-width: 50px;
}

.timetable-wrapper::-webkit-scrollbar-thumb:hover {
    background: #444;
}

.timetable-wrapper::-webkit-scrollbar-thumb:active {
    background: #333;
}

/* Firefox scrollbar styling */
.timetable-wrapper {
    scrollbar-width: auto;
    /* Use 'auto' instead of 'thin' for better visibility */
    scrollbar-color: #666 #f1f1f1;
}

/* Scroll indicators (shadows on edges) */
.timetable-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 12px;
    /* Above scrollbar */
    width: 20px;
    pointer-events: none;
    z-index: 25;
    transition: opacity 0.3s;
    left: 80px;
    /* After time column */
    background: linear-gradient(to right, rgba(0, 0, 0, 0.1), transparent);
    opacity: 0;
}

.timetable-wrapper.can-scroll-left::before {
    opacity: 1;
}

/* Header Grid */
.timetable-header-grid {
    display: grid;
    /* grid-template-columns set inline via PHP based on venue count */
    min-width: min-content;
    background: #fff;
    color: #000;
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 2px solid #ddd;
}

.time-header,
.venue-header {
    padding: 15px 10px;
    font-weight: bold;
    text-align: center;
    border-right: 1px solid #ddd;
    background: #fff;
    color: #000;
}

.time-header {
    font-size: 14px;
    position: sticky;
    left: 0;
    z-index: 30;
    max-width: 80px;
    width: 80px;
}

.venue-header {
    font-size: 14px;
    line-height: 1.3;
    min-width: 180px;
}

/* Timetable Body */
.timetable-body {
    display: grid;
    /* grid-template-columns set inline via PHP based on venue count */
    min-width: min-content;
    min-height: 400px;
}

/* Time Markers Column */
.time-markers {
    border-right: 2px solid #ddd;
    background: #fff;
    position: sticky;
    left: 0;
    z-index: 15;
    max-width: 80px;
    width: 80px;
}

.time-marker {
    height: 60px;
    /* 1 hour = 60px */
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 5px;
    font-weight: bold;
    font-size: 13px;
    color: #333;
    background: #fff;
}

/* Venue Columns */
.venue-column {
    position: relative;
    border-right: 1px solid #ddd;
    background: #fff;
    min-width: 180px;
}

/* Background time grid */
.time-slot {
    height: 60px;
    /* Match time marker height */
    border-bottom: 1px solid #e8e8e8;
    background: #fff;
}

/* Event Items - Positioned Absolutely */
.event-item {
    position: absolute;
    /* left and width are set inline for overlap handling */
    top: calc(var(--start-offset, 0) * 1px);
    /* Position based on start time */
    height: calc(var(--duration, 90) * 1px);
    /* Height based on duration */
    min-height: 50px;
    padding: 8px;
    background: var(--enfold-main-color-primary, #e74c3c);
    color: #fff;
    border-radius: 4px;
    transition: all 0.3s ease;
    overflow: hidden;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.event-item[data-link] {
    cursor: pointer;
}

.event-item:hover {
    z-index: 15;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.event-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
}

.event-link {
    text-decoration: none;
    color: #fff !important;
    width: 100%;
}

.event-link:hover .event-name {
    text-decoration: underline;
}

.event-name {
    font-size: 13px;
    font-weight: bold;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #fff !important;
    word-break: break-word;
    hyphens: auto;
}

.event-time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.9);
    margin-top: 4px;
}

/* Events post type styling - white background with custom text colors */
.event-item[data-event-type="events"] {
    background: #fff;
    border: 2px solid var(--enfold-main-color-border, #ddd);
    min-height: 70px;
}

.event-item[data-event-type="events"] .event-name {
    color: var(--enfold-socket-color-primary, #333) !important;
}

.event-item[data-event-type="events"] .event-time {
    color: var(--enfold-socket-color-primary, #666);
}

.event-item[data-event-type="events"] .event-link {
    color: var(--enfold-main-color-border, #333) !important;
}

/* Color coding by venue - Optional: uncomment to use different colors per venue */
/*
.venue-column[data-venue="kinopalatsi-6"] .event-item {
    background: #e74c3c;
}

.venue-column[data-venue="maxim-1"] .event-item {
    background: #3498db;
}

.venue-column[data-venue="kinopalatsi-5"] .event-item {
    background: #2ecc71;
}

.venue-column[data-venue="bio-rex-lasipalatsi"] .event-item {
    background: #f39c12;
}

.venue-column[data-venue="kiasma-teatteri"] .event-item {
    background: #9b59b6;
}
*/

/* Tablet */
@media (max-width: 989px) {
    .venue-header {
        padding: 12px 8px;
        font-size: 13px;
        min-width: 160px;
    }

    .time-header {
        padding: 12px 8px;
        font-size: 13px;
    }

    .time-marker {
        height: 50px;
        /* Smaller hour blocks on tablet */
        font-size: 12px;
    }

    .time-slot {
        height: 50px;
    }

    .venue-column {
        min-width: 160px;
    }

    .event-item {
        /* Adjust scaling for smaller time blocks */
        top: calc(var(--start-offset, 0) * 0.833px);
        /* 50/60 = 0.833 */
        height: calc(var(--duration, 90) * 0.833px);
    }

    .event-name {
        font-size: 12px;
    }

    .event-time {
        font-size: 10px;
    }
}

/* Mobile */
@media (max-width: 767px) {
    .docpoint-timetable-grid {
        margin: 20px 0;
    }

    .venue-filters {
        gap: 6px;
        margin-bottom: 15px;
    }

    .filter-tag {
        padding: 6px 12px;
        font-size: 12px;
        border-radius: 16px;
    }

    .timetable-wrapper {
        border-radius: 4px;
    }

    .venue-header {
        padding: 10px 5px;
        font-size: 11px;
        min-width: 130px;
    }

    .time-header {
        padding: 10px 5px;
        font-size: 11px;
    }

    .time-marker {
        height: 40px;
        /* Even smaller on mobile */
        font-size: 10px;
    }

    .time-slot {
        height: 40px;
    }

    .venue-column {
        min-width: 130px;
    }

    .event-item {
        /* Adjust scaling for mobile time blocks */
        top: calc(var(--start-offset, 0) * 0.667px);
        /* 40/60 = 0.667 */
        height: calc(var(--duration, 90) * 0.667px);
        min-height: 25px;
        padding: 6px;
    }

    .event-name {
        font-size: 11px;
    }

    .event-time {
        font-size: 9px;
    }
}

/* Small Mobile (iPhone SE, etc) */
@media (max-width: 374px) {
    .venue-header {
        padding: 8px 4px;
        font-size: 10px;
        min-width: 110px;
    }

    .time-header {
        padding: 8px 4px;
        font-size: 10px;
    }

    .time-marker {
        height: 35px;
        font-size: 9px;
    }

    .time-slot {
        height: 35px;
    }

    .venue-column {
        min-width: 110px;
    }

    .event-item {
        top: calc(var(--start-offset, 0) * 0.583px);
        /* 35/60 = 0.583 */
        height: calc(var(--duration, 90) * 0.583px);
        min-height: 22px;
        padding: 4px;
    }

    .event-name {
        font-size: 10px;
    }

    .event-time {
        font-size: 8px;
    }
}

/* Print styles */
@media print {
    .timetable-wrapper {
        border: 1px solid #000;
    }

    .timetable-header-grid {
        background: #eee !important;
        color: #000 !important;
        border-bottom: 2px solid #000;
    }

    .time-header,
    .venue-header {
        border-right: 1px solid #000;
    }

    .time-markers {
        border-right: 2px solid #000;
    }

    .venue-column {
        border-right: 1px solid #000;
    }

    .time-marker,
    .time-slot {
        border-bottom: 1px solid #000;
    }

    .event-item {
        page-break-inside: avoid;
    }
}