/**
 * Gantt Chart Styles - Complete Layout, Events, Filters, and Modal
 * Consolidated from gantt-layout.css, gantt-events.css, gantt-scrollbars.css, gantt-filters.css, gantt-modal.css, and gantt.css
 */

/* ===========================================
   CSS CUSTOM PROPERTIES
   =========================================== */

:root {
    --gantt-time-column-width: 100px;
    --gantt-place-column-width: 180px;
    --gantt-place-count: 1;
}

/* Dynamic Grid Layout Class */
.gantt-grid-layout {
    grid-template-columns: var(--gantt-time-column-width) repeat(var(--gantt-place-count), var(--gantt-place-column-width));
    transition: grid-template-columns 0.2s ease;
}

/* Timeline container grid layout - hybrid approach */
.timeline-container {
    display: flex;
    position: relative;
    min-height: 400px;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}



/* ===========================================
   GANTT CONTAINER AND LAYOUT
   =========================================== */

.gantt-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    position: relative;
    flex: 1;
    /* Take available space in main container */
    min-height: 500px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent container itself from scrolling */
    margin-top: 0; /* Remove any default margin */
}

.gantt-container * {
    box-sizing: border-box;
}

.gantt-content {
    flex: 1;
    position: relative;
    height: 100%;
    overflow: auto;
    /* Only the content area should scroll */
    scrollbar-width: thin;
    scrollbar-color: var(--color-neutral-400) var(--color-neutral-50);
}

/* Places header - horizontal row with place names as columns */
.places-header {
    display: grid;
    background: var(--color-neutral-50);
    border-bottom: 2px solid var(--color-neutral-200);
    position: sticky;
    top: 0;
    z-index: 200;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--color-neutral-500);
    min-height: 60px;
    min-width: max-content;
    /* Allow horizontal scrolling when needed */
}

.place-header-cell {
    padding: 0.75rem 0.5rem;
    position: relative;
    text-align: center;
    border-right: 1px solid var(--color-neutral-200);
    background: var(--color-neutral-600);
    color: white;
    min-width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    word-wrap: break-word;
    overflow: hidden;
    font-size: 0.8rem;
    line-height: 1.2;
}

/* Subtle alternating colors for place header cells */
.place-header-cell:nth-child(even):not(.time-header) {
    background: var(--color-neutral-600);
}

.place-header-cell:nth-child(odd):not(.time-header) {
    background: var(--color-neutral-500);
}

.place-header-cell.time-header {
    position: sticky;
    left: 0;
    z-index: 101;
}

/* Place header name and eye icon layout */

.place-header-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.place-exclusion-eye {
    position: absolute;
    top: 4px;
    right: 4px;
    cursor: pointer;
    font-size: 12px;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    z-index: 10;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
    padding: 1px 3px;
}

.place-exclusion-eye:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.2);
}

.gantt-grid {
    display: flex;
    flex-direction: column;
    position: relative;
    min-width: max-content;
    /* Allow horizontal scrolling when needed */
}

/* Timeline containers - each represents a day with vertical time flow */
/* Note: Grid layout is defined in CSS custom properties section above */

/* Time markers column - leftmost column showing time vertically */
.time-markers-column {
    width: var(--gantt-time-column-width);
    transition: width 0.2s ease;
    min-width: 20px;
    max-width: 100px;
    border-right: 2px solid var(--color-neutral-200);
    position: sticky;
    left: 0;
    z-index: 150;
}

.time-marker {
    position: absolute;
    left: 0;
    right: 0;
    height: var(--gantt-pixels-per-hour);
    border-top: 1px solid var(--color-neutral-200);
    border-bottom: 1px solid var(--color-neutral-200);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: sideways-lr;
    background: var(--color-neutral-500);
}

