/* ===============================================
   UNIFIED TIMELINE COMPONENT SYSTEM
   ===============================================
   
   Continuous timeline track with tick marks (like a ruler)
   for schedules, allocation, and timekeeping.
   
   Structure:
   - Timeline ruler with major (hourly) and minor (15-min) tick marks
   - Staff/employee rows with blocks positioned on the timeline
   - Horizontal scrolling to view full day
   - Row heights match grid system
*/

/* ===================================
   TIMELINE VARIABLES
   =================================== */

:root {
    --timeline-track-width: 800px;
    --timeline-label-width: 120px;
    --timeline-label-width-md: 100px;
    --timeline-label-width-sm: 80px;
    --timeline-row-height: 48px;
    --timeline-ruler-height: 40px;
}

/* ===================================
   TIMELINE CONTAINER
   =================================== */

.timeline-grid-container {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-sm);
    box-sizing: border-box;
}

/* ===================================
   EXPANDABLE TEAM HEADER
   =================================== */

.timeline-team-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    transition: background-color 0.2s ease;
}

.timeline-team-header:hover {
    background: var(--bg-gray-50);
}

.timeline-team-name {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.timeline-team-summary {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-left: auto;
    margin-right: var(--space-sm);
}

.timeline-expand-arrow {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    background: transparent;
    position: relative;
}

.timeline-expand-arrow:hover {
    background: var(--bg-gray-100);
}

.timeline-expand-arrow::after {
    content: '';
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--text-secondary);
    transition: all 0.2s ease;
}

.timeline-expand-arrow:hover::after {
    border-top-color: var(--text-primary);
}

.timeline-expand-arrow.expanded::after {
    transform: rotate(180deg);
}

/* ===================================
   TIMELINE CONTENT WRAPPER
   =================================== */

.timeline-content {
    padding: var(--space-md);
    overflow-x: auto;
    overflow-y: visible;
    position: relative;
    /* Scrollbar styling inherited from grid.css */
}

/* ===================================
   TIMELINE RULER (Continuous Track)
   =================================== */

.timeline-ruler-container {
    display: grid;
    grid-template-columns: var(--timeline-label-width) 1fr;
    gap: 0;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-white);
}

.timeline-ruler-label {
    padding: var(--space-sm) var(--space-md);
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-light);
    display: flex;
    align-items: flex-end;
    padding-bottom: var(--space-xs);
}

.timeline-ruler-track {
    position: relative;
    min-width: var(--timeline-track-width);
    height: var(--timeline-ruler-height);
    background: var(--bg-secondary);
}

/* Base line for ruler */
.timeline-ruler-track::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--border-medium);
}

/* Tick marks container */
.timeline-ticks {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100%;
}

/* Individual tick mark */
.timeline-tick {
    position: absolute;
    bottom: 0;
    width: 2px;
    background: var(--border-light);
}

/* Major tick (hourly) - taller */
.timeline-tick.major {
    height: 24px;
    background: var(--border-medium);
}

/* Minor tick (15-min) - shorter */
.timeline-tick.minor {
    height: 12px;
    background: var(--border-light);
}

/* Time labels */
.timeline-time-label {
    position: absolute;
    bottom: 14px;
    transform: translateX(-50%);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.timeline-time-label.minor {
    font-size: 10px;
    font-weight: 400;
    color: var(--text-muted);
    bottom: 4px;
}

/* ===================================
   TIMELINE STAFF ROWS
   =================================== */

.timeline-rows-container {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--border-light);
}

.timeline-staff-row {
    display: grid;
    grid-template-columns: var(--timeline-label-width) 1fr;
    gap: 0;
    background: var(--bg-white);
}

.timeline-staff-label {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-light);
    display: flex;
    align-items: center;
}

.timeline-track-container {
    position: relative;
    min-width: var(--timeline-track-width);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-light);
}

/* Empty state background */
.timeline-track-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, 
        var(--bg-gray-25) 0%, 
        var(--bg-white) 25%, 
        var(--bg-white) 75%, 
        var(--bg-gray-25) 100%
    );
    z-index: 0;
}

/* ===================================
   TIMELINE BLOCKS (Tasks/Rooms)
   =================================== */

.timeline-block {
    position: absolute;
    top: 4px;
    height: calc(100% - 8px);
    background: var(--color-primary);
    color: white;
    border-radius: var(--radius-sm);
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--text-xs);
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: grab;
    transition: all 0.2s ease;
    z-index: 1;
    border: none !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.timeline-block:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 2;
}

.timeline-block:active {
    cursor: grabbing;
}

.timeline-block-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    pointer-events: none;
}

/* Block Status Colors */
.timeline-block.status-completed {
    background: var(--color-success);
}

