/* ============================================
   CropSaga - Calendar Module Styles
   ============================================ */

.calendar-filters {
    display: flex;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    flex-wrap: wrap;
    align-items: center;
}

.calendar-filters .form-select {
    flex: 1;
    min-width: 180px;
}

/* Timeline View (Gantt) */
.timeline-container {
    background: var(--color-bg-table);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden; /* horizontal scroll handled by inner synced panes */
}

.timeline-header {
    display: flex;
    position: sticky;
    top: 0;
    background: var(--color-bg-primary);
    border-bottom: 2px solid var(--color-border);
    z-index: 10;
}

/* Horizontal scroll panes (header/body) kept in sync via JS */
.timeline-scroll-x {
    position: relative;
    overflow-x: auto;
    overflow-y: hidden;
}

/* Hide scrollbar for header pane but allow programmatic scrolling */
.no-scrollbar {
    -ms-overflow-style: none; /* IE/Edge */
    scrollbar-width: none;    /* Firefox */
}
.no-scrollbar::-webkit-scrollbar { display: none; }

.timeline-row-header {
    width: 250px;
    padding: var(--spacing-md);
    font-weight: 600;
    color: var(--color-accent-green);
    border-right: 1px solid var(--color-border);
    flex-shrink: 0;
    position: sticky;
    left: 0;
    z-index: 12;
    background: var(--color-bg-primary);
}

.timeline-months {
    display: flex;
    flex: 1;
}

/* Week header composed of title + day strip */
.timeline-week {
    flex: 0 0 auto;
    border-right: 1px solid var(--color-border);
}

.week-title {
    padding: 6px 8px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.week-days {
    display: grid;
    grid-template-columns: repeat(7, minmax(22px, 1fr));
    gap: 0;
    border-top: 1px solid var(--color-border);
}

.week-day {
    padding: 4px 0;
    text-align: center;
    font-size: 10px;
    color: var(--color-text-secondary);
    line-height: 1.1;
    font-variant-numeric: tabular-nums; /* keep numbers aligned and not squished */
}

.week-day .wdn { font-weight: 600; font-size: 11px; }
.week-day .wd { opacity: 0.7; font-size: 10px; }

/* Keep weeks flexible so header width == body width (prevents misalignment) */
.timeline-week { min-width: 0; }

.timeline-month {
    flex: 0 0 auto; /* width set inline to match real days proportion */
    padding: var(--spacing-md);
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    border-right: 1px solid var(--color-border);
    min-width: 0; /* allow shrinking for weeks/days to keep header width == body width */
}

.timeline-month:last-child {
    border-right: none;
}

/* Timeline Body */
.timeline-body {
    min-height: 400px;
}

/* Split columns: fixed labels + scrollable bars */
.timeline-rows-grid {
    display: grid;
    grid-template-columns: 250px 1fr;
}
.timeline-labels {
    background: var(--color-bg-table);
    display: grid;
    grid-auto-rows: 60px; /* enforce same row heights */
}
.timeline-label-row {
    border-bottom: 1px solid var(--color-border);
    min-height: 0;
    display: flex;
}
.timeline-bars-row {
    border-bottom: 1px solid var(--color-border);
    min-height: 0;
    display: flex;
}
/* right column: grid with fixed row height to mirror labels */
#tlScrollBody {
    display: grid;
    grid-auto-rows: 60px;
}

/* Full calendar view: denser rows to vedea cât mai mult */
body.full-calendar .timeline-labels { grid-auto-rows: 40px; }
body.full-calendar #tlScrollBody { grid-auto-rows: 40px; }

/* Excel-like header (months with four week columns) */
.excel-month {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--color-border);
}
.excel-month-title {
    padding: 8px 10px;
    font-weight: 700;
    font-size: 13px;
    text-align: center;
    color: var(--color-text-primary);
    background: var(--color-bg-table);
    border-bottom: 1px solid var(--color-border);
}
.excel-weeks {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
}
.excel-week {
    padding: 6px 8px;
    text-align: center;
    font-size: 11px;
    color: var(--color-text-secondary);
}