/* Place columns - each column represents a place with events positioned vertically by time */
.place-column {
    position: relative;
    border-right: 1px solid var(--color-neutral-200);
    width: var(--gantt-place-column-width);
    transition: width 0.2s ease;
    /* Default width */
    background: white;
    overflow: visible;
    /* Allow events to be properly visible */
    flex-shrink: 0;
    /* Prevent columns from shrinking */
}

.place-column:nth-child(even) {
    background: var(--color-neutral-50);
}

.place-column:nth-child(odd) {
    background: white;
}

/* Expanded columns for crowded events */
.place-column.expanded-column {
    min-width: unset;
    /* Override the default min-width */
    flex-shrink: 0;
    /* Prevent shrinking */
}

/* ===========================================
   EVENT BLOCKS AND TITLES
   =========================================== */

.event-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    text-shadow: var(--text-shadow-medium);
    line-height: 1.2;
    /* overflow: hidden; */
    text-overflow: ellipsis;
    /* white-space: nowrap; */
    flex: 1;
}

.event-block:hover .event-title {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    font-weight: 600;
}

/* Vertical text styles */
.event-block.vertical-text {
    border-width: 2px; /* Consistent border for narrow blocks */
}

.event-block.vertical-text .event-title {
    writing-mode: sideways-lr;
    text-orientation: mixed;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.7rem;
    line-height: 1;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-shadow: var(--text-shadow-strong);
    padding-right: 0px;
}

.event-block.vertical-text .event-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 4px 2px;
}

.event-block.vertical-text .event-favorite {
    writing-mode: initial;
    transform: none;
    font-size: 0.7rem;
    margin: 0;
}

/* Tall Event Blocks */
.tall-block .event-title {
    white-space: normal;
    word-wrap: break-word;
    hyphens: auto;
}

.event-block.tall-block .event-title {
    white-space: normal;
    word-wrap: break-word;
    hyphens: auto;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ===========================================
   SCROLLBAR STYLING
   =========================================== */

.gantt-content::-webkit-scrollbar-corner {
    background: var(--color-neutral-200);
}

.gantt-content::-webkit-scrollbar {
    width: 14px;
    height: 14px;
    display: block !important;
}

.gantt-content::-webkit-scrollbar-track {
    background: var(--color-neutral-50);
    border-radius: 6px;
    border: 1px solid var(--color-neutral-200);
}

.gantt-content::-webkit-scrollbar-thumb {
    background: var(--color-neutral-400);
    border-radius: 6px;
    border: 2px solid var(--color-neutral-50);
    min-height: 30px;
    min-width: 30px;
}

.gantt-content::-webkit-scrollbar-thumb:hover {
    background: var(--color-neutral-500);
}

.gantt-content::-webkit-scrollbar-thumb:active {
    background: var(--color-neutral-500);
}

/* ===========================================
   PLACE FILTER DROPDOWN
   =========================================== */

.place-filter {
    position: absolute;
    top: calc(var(--header-height-desktop) + var(--header-safe-margin-desktop));
    right: 20px;
    z-index: 1000;
    /* Higher z-index to appear above everything */
    background: white;
    border-radius: 12px;
    border: 2px solid var(--color-primary);
    box-shadow: var(--shadow-gantt-hover);
    max-width: 420px;
    width: 420px;
    backdrop-filter: blur(10px);
    transform-origin: top right;
    transform: scale(0.9) translateY(-10px);
    transition: all 0.1s cubic-bezier(0.4, 0, 0.2, 1);
    display: none;
    /* Use modal pattern */
}

/* Show place filter using modal pattern */
.place-filter.modal--visible {
    display: block !important;
}

.place-filter-content {
    max-height: 450px;
    overflow: hidden;
    transition: all 0.1s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 10px;
}

.place-checkboxes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* Two equal columns */
    gap: 0.8rem;
    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
    padding: 1rem;
    background: white;
    box-sizing: border-box;
    align-items: stretch;
    /* Make buttons in same row same height */
}

