/* Timeline / Gantt View Styles */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: radial-gradient(1200px 600px at 50% -10%, #f8fafc 10%, #eef2f7 55%, #e9eef5 100%);
    min-height: 100vh;
}

.timeline-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Header */
.timeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 12px;
}

.header-left {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.header-left h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: #212529;
}

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

.header-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.date-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.date-controls label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    color: #495057;
}

.date-controls input[type="date"] {
    padding: 6px 10px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 0.85rem;
    background: #fff;
}

.btn-apply {
    padding: 6px 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s;
}

.btn-apply:hover {
    opacity: 0.9;
}

.btn-quick {
    padding: 6px 10px;
    background: #f8f9fa;
    color: #495057;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 0.8rem;
    text-decoration: none;
    transition: all 0.15s;
}

.btn-quick:hover {
    background: #e9ecef;
    color: #212529;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.btn-snapshot {
    padding: 6px 14px;
    background: #fff;
    color: #198754;
    border: 1px solid #198754;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-snapshot:hover {
    background: #198754;
    color: #fff;
}

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

.btn-back {
    padding: 6px 14px;
    background: #fff;
    color: #495057;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s;
}

.btn-back:hover {
    background: #f8f9fa;
    color: #212529;
}

.btn-weekly {
    padding: 6px 14px;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: opacity 0.15s;
}

.btn-weekly:hover {
    opacity: 0.9;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 40px;
    text-align: center;
    color: #6c757d;
}

.empty-state h2 {
    margin: 16px 0 8px;
    color: #495057;
}

.empty-state p {
    margin: 0;
    line-height: 1.6;
}

/* Main Grid */
.timeline-grid {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Users Column (fixed) */
.users-column {
    width: 140px;
    min-width: 140px;
    background: #fff;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 10;
}

.users-header {
    height: 54px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: 0.85rem;
    color: #495057;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.user-cell {
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-bottom: 2px solid #dee2e6;
    background: #fff;
    min-height: 36px;
}

/* User cell colors matching row colors */
.user-cell.user-color-0 { background: rgba(102, 126, 234, 0.12); }
.user-cell.user-color-1 { background: rgba(67, 233, 123, 0.12); }
.user-cell.user-color-2 { background: rgba(79, 172, 254, 0.12); }
.user-cell.user-color-3 { background: rgba(250, 112, 154, 0.12); }
.user-cell.user-color-4 { background: rgba(168, 237, 234, 0.15); }
.user-cell.user-color-5 { background: rgba(255, 236, 210, 0.18); }
.user-cell.user-color-6 { background: rgba(240, 147, 251, 0.12); }
.user-cell.user-color-7 { background: rgba(254, 214, 227, 0.15); }

.user-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: #212529;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Calendar Area (scrollable) */
.calendar-area {
    flex: 1;
    overflow-x: auto;
    overflow-y: auto;
    position: relative;
}

/* Date Headers */
.date-headers {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 5;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    height: 54px;
    min-width: max-content;
}

.date-cell {
    width: 40px;
    min-width: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4px 0;
    border-right: 1px solid #f1f3f5;
    position: relative;
}

.date-cell.weekend {
    background: #fff5f5;
}

.date-cell.weekend .day-num {
    color: #e03131;
}

.date-cell.weekend .day-name {
    color: #fa5252;
}

.date-cell.today {
    background: #e7f5ff;
}

.month-label {
    position: absolute;
    top: 2px;
    left: 2px;
    font-size: 0.65rem;
    font-weight: 600;
    color: #868e96;
    text-transform: uppercase;
}

.day-num {
    font-size: 0.85rem;
    font-weight: 600;
    color: #212529;
}

.day-name {
    font-size: 0.65rem;
    color: #868e96;
    text-transform: uppercase;
}

/* Rows Container */
.rows-container {
    position: relative;
    min-width: max-content;
}

.user-row {
    position: relative;
    border-bottom: 2px solid #dee2e6;
    min-height: 36px;
}

/* Alternating user row backgrounds */
.user-row.user-color-0 { background: rgba(102, 126, 234, 0.06); }
.user-row.user-color-1 { background: rgba(67, 233, 123, 0.06); }
.user-row.user-color-2 { background: rgba(79, 172, 254, 0.06); }
.user-row.user-color-3 { background: rgba(250, 112, 154, 0.06); }
.user-row.user-color-4 { background: rgba(168, 237, 234, 0.06); }
.user-row.user-color-5 { background: rgba(255, 236, 210, 0.08); }
.user-row.user-color-6 { background: rgba(240, 147, 251, 0.06); }
.user-row.user-color-7 { background: rgba(254, 214, 227, 0.08); }

/* Day Column Backgrounds */
.day-column {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 40px;
    border-right: 1px solid #f1f3f5;
}

.day-column.weekend {
    background: rgba(224, 49, 49, 0.08);
}

.day-column.today {
    background: #e7f5ff;
}

/* Task Bars */
.task-bar {
    position: absolute;
    height: 28px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    text-decoration: none;
    font-size: 0.75rem;
    white-space: nowrap;
    transition: transform 0.1s, box-shadow 0.1s;
    z-index: 2;
}

.task-bar:hover {
    transform: translateY(-1px);
    z-index: 3;
}

.task-bar:hover .bar-duration {
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.task-bar:hover .bar-label {
    background: rgba(255,255,255,0.98);
}

/* Duration bar - the colored portion */
.bar-duration {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: var(--bar-width);
    min-width: var(--bar-width);
    background: linear-gradient(135deg, var(--bar-color-1), var(--bar-color-2));
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.task-bar.ongoing .bar-duration {
    border-right: 3px solid rgba(255,255,255,0.6);
    animation: pulse-ongoing 2s ease-in-out infinite;
}

@keyframes pulse-ongoing {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

/* Label - on top of bar, faded bg only beyond bar */
.bar-label {
    position: relative;
    z-index: 1;
    padding: 4px 10px 4px 8px;
    color: #222;
    font-weight: 600;
    text-shadow:
        -1px -1px 0 rgba(255,255,255,0.8),
        1px -1px 0 rgba(255,255,255,0.8),
        -1px 1px 0 rgba(255,255,255,0.8),
        1px 1px 0 rgba(255,255,255,0.8),
        0 0 4px rgba(255,255,255,0.9);
    background: linear-gradient(to right,
        transparent 0,
        transparent var(--bar-width),
        rgba(255,255,255,0.88) var(--bar-width),
        rgba(255,255,255,0.85) 100%
    );
    border-radius: 0 4px 4px 0;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Today Indicator Line */
.today-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #fa5252;
    z-index: 4;
    pointer-events: none;
}

.today-line::before {
    content: '';
    position: absolute;
    top: -6px;
    left: -4px;
    width: 10px;
    height: 10px;
    background: #fa5252;
    border-radius: 50%;
}

/* Scrollbar Styling */
.calendar-area::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.calendar-area::-webkit-scrollbar-track {
    background: #f1f3f5;
}

.calendar-area::-webkit-scrollbar-thumb {
    background: #ced4da;
    border-radius: 4px;
}

.calendar-area::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

/* Responsive */
@media (max-width: 768px) {
    .timeline-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-controls {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
    }

    .date-controls {
        width: 100%;
    }

    .users-column {
        width: 100px;
        min-width: 100px;
    }

    .user-name {
        font-size: 0.75rem;
    }

    .task-bar {
        font-size: 0.7rem;
        padding: 0 4px;
    }
}
