/* =============================================================
   Dienstplan V3 — Stylesheet
   ============================================================= */

:root {
    --color-F:    #FFD700;
    --color-S:    #FF8C00;
    --color-N:    #4B0082;
    --color-DF:   #90EE90;
    --color-U:    #87CEEB;
    --color-FN:   #DAA520;

    --bg:         #f5f5f5;
    --card-bg:    #ffffff;
    --text:       #333;
    --text-muted: #888;
    --border:     #ddd;
    --danger:     #d32f2f;
    --success:    #388e3c;
    --warning:    #f57c00;

    --dgl-color:  #1565c0;
    --dglin-color:#6a1b9a;
    --dglv-color: #00838f;
    --sb-color:   #555;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* ---- Layout ---- */
.app-container {
    max-width: 100%;
    padding: 0.5rem;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background: var(--card-bg);
    border-bottom: 2px solid var(--border);
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.app-header h1 { font-size: 1.25rem; }

/* ---- Buttons ---- */
.btn {
    display: inline-block;
    padding: 0.45rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    background: var(--card-bg);
    color: var(--text);
    transition: all 0.15s;
    white-space: nowrap;
}
.btn:hover { filter: brightness(0.95); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #1976d2; color: #fff; border-color: #1976d2; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-outline { background: transparent; }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.75rem; }
.btn-lg { padding: 0.6rem 1.5rem; font-size: 1rem; font-weight: 600; }

/* ---- Monats-Nav ---- */
.month-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
}
.month-nav button {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.8rem;
    cursor: pointer;
    font-size: 1rem;
}
.month-nav button:hover { background: #e3f2fd; }
.month-label { font-size: 1.2rem; font-weight: 700; min-width: 14rem; text-align: center; }

/* ---- Legende ---- */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.5rem 1rem;
    background: var(--card-bg);
    border-radius: 8px;
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.legend-color {
    width: 18px; height: 18px;
    border-radius: 4px;
    display: inline-block;
    border: 1px solid rgba(0,0,0,0.15);
}

/* ---- Einstellungen ---- */
.settings-panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
}
.settings-panel h3 { margin-bottom: 0.5rem; }
.settings-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 0.75rem;
}
.settings-grid label { font-size: 0.85rem; }
.settings-grid input {
    width: 60px; padding: 0.25rem; border: 1px solid var(--border); border-radius: 4px;
}

/* ---- Matrix-Tabelle ---- */
.matrix-container {
    overflow-x: auto;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    position: relative;
    max-height: 75vh;
    overflow-y: auto;
}

.matrix-table {
    border-collapse: collapse;
    font-size: 0.75rem;
    width: max-content;
}

.matrix-table th,
.matrix-table td {
    border: 1px solid var(--border);
    padding: 2px 1px;
    text-align: center;
    min-width: 36px;
    height: 32px;
    vertical-align: middle;
}

/* Fixe linke Spalte (Beamten-Namen) */
.matrix-table th.officer-col,
.matrix-table td.officer-col {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--card-bg);
    min-width: 160px;
    max-width: 180px;
    text-align: left;
    padding: 2px 6px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.matrix-table thead th {
    background: #e8eaf0;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 3;
}

.matrix-table thead th.officer-col {
    z-index: 4;
    background: #d0d4dc;
}

/* Tages-Header */
.matrix-table .day-header {
    padding: 2px 3px;
    font-size: 0.7rem;
}
.matrix-table .day-header .dow { font-size: 0.65rem; color: var(--text-muted); }
.matrix-table .day-header.weekend { background: #ffecb3; }
.matrix-table .day-header.today { background: #bbdefb; font-weight: 700; }

/* Zellen */
.matrix-table .shift-cell {
    cursor: pointer;
    transition: background 0.1s;
    font-size: 0.7rem;
    font-weight: 600;
    user-select: none;
}
.matrix-table .shift-cell:hover {
    outline: 2px solid #1976d2;
    outline-offset: -2px;
    z-index: 1;
    position: relative;
}

/* Schicht-Farben */
.shift-F  { background: var(--color-F); color: #333; }
.shift-S  { background: var(--color-S); color: #fff; }
.shift-N  { background: var(--color-N); color: #fff; }
.shift-FN { background: linear-gradient(135deg, var(--color-F) 45%, var(--color-N) 55%); color: #fff; }
.shift-DF { background: var(--color-DF); color: #333; }
.shift-U  { background: var(--color-U); color: #333; }
.shift-BT { background: #c8e6c9; color: #1b5e20; border: 2px dashed #388e3c; font-style: italic; }

/* Position-Badges in der Namensspalte */
.pos-badge {
    display: inline-block;
    font-size: 0.6rem;
    padding: 0px 4px;
    border-radius: 3px;
    margin-right: 4px;
    color: #fff;
    font-weight: 600;
}
.pos-DGL   { background: var(--dgl-color); }
.pos-DGLin { background: var(--dglin-color); }
.pos-DGLV  { background: var(--dglv-color); }
.pos-SB    { background: var(--sb-color); }

/* Unbeliebter-Dienst-Markierung */
.unpopular-indicator {
    position: absolute;
    top: 1px;
    right: 2px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--danger);
}

/* ---- Aktionen ---- */
.actions-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

/* ---- Statistik ---- */
.stats-container,
.violations-container {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 0.75rem;
    overflow-x: auto;
}

.stats-container h2,
.violations-container h2 {
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

.stats-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.8rem;
}
.stats-table th,
.stats-table td {
    border: 1px solid var(--border);
    padding: 4px 8px;
    text-align: center;
}
.stats-table th { background: #e8eaf0; font-weight: 600; }
.stats-table td.name-col { text-align: left; font-weight: 500; }

/* Ampel */
.traffic-light {
    display: inline-block;
    width: 14px; height: 14px;
    border-radius: 50%;
}
.tl-green  { background: #4caf50; }
.tl-yellow { background: #ffeb3b; border: 1px solid #f9a825; }
.tl-red    { background: #f44336; }

/* Violations */
.violation-item {
    padding: 0.4rem 0.75rem;
    margin: 0.25rem 0;
    border-radius: 4px;
    font-size: 0.85rem;
}
.violation-error   { background: #ffebee; border-left: 4px solid var(--danger); color: #b71c1c; }
.violation-warning { background: #fff3e0; border-left: 4px solid var(--warning); color: #e65100; }

/* Loading */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

/* Status messages */
.status-msg { font-size: 0.85rem; }
.status-ok  { color: var(--success); }
.status-err { color: var(--danger); }

/* Delete-Button (deprecated, kept for compatibility) */
.btn-delete-officer { display: none; }

/* ---- Officer Management in Settings ---- */
.officer-mgmt {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}
.officer-mgmt-section {
    flex: 1;
    min-width: 280px;
}
.officer-mgmt-section h5 {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: #555;
}
.officer-add-form,
.officer-delete-form {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    flex-wrap: wrap;
}
.officer-add-form input,
.officer-delete-form input {
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.85rem;
    min-width: 140px;
}
.officer-add-form select,
.officer-delete-form select {
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.85rem;
}
.hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}
.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.btn-danger:disabled {
    background: #e0e0e0;
    color: #999;
    border-color: #ccc;
    cursor: not-allowed;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .app-header h1 { font-size: 1rem; }
    .month-label { font-size: 1rem; min-width: auto; }
    .matrix-table { font-size: 0.65rem; }
    .matrix-table th, .matrix-table td { min-width: 28px; height: 28px; }
    .matrix-table th.officer-col, .matrix-table td.officer-col { min-width: 120px; }
}

/* ---- Context-Menu (für Schnellauswahl) ---- */
.shift-context-menu {
    display: none;
    position: fixed;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    z-index: 1000;
    padding: 0.25rem;
    min-width: 120px;
}
.shift-context-menu.active { display: block; }
.shift-context-menu .menu-item {
    display: block;
    width: 100%;
    padding: 0.45rem 0.85rem;
    border: none;
    cursor: pointer;
    text-align: left;
    font-size: 0.85rem;
    border-radius: 4px;
    font-weight: 600;
    margin: 1px 0;
}
.shift-context-menu .menu-item:hover { filter: brightness(0.85); outline: 2px solid #1976d2; outline-offset: -2px; }
.shift-context-menu .menu-F  { background: var(--color-F); color: #222; }
.shift-context-menu .menu-S  { background: var(--color-S); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.5); }
.shift-context-menu .menu-N  { background: var(--color-N); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.5); }
.shift-context-menu .menu-FN { background: linear-gradient(135deg, var(--color-F) 40%, var(--color-N) 60%); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.6); }
.shift-context-menu .menu-DF { background: var(--color-DF); color: #222; }
.shift-context-menu .menu-U  { background: var(--color-U); color: #222; }
.shift-context-menu .menu-BT { background: #c8e6c9; color: #1b5e20; border: 2px dashed #388e3c; }
.shift-context-menu .menu--  { background: #f5f5f5; color: var(--text-muted); }