.timeline-block.status-in-progress {
    background: linear-gradient(to right, var(--color-success) 40%, var(--color-info) 40%);
}

.timeline-block.status-pending {
    background: var(--color-info);
}

.timeline-block.status-overdue {
    background: var(--color-error);
}

/* ===================================
   DRAG & DROP STATES
   =================================== */

.timeline-block.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
    z-index: 1000;
}

.timeline-track-container.drag-over {
    background: var(--bg-primary-50);
}

.timeline-track-container.drag-over::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 2px dashed var(--color-primary);
    border-radius: var(--radius-sm);
    z-index: 0;
    pointer-events: none;
}

/* ===================================
   INDICATORS (VIP, Urgent)
   =================================== */

.timeline-block .urgent-indicator {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--color-error);
    color: white;
    border-radius: 50%;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    z-index: 1;
}

.timeline-block .vip-indicator {
    position: absolute;
    top: 2px;
    left: 2px;
    background: var(--warning-500);
    color: white;
    border-radius: 50%;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    z-index: 1;
}

/* Room type indicator (colored left border) */
.timeline-block[data-cleaning-type] {
    border-left: 4px solid var(--color-primary);
}

/* ===================================
   RESPONSIVE ADJUSTMENTS
   =================================== */

@media (max-width: 1200px) {
    :root {
        --timeline-label-width: var(--timeline-label-width-md);
    }
    
    .timeline-staff-label,
    .timeline-ruler-label {
        font-size: var(--text-xs);
        padding: var(--space-xs);
    }
    
    .timeline-time-label {
        font-size: 10px;
    }
}

@media (max-width: 768px) {
    :root {
        --timeline-label-width: var(--timeline-label-width-sm);
        --timeline-ruler-height: 36px;
        --timeline-row-height: 40px;
    }
    
    .timeline-block {
        font-size: 10px;
        padding: 2px 4px;
    }
}

/* ===================================
   SHIFT TIMELINE (Timekeeping Tab)
   =================================== */

/* Shift timeline container */
.timeline-scroll-container {
    position: relative;
    width: 100%;
    padding: var(--space-lg) 0;
    overflow-x: auto;
    overflow-y: hidden;
    /* Scrollbar styling inherited from grid.css */
}

/* Shift timeline track */
.timeline-track {
    position: relative;
    height: 80px;
    min-width: var(--timeline-track-width);
    background: linear-gradient(to right, var(--bg-gray-50) 0%, var(--bg-gray-100) 50%, var(--bg-gray-50) 100%);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
}

.timeline-track::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--border-default);
    transform: translateY(-50%);
}

/* Shift markers */
.shift-marker {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translate(-50%, -50%);
    cursor: pointer;
}

.marker-dot {
    width: 14px;
    height: 14px;
    border-radius: 2px;
    background: var(--bg-white);
    border: 2px solid var(--border-default);
    transition: all 0.2s var(--ease-out);
}

.has-no-shows .marker-dot {
    background: var(--error-500);
    border-color: var(--error-600);
}

.has-late .marker-dot {
    background: var(--warning-500);
    border-color: var(--warning-600);
}

.complete .marker-dot {
    background: var(--success-500);
    border-color: var(--success-600);
}

.in-progress .marker-dot {
    background: var(--primary-500);
    border-color: var(--primary-600);
    animation: pulse 2s ease-in-out infinite;
}

.upcoming .marker-dot {
    background: var(--bg-gray-200);
    border-color: var(--border-default);
}

.shift-marker:hover .marker-dot {
    transform: scale(1.2);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.selected .marker-dot {
    border-color: var(--primary-500);
    border-width: 3px;
}

.shift-marker .marker-info {
    position: absolute;
    top: -45px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    white-space: nowrap;
    pointer-events: none;
}

.shift-marker .marker-time {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
}

.shift-marker .marker-count {
    font-size: var(--text-xs);
    color: var(--text-muted);
    background: var(--bg-white);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

.shift-marker.selected .marker-count {
    background: var(--primary-50);
    border-color: var(--primary-300);
    color: var(--primary-700);
    font-weight: 600;
}

.timeline-labels {
    position: relative;
    min-width: var(--timeline-track-width);
    height: 20px;
    margin-top: var(--space-sm);
}

.time-label {
    position: absolute;
    font-size: var(--text-xs);
    color: var(--text-muted);
    transform: translateX(-50%);
}

/* ===================================
   ACCESSIBILITY
   =================================== */

@media (prefers-reduced-motion: reduce) {
    .timeline-block,
    .timeline-track-container,
    .timeline-team-header,
    .timeline-expand-arrow,
    .shift-marker {
        transition: none;
    }
    
    .in-progress .marker-dot {
        animation: none;
    }
}

.timeline-block:focus-visible,
.timeline-team-header:focus-visible,
.shift-marker:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}
