/* === Stunden-Übersicht Sidebar === */

/*
 * Layout-Konzept:
 * - Sidebar ist fixed rechts, komplett außerhalb wenn collapsed
 * - Nur kleiner Toggle-Tab sichtbar wenn collapsed
 * - Body/Container wird gestaucht wenn open
 */

.hours-sidebar {
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    width: 320px;
    background: var(--bg-color);
    border-left: 2px solid var(--border-color);
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.08);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Collapsed: Sidebar komplett raus, nur Toggle sichtbar */
.hours-sidebar.collapsed {
    transform: translateX(100%);
}

/* Open: Sidebar sichtbar */
.hours-sidebar.open {
    transform: translateX(0);
}

/* Content-Bereich staucht sich für die Sidebar */
body .container {
    transition: max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    overflow-x: hidden;
}

body.sidebar-open .container {
    max-width: calc(95% - 320px);
    margin-left: 12px;
    margin-right: auto;
}

/* Alle Inhalte innerhalb des Containers müssen sich anpassen */
body.sidebar-open .container > *,
body.sidebar-open .container header,
body.sidebar-open .container main,
body.sidebar-open .container footer,
body.sidebar-open #tab-smartshifts {
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* SmartShifts spezifisch */
body.sidebar-open .smartshifts-container {
    max-width: 100%;
    overflow-x: auto;
}

body.sidebar-open .smartshifts-kw-navigation,
body.sidebar-open .smartshifts-actions {
    max-width: 100%;
    overflow-x: auto;
}

body.sidebar-open .smartshifts-day-navigation {
    max-width: 100%;
    overflow: visible; /* Feiertags-Badges nicht abschneiden */
}

/* Toggle Button - kleiner Tab am Rand */
.hours-sidebar-toggle {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 60px;
    background: var(--primary-color);
    color: white;
    border-radius: 6px 0 0 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: -2px 0 6px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    user-select: none;
    z-index: 1001;
}

/* Toggle versteckt sich wenn Sidebar offen */
.hours-sidebar.open .hours-sidebar-toggle {
    opacity: 0;
    pointer-events: none;
}

.hours-sidebar-toggle:hover {
    background: var(--primary-hover);
    width: 28px;
}

.hours-sidebar.collapsed .hours-sidebar-toggle #sidebar-toggle-icon::before {
    content: '◀';
    font-size: 12px;
    font-weight: 600;
}

.hours-sidebar.open .hours-sidebar-toggle #sidebar-toggle-icon::before {
    content: '▶';
    font-size: 12px;
    font-weight: 600;
}

/* Schließen-Button in der Sidebar selbst */
.hours-sidebar .sidebar-close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    color: #64748b;
    z-index: 10;
}

.hours-sidebar .sidebar-close-btn:hover {
    background: #e2e8f0;
    color: #334155;
}

/* Sidebar Content */
.hours-sidebar-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 16px 20px;
    overflow: hidden;
}

/* Sidebar Header (general) */
.hours-sidebar .sidebar-header {
    padding: 16px 20px 12px 20px;
    padding-right: 40px; /* Platz für X-Button */
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 0;
}

.hours-sidebar .sidebar-header h3 {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
}

.hours-sidebar .sidebar-header .kw-info {
    font-size: 12px;
    color: var(--text-muted);
}

.hours-sidebar-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
}

.hours-sidebar-header h3 {
    margin: 0 0 4px 0;
    font-size: 16px;
    color: var(--text-color);
}

/* Employee List */
.hours-sidebar-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 4px;
}

/* Scrollbar Styling */
.hours-sidebar-list::-webkit-scrollbar {
    width: 6px;
}

.hours-sidebar-list::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 3px;
}

.hours-sidebar-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.hours-sidebar-list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Employee Item */
.hours-sidebar-item {
    padding: 6px 8px;
    background: white;
    border-radius: 4px;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
}

.hours-sidebar-item:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    transform: translateX(-2px);
}

/* Color Coding - Traffic Light System */
.hours-sidebar-item.utilization-low {
    border-left-color: #22c55e; /* Green <90% */
    background: #f0fdf4;
}

.hours-sidebar-item.utilization-normal {
    border-left-color: #eab308; /* Yellow 90-100% */
    background: #fefce8;
}

.hours-sidebar-item.utilization-over {
    border-left-color: #f97316; /* Orange 100-110% */
    background: #fff7ed;
}

.hours-sidebar-item.utilization-critical {
    border-left-color: #ef4444; /* Red >110% */
    background: #fef2f2;
}

/* Header row: Name - Schichten - Konflikte */
.hours-sidebar-item-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
    flex-wrap: wrap;
}

.hours-sidebar-item-name {
    font-weight: 600;
    font-size: 11px;
    color: var(--text-color);
    flex-shrink: 0;
}

.hours-sidebar-item-shifts {
    font-size: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.hours-sidebar-item-conflicts {
    font-size: 12px;
    display: flex;
    gap: 2px;
}

/* Footer row: Stunden - Auslastung */
.hours-sidebar-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
}

.hours-sidebar-item-hours {
    font-weight: 600;
    font-size: 11px;
}

.hours-sidebar-item-utilization {
    font-weight: 600;
    font-size: 10px;
}