.filter-actions {
    padding: 0.8rem 1rem;
    display: flex;
    gap: 0.8rem;
    justify-content: center;
    border-top: 1px solid var(--color-neutral-200);
    background: var(--color-neutral-50);
    border-radius: 0 0 10px 10px;
}

/* ===========================================
   MODAL DIALOG
   =========================================== */

.modal {
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: var(--color-surface-modal);
    backdrop-filter: blur(8px);
    transition: opacity 0.1s ease;
    display: none;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn 0.2s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-header {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.1s ease, transform 0.1s ease;
}

.modal-close:hover {
    background: var(--color-surface-highlight);
}

.modal-close:active {
    transform: scale(0.9);
}

.modal-body {
    padding: 1.5rem;
}

/* ===========================================
   TIMELINE STYLES
   =========================================== */

/* Time Markers */
.time-marker-hour {
    font-weight: 600;
}

.time-marker-half {
    font-weight: 600;
    opacity: 0.7;
}

/* Event Blocks */
.event-block {
    cursor: pointer;
    border-radius: 6px;
    border: 2px solid;
    box-shadow: var(--shadow-md);
    transition: all 0.05s ease-in-out, background 0.00001ms;
    overflow: hidden;
    position: absolute;
    /* Absolute positioning for time-based placement */
    min-height: 30px;
    /* Minimum height for readability */
    z-index: 10;
    /* Positioning will be set by .event-positioned class */
    background: var(--event-bg-color, var(--color-neutral-400));
    border-color: var(--event-border-color, var(--color-neutral-500));
    backdrop-filter: blur(1px);
}

/* Event positioning using CSS custom properties */
.event-positioned {
    top: var(--event-top, 0);
    height: var(--event-height, 30px);
    width: var(--event-width, 100%);
    left: var(--event-left, 0%);
    z-index: var(--event-z-index, 10);
}

.event-block:hover {
    box-shadow: 0 4px 11px 5px rgb(0 0 0 / 40%);
    z-index: 55;
}

/* Favorited Event Glow Effect */
.event-block--favorited {
    background: radial-gradient(circle at right top, var(--color-favorite-glow-soft), var(--event-bg-color) 65%);
    transition: all 0.05s ease-in-out;
}

/* .event-block--favorited:hover {
    transform: scale(1.02);
    z-index: 20;
} */

/* Event Content */
.event-content {
    padding: 6px 8px;
    display: flex;
    align-items: flex-start;
    padding-right: 2rem;
    align-items: center;
    gap: 4px;
    height: 100%;
    position: relative;
}

/* Event Favorite Star */
.event-favorite {
    color: var(--color-favorite-star);
    text-shadow: var(--text-shadow-light);
    font-size: 0.8rem;
    flex-shrink: 0;
    line-height: 1;
    margin-top: 1px;
}

/* ===========================================
   ANIMATIONS
   =========================================== */

@keyframes tooltip-fadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-100%) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(-100%) scale(1);
    }
}

/* Day Separator - Grid layout defined in CSS custom properties section above */

/* Day separator grid layout */
.day-separator {
    position: sticky;
    top: 60px;
    z-index: 151;
    background: var(--color-neutral-500);
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    min-height: 40px;
    height: 40px;
    border-bottom: 2px solid var(--color-neutral-600);
    box-shadow: var(--shadow-md);
    width: 100%;
    display: grid;
    align-items: center;
    margin: 0;
    overflow: hidden;
    grid-template-columns: var(--gantt-time-column-width) repeat(var(--gantt-place-count), var(--gantt-place-column-width));
}

.day-separator-time {
    background: rgba(74, 85, 104, 0.95);
    color: white;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 2px solid rgba(255, 255, 255, 0.2);
    position: sticky;
    left: 0;
    z-index: 46;
}