.timeline-row {
    display: flex;
    border-bottom: 1px solid var(--color-border);
    min-height: 60px;
    transition: background 0.3s;
}

.timeline-row:hover {
    background: var(--color-hover-bg);
}

.timeline-row-label {
    width: 250px;
    padding: var(--spacing-md);
    border-right: 1px solid var(--color-border);
    flex-shrink: 0;
    position: sticky;
    left: 0;
    z-index: 11;
    background: var(--color-bg-table);
}

.row-title {
    font-weight: 600;
    color: var(--color-text-primary);
    font-size: 14px;
    margin-bottom: 4px;
}

.row-subtitle {
    font-size: 12px;
    color: var(--color-text-secondary);
}

.timeline-bars {
    flex: 1;
    position: relative;
    padding: var(--spacing-sm) 0;
}

/* prevent flex shrinking of the long track so horizontal overflow is created */
.timeline-bars-row .timeline-track { flex: 0 0 auto; }
.timeline-months .timeline-track { flex: 0 0 auto; }
.timeline-scroll-x { width: 100%; }

/* Vertical grid lines */
.timeline-grid,
.timeline-grid-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.timeline-grid-header { height: 100%; }

.timeline-grid .grid-line,
.timeline-grid-header .grid-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--color-border);
    opacity: 0.25;
}

.today-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--color-accent-green);
    opacity: 0.8;
    z-index: 2;
    box-shadow: 0 0 6px rgba(148, 201, 115, 0.6);
}

/* Task Bars */
.task-bar {
    position: absolute;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    padding: 0 8px;
    top: 50%;
    transform: translateY(-50%);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    min-width: 14px; /* ensure visibility in weekly view */
}

.task-bar:hover {
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    z-index: 5;
}

.task-bar-label {
    font-size: 11px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.no-tasks-message {
    padding: var(--spacing-md);
    text-align: center;
    color: var(--color-text-secondary);
    font-size: 12px;
    font-style: italic;
}

.no-data-timeline {
    padding: 60px 20px;
    text-align: center;
    color: var(--color-text-secondary);
}

.no-data-timeline i {
    font-size: 64px;
    opacity: 0.3;
    margin-bottom: 16px;
    display: block;
}

/* List View */
.list-container {
    background: var(--color-bg-table);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
}

.task-row {
    transition: background 0.3s;
}

.task-row:hover {
    background: var(--color-hover-bg);
}

.task-row.completed {
    opacity: 0.7;
}

.task-row.overdue {
    border-left: 3px solid var(--color-error-red);
}

/* Tech Sheets Modal */
.tech-sheets-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.tech-sheet-item {
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: var(--spacing-md);
}

.sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.sheet-header h3 {
    margin: 0;
    color: var(--color-accent-green);
    font-size: 16px;
}

.sheet-summary {
    font-size: 13px;
    color: var(--color-text-secondary);
}

/* Responsive Timeline */
@media (max-width: 1200px) {
    .timeline-row-header,
    .timeline-row-label {
        width: 200px;
    }

    .timeline-month {
        min-width: 60px;
        font-size: 11px;
    }
}

@media (max-width: 992px) {
    .calendar-filters {
        flex-direction: column;
    }

    .calendar-filters .form-select {
        width: 100%;
    }

    .timeline-container {
        overflow: hidden; /* keep scroll only on inner synced panes */
    }
}

/* Task Type Colors */
.task-type-mechanical { background: #94C973; }
.task-type-irrigation { background: #4A90E2; }
.task-type-fertilization { background: #F39C12; }
.task-type-chemical { background: #E67E22; }
.task-type-harvest { background: #8B4513; }
.task-type-cover { background: #A6AE9E; }

/* Legend */
.calendar-legend {
    display: flex;
    gap: var(--spacing-lg);
    padding: var(--spacing-md);
    background: var(--color-bg-table);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    margin-top: var(--spacing-md);
    flex-wrap: wrap;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