/* Color coding for hours */
.hours-sidebar-item.utilization-low .hours-sidebar-item-hours,
.hours-sidebar-item.utilization-low .hours-sidebar-item-utilization {
    color: #16a34a;
}

.hours-sidebar-item.utilization-normal .hours-sidebar-item-hours,
.hours-sidebar-item.utilization-normal .hours-sidebar-item-utilization {
    color: #ca8a04;
}

.hours-sidebar-item.utilization-over .hours-sidebar-item-hours,
.hours-sidebar-item.utilization-over .hours-sidebar-item-utilization {
    color: #ea580c;
}

.hours-sidebar-item.utilization-critical .hours-sidebar-item-hours,
.hours-sidebar-item.utilization-critical .hours-sidebar-item-utilization {
    color: #dc2626;
}

/* Empty State */
.hours-sidebar-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* Responsive */
@media (max-width: 1400px) {
    .hours-sidebar {
        width: 280px;
    }

    body.sidebar-open .container {
        max-width: calc(95% - 280px);
    }
}

@media (max-width: 768px) {
    /* Auf Mobile: Overlay statt Push (wegen Platz) */
    body.sidebar-open .container {
        max-width: 100% !important;
        margin: 0 auto !important;
    }

    .hours-sidebar {
        width: 100%;
        height: 40vh;
        top: auto;
        bottom: 0;
        transform: translateY(100%);
        border-left: none;
        border-top: 2px solid var(--border-color);
        z-index: 1500;
    }

    .hours-sidebar.open {
        transform: translateY(0);
    }

    .hours-sidebar.collapsed {
        transform: translateY(100%);
    }

    /* Toggle-Button auf Mobile: unten mittig */
    .hours-sidebar-toggle {
        position: fixed;
        left: 50%;
        right: auto;
        top: auto;
        bottom: 0;
        transform: translateX(-50%);
        width: 80px;
        height: 32px;
        border-radius: 8px 8px 0 0;
    }

    .hours-sidebar-toggle #sidebar-toggle-icon::before {
        content: '▲' !important;
    }
}

/* Employee Details List */
.employee-details-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.employee-details-item {
    padding: 10px 12px;
    background: white;
    border-left: 3px solid var(--border-color);
    border-radius: 4px;
    font-size: 12px;
}

.employee-details-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.employee-details-item-day {
    font-weight: 600;
    color: var(--text-color);
}

.employee-details-item-time {
    font-size: 11px;
    color: var(--text-muted);
}

.employee-details-item-shift {
    font-size: 11px;
    color: var(--text-muted);
}

.employee-details-item.is-lead {
    border-left-color: #3b82f6;
    background: #eff6ff;
}

.employee-details-item.has-conflict {
    border-left-color: #ef4444;
    background: #fef2f2;
}

.employee-details-item.has-warning {
    border-left-color: #f59e0b;
    background: #fffbeb;
}

/* === Monatsstunden-Anzeige in Sidebar === */

/* Monats-Zeile in Card */
.hours-sidebar-item-monthly {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px dashed var(--border-color);
}

.hours-sidebar-item-monthly.loading {
    color: var(--text-muted);
    font-style: italic;
}

/* Monats-Auslastungs-Klassen */
.hours-sidebar-item-monthly.monthly-ok .hours-sidebar-item-hours,
.hours-sidebar-item-monthly.monthly-ok .hours-sidebar-item-utilization {
    color: #16a34a; /* Grün - 95-105% */
}

.hours-sidebar-item-monthly.monthly-low .hours-sidebar-item-hours,
.hours-sidebar-item-monthly.monthly-low .hours-sidebar-item-utilization {
    color: #f59e0b; /* Gelb/Orange - 85-95% */
}

.hours-sidebar-item-monthly.monthly-high .hours-sidebar-item-hours,
.hours-sidebar-item-monthly.monthly-high .hours-sidebar-item-utilization {
    color: #f59e0b; /* Gelb/Orange - 105-115% */
}

.hours-sidebar-item-monthly.monthly-critical-low .hours-sidebar-item-hours,
.hours-sidebar-item-monthly.monthly-critical-low .hours-sidebar-item-utilization {
    color: #dc2626; /* Rot - <85% */
    font-weight: 700;
}

.hours-sidebar-item-monthly.monthly-critical-high .hours-sidebar-item-hours,
.hours-sidebar-item-monthly.monthly-critical-high .hours-sidebar-item-utilization {
    color: #dc2626; /* Rot - >115% */
    font-weight: 700;
}

/* Gefilterte Monats-Zeile */
.hours-sidebar-item-monthly.filtered {
    border-top-style: dotted;
}

/* Filter-Hinweis im Sidebar-Header */
.sidebar-filter-hint {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #f59e0b;
    border-radius: 6px;
    padding: 6px 10px;
    margin: 0 16px 12px 16px;
    font-size: 11px;
    color: #92400e;
    cursor: help;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Inaktiver Filter-Hinweis (Tipp) */
.sidebar-filter-hint.sidebar-filter-hint-inactive {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    border: 1px solid #cbd5e1;
    color: #64748b;
    white-space: normal;
    overflow: visible;
}