.day-separator-content {
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Centered day text overlay - stays in center during horizontal scroll */
.day-separator-centered {
    position: absolute;
    left: 50vw;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    z-index: 47;
    pointer-events: none;
}

.day-separator-inner {
    font-size: 0.9rem;
    letter-spacing: 1px;
    /* position: absolute;
    left: 5%; */
}

/* ===========================================
   CUSTOM TOOLTIP STYLES
   =========================================== */

/* Custom JavaScript Tooltip */
.custom-event-tooltip {
    background: var(--color-surface-tooltip);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-size: 0.85rem;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-light);
    max-width: 280px;
    min-width: 150px;
    opacity: 0;
    transition: opacity 0.1s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    pointer-events: none;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    line-height: 1.4;
}

.custom-event-tooltip.tooltip-animate {
    opacity: 1;
}

.custom-event-tooltip .tooltip-title {
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: #ffffff;
    line-height: 1.3;
    font-size: 0.9rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.custom-event-tooltip .tooltip-time {
    font-size: 0.75rem;
    color: #e0e0e0;
    margin-bottom: 0.2rem;
    font-weight: 500;
    white-space: nowrap;
}

.custom-event-tooltip .tooltip-place {
    font-size: 0.75rem;
    color: #c0c0c0;
    font-style: italic;
    font-weight: 400;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Horizontal time grid lines - added via JavaScript for dynamic placement */
.time-grid-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--color-neutral-200);
    z-index: 5;
    pointer-events: none;
    /* Don't interfere with event interactions */
}

.time-grid-line.hour-line {
    background: var(--color-neutral-300);
    height: 1px;
}

.time-grid-line.half-hour-line {
    background: var(--color-neutral-100);
    height: 1px;
    opacity: 0.6;
}

/* Enhanced time row highlighting on hover */
/* .timeline-container:hover .time-grid-line.hour-line {
    background: var(--color-neutral-400);
    height: 2px;
    transition: all 0.2s ease;
} */

/* Subtle time zone highlighting - every 2 hours get subtle background difference */
/* Updated to use CSS custom properties for maintainable sizing */
/* .timeline-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(to bottom,
        transparent 0px,
        transparent calc(var(--gantt-pixels-per-hour) * 2),
        rgba(102, 126, 234, 0.03) calc(var(--gantt-pixels-per-hour) * 2),
        rgba(102, 126, 234, 0.03) calc(var(--gantt-pixels-per-hour) * 4));
    pointer-events: none;
    z-index: 1;
} */

/* Enhanced place column alternating colors */

/* ===========================================
   RESPONSIVE PLACE FILTER
   =========================================== */

@media (max-width: 768px) {
    .place-filter {
        position: fixed;
        top: calc(var(--header-height-tablet) + 10px);
        left: 10px;
        right: 10px;
        width: auto;
        max-width: none;
        transform-origin: top center;
    }
    
    .place-checkboxes {
        gap: 0.6rem;
        max-height: 300px;
        padding: 0.8rem;
    }
}

@media (max-width: 480px) {
    .place-filter {
        top: calc(var(--header-height-mobile) + 5px);
        left: 5px;
        right: 5px;
    }
    
    .place-filter-content {
        max-height: 350px;
    }
    
    .place-checkboxes {
        max-height: 250px;
        padding: 0.6rem;
        gap: 0.4rem;
    }
    
    .filter-actions {
        padding: 0.6rem 0.8rem;
        gap: 0.6rem;
    }
}

/* ===========================================
   ZOOM CONTROLS
   =========================================== */

/* ZOOM CONTROLS - repositioned to bottom right, visible only on desktop/tablet */
.zoom-controls {
    position: fixed;
    right: 32px;
    bottom: 32px;
    z-index: 1200;
    background: #fff;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    border-radius: 8px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 0;
    transition: opacity 0.2s, transform 0.2s;
}

@media (max-width: 900px) {
    .zoom-controls {
        right: 12px;
        bottom: 12px;
        padding: 6px 10px;
    }
}

@media (max-width: 768px) {
    .zoom-controls {
        display: none !important;
    }
}