/* TP Personalplaner — CI-Theme
   Farben: #E2001A (Rot), #FFFFFF (Weiß), #F2F2F2 (Grau)
*/
:root {
  --tp-red: #E2001A;
  --tp-red-dark: #B80015;
  --tp-red-soft: #FCE5E7;
  --tp-grey: #F2F2F2;
  --tp-grey-2: #E5E5E5;
  --tp-grey-3: #9A9A9A;
  --tp-text: #1A1A1A;
  --tp-text-soft: #666;
  --tp-white: #FFFFFF;
  --tp-shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04);
  --tp-radius: 6px;
  --tp-sidebar-w: 220px;
  --tp-topbar-h: 56px;
  --tp-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: var(--tp-font); color: var(--tp-text); background: var(--tp-grey); font-size: 14px; }
a { color: var(--tp-red); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--tp-sidebar-w) 1fr; grid-template-rows: var(--tp-topbar-h) 1fr; min-height: 100vh; }
.topbar { grid-column: 1 / 3; background: var(--tp-red); color: white; display: flex; align-items: center; padding: 0 16px; gap: 16px; box-shadow: var(--tp-shadow); }
.topbar .brand { display:flex; align-items:center; gap:12px; min-width: var(--tp-sidebar-w); }
.topbar .brand img { height: 32px; display:block; }
.topbar .title { font-weight: 600; font-size: 15px; letter-spacing: .3px; }
.topbar .spacer { flex: 1; }
.topbar .topbar-right { display:flex; align-items:center; gap:14px; }
.topbar a, .topbar button { color: white; }

.sidebar { background: white; border-right: 1px solid var(--tp-grey-2); padding: 16px 8px; overflow-y: auto; }
.sidebar .nav-section { margin-bottom: 18px; }
.sidebar .nav-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--tp-text-soft); padding: 4px 12px; margin-bottom: 4px; }
.sidebar a.nav { display: block; padding: 8px 12px; border-radius: var(--tp-radius); color: var(--tp-text); }
.sidebar a.nav:hover { background: var(--tp-grey); text-decoration: none; }
.sidebar a.nav.active { background: var(--tp-red-soft); color: var(--tp-red); font-weight: 600; }

.main { padding: 20px 24px; overflow: auto; }

/* ---------- Components ---------- */
.card { background: white; border-radius: var(--tp-radius); box-shadow: var(--tp-shadow); padding: 18px 20px; margin-bottom: 16px; }
.card h2 { margin: 0 0 12px 0; font-size: 16px; }

.page-header { display:flex; align-items:center; gap: 14px; margin-bottom: 18px; }
.page-header h1 { margin: 0; font-size: 22px; font-weight: 600; }
.page-header .market-pill { background: var(--tp-red); color: white; padding: 4px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.page-header .spacer { flex: 1; }

.btn { display:inline-flex; align-items:center; gap:6px; padding: 7px 14px; border-radius: var(--tp-radius); border: 1px solid var(--tp-grey-2); background: white; color: var(--tp-text); cursor: pointer; }
.btn:hover { background: var(--tp-grey); }
.btn-primary { background: var(--tp-red); color: white; border-color: var(--tp-red); }
.btn-primary:hover { background: var(--tp-red-dark); }
.btn-ghost { border-color: transparent; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { background: white; color: var(--tp-red); border-color: var(--tp-red); }
.btn-danger:hover { background: var(--tp-red); color: white; }

.form-row { display: grid; grid-template-columns: 220px 1fr; gap: 12px; align-items: center; margin-bottom: 10px; }
.form-row label { color: var(--tp-text-soft); font-size: 13px; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--tp-grey-2); border-radius: var(--tp-radius); background: white;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { outline: 2px solid var(--tp-red-soft); border-color: var(--tp-red); }
.form-row .hint { color: var(--tp-text-soft); font-size: 12px; margin-top: 4px; }
.form-actions { display:flex; gap:8px; padding-top: 8px; border-top: 1px solid var(--tp-grey-2); margin-top: 14px; }

table.tp { width: 100%; border-collapse: collapse; background: white; border-radius: var(--tp-radius); overflow: hidden; box-shadow: var(--tp-shadow); }
table.tp th { background: var(--tp-grey); text-align: left; padding: 10px 12px; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--tp-text-soft); }
table.tp td { padding: 10px 12px; border-top: 1px solid var(--tp-grey-2); }
table.tp tbody tr:hover { background: #fafafa; }

.badge { display:inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge.market { background: var(--tp-red-soft); color: var(--tp-red); }
.badge.role-inhaber { background: #fff3cd; color: #856404; }
.badge.role-filialleiter { background: #d1ecf1; color: #0c5460; }
.badge.role-mitarbeiter { background: var(--tp-grey); color: var(--tp-text-soft); }
.badge.status-requested { background: #fff3cd; color: #856404; }
.badge.status-approved { background: #d4edda; color: #155724; }
.badge.status-rejected { background: var(--tp-red-soft); color: var(--tp-red); }
.badge.inactive { background: var(--tp-grey-2); color: var(--tp-text-soft); }

.flash { padding: 10px 14px; border-radius: var(--tp-radius); margin-bottom: 14px; font-size: 13px; }
.flash.success { background: #d4edda; color: #155724; }
.flash.error { background: #f8d7da; color: #721c24; }
.flash.info { background: #d1ecf1; color: #0c5460; }

/* ---------- Login ---------- */
.login-wrap { display:flex; min-height: 100vh; align-items: center; justify-content: center; background: var(--tp-red); }
.login-card { background: white; padding: 36px 36px 30px; border-radius: 10px; min-width: 340px; box-shadow: 0 16px 40px rgba(0,0,0,.18); text-align: center; }
.login-card img { height: 40px; margin-bottom: 18px; }
.login-card h1 { margin: 0 0 18px; font-size: 18px; }
.login-card input { width: 100%; padding: 9px 12px; border: 1px solid var(--tp-grey-2); border-radius: var(--tp-radius); margin-bottom: 10px; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 10px; }
.login-card .hint { color: var(--tp-text-soft); font-size: 12px; margin-top: 12px; }

/* ---------- Market switcher ---------- */
.market-switcher { display:flex; align-items:center; gap:6px; }
.market-switcher select { background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.4); color: white; padding: 5px 10px; border-radius: var(--tp-radius); }
.market-switcher select option { color: var(--tp-text); }

/* ---------- Schichtplan ---------- */
.shift-grid { background: white; border-radius: var(--tp-radius); overflow: hidden; box-shadow: var(--tp-shadow); }
.shift-grid table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.shift-grid th, .shift-grid td { border: 1px solid var(--tp-grey-2); padding: 0; vertical-align: top; font-size: 12px; }
.shift-grid th { background: var(--tp-grey); padding: 8px 6px; text-align: center; font-weight: 600; color: var(--tp-text-soft); text-transform: none; letter-spacing: 0; font-size: 12px; }
.shift-grid th.col-name { width: 200px; text-align: left; padding-left: 14px; }
.shift-grid th.col-totals { width: 90px; }
.shift-grid th.is-holiday, .shift-grid td.is-holiday { background: var(--tp-red-soft); }
.shift-grid th.is-weekend { background: #fafafa; color: var(--tp-text-soft); }
.shift-grid .day-num { font-weight: 600; color: var(--tp-text); }
.shift-grid .day-name { color: var(--tp-text-soft); font-size: 11px; }
.shift-grid .row-name { padding: 8px 12px; font-weight: 500; }
.shift-grid .row-name .pn { color: var(--tp-text-soft); font-size: 11px; }
.shift-grid .cell { min-height: 44px; padding: 4px; cursor: pointer; }
.shift-grid .cell:hover { background: var(--tp-red-soft); }
.shift-grid .shift-chip { display:block; background: white; border: 1px solid var(--tp-grey-2); border-left: 3px solid var(--tp-red); border-radius: 4px; padding: 3px 6px; font-size: 11px; line-height: 1.3; margin-bottom: 2px; }
.shift-grid .shift-chip:hover { background: #fafafa; }
.shift-grid .shift-chip.chip-school { border-left-color: #43a047; background: #f1f8e9; }
.shift-grid .shift-chip.chip-foreign { border-left-color: #f0a020; background: #fff8e7; }
.shift-grid .chip-badge { display:inline-block; padding: 0 5px; border-radius: 8px; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; margin-right: 4px; vertical-align: middle; }
.shift-grid .chip-badge-school { background: #43a047; color: white; }
.shift-grid .chip-badge-foreign { background: #f0a020; color: white; }
.shift-grid .abs-chip { display:block; border-radius: 4px; padding: 4px 6px; font-size: 11px; line-height: 1.3; color: white; font-weight: 500; }
.shift-grid .totals { padding: 8px; text-align: center; font-size: 12px; }
.shift-grid .totals .delta-pos { color: #155724; }
.shift-grid .totals .delta-neg { color: var(--tp-red); }
.shift-grid .totals .delta-zero { color: var(--tp-text-soft); }
.shift-grid tfoot .coverage-row td,
.shift-grid tfoot .coverage-row th { background: #fafafa; padding: 8px 6px; }
.shift-grid tfoot .coverage-row .coverage-cell { text-align: center; font-weight: 600; font-size: 14px; color: var(--tp-text); }
.shift-grid tfoot .coverage-row .row-name { background: var(--tp-grey); }
.shift-grid tfoot .coverage-row td:has(.coverage-cell.under) { background: var(--tp-red-soft); }
.shift-grid tfoot .coverage-row .coverage-cell.under { color: var(--tp-red); }
.shift-grid tfoot .coverage-row .coverage-cell.under::before { content: "▼ "; font-size: 10px; }

.shift-toolbar { display:flex; align-items:center; gap:8px; margin-bottom: 14px; }
.shift-toolbar .week-label { font-size: 15px; font-weight: 600; }

/* ---------- Crew-Kalender (Mitarbeiter × Tage) ---------- */
.crew-cal { background: white; border-radius: var(--tp-radius); box-shadow: var(--tp-shadow); overflow-x: auto; }
.crew-cal table { border-collapse: collapse; table-layout: fixed; width: 100%; min-width: max-content; }
.crew-cal th, .crew-cal td { border: 1px solid var(--tp-grey-2); padding: 0; }
.crew-cal th { background: var(--tp-grey); color: var(--tp-text-soft); font-weight: 500; }

.crew-cal .col-name { width: 180px; text-align: left; padding: 6px 10px; background: var(--tp-grey); position: sticky; left: 0; z-index: 2; }
.crew-cal td.emp-name { width: 180px; padding: 5px 10px; background: white; font-size: 12px; position: sticky; left: 0; z-index: 1; border-right: 2px solid var(--tp-grey-2); }
.crew-cal td.emp-name .pn { color: var(--tp-text-soft); font-size: 10px; margin-right: 4px; }
.crew-cal td.emp-name .name { font-weight: 500; }

.crew-cal .day-head { text-align: center; padding: 4px 0; font-size: 11px; line-height: 1.1; vertical-align: middle; }
.crew-cal .day-head .month-label { font-size: 9px; font-weight: 700; color: var(--tp-red); text-transform: uppercase; }
.crew-cal .day-head .day-num { font-weight: 600; color: var(--tp-text); font-size: 12px; }
.crew-cal .day-head .day-wd { color: var(--tp-text-soft); font-size: 9px; }

.crew-cal .day-head.is-holiday, .crew-cal td.day-cell.is-holiday { background: var(--tp-red-soft); }
.crew-cal .day-head.is-weekend, .crew-cal td.day-cell.is-weekend { background: #f5f5f5; }
.crew-cal .day-head.new-month { border-left: 2px solid var(--tp-red); }

.crew-cal td.day-cell { background: white; height: 26px; vertical-align: middle; padding: 0; }
.crew-cal td.day-cell.has-abs { padding: 1px; }

.crew-cal .abs-bar { height: 100%; min-height: 22px; width: 100%; display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; font-size: 10px; border-radius: 2px; }
.crew-cal .abs-letter { letter-spacing: .3px; }

.crew-cal .market-row td { background: var(--tp-red-soft); padding: 6px 12px; font-size: 12px; color: var(--tp-red); position: sticky; left: 0; }

/* Spaltenbreiten pro Ansicht */
.crew-cal.view-week .day-head, .crew-cal.view-week .day-cell { min-width: 80px; width: 80px; }
.crew-cal.view-month .day-head, .crew-cal.view-month .day-cell { min-width: 30px; width: 30px; }
.crew-cal.view-quarter .day-head, .crew-cal.view-quarter .day-cell { min-width: 18px; width: 18px; }
.crew-cal.view-quarter .day-head .day-wd { display: none; }
.crew-cal.view-quarter .abs-letter { font-size: 8px; }
.cal td.is-holiday { background: var(--tp-red-soft); }
.cal td .day-num { font-weight: 600; }
.cal td .holiday-name { color: var(--tp-red); font-size: 10px; margin-top: 2px; }
.cal td .abs-chip { display:block; margin-top: 3px; padding: 2px 5px; border-radius: 3px; color: white; font-size: 10px; }

/* ---------- Modal ---------- */
.modal-overlay { display:none; position:fixed; inset:0; background: rgba(0,0,0,.45); align-items:center; justify-content:center; z-index: 50; }
.modal-overlay.show { display:flex; }
.modal { background: white; border-radius: 8px; min-width: 460px; max-width: 600px; padding: 22px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal h2 { margin: 0 0 14px; font-size: 16px; }
.modal .close { float: right; cursor: pointer; color: var(--tp-text-soft); background: none; border: 0; font-size: 20px; line-height: 1; }

/* utility */
.muted { color: var(--tp-text-soft); }
.right { text-align: right; }
.center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 14px; }
.mb-0 { margin-bottom: 0; }
.spread { display:flex; justify-content: space-between; align-items: center; }
.row-gap { display:flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.legend { display:flex; gap:14px; font-size: 12px; color: var(--tp-text-soft); }
.legend .dot { display:inline-block; width:10px; height:10px; border-radius: 2px; vertical-align: middle; margin-right: 4px; }

/* ---------- Print ---------- */
.print-header { display: none; }
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  /* Hintergrundfarben (z.B. farbige Chips) müssen mitgedruckt werden */
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  body { background: white; font-size: 11px; }
  .topbar, .sidebar, .no-print, .market-switcher, .form-actions, .flash, .modal-overlay, .legend { display: none !important; }
  .app { display: block; }
  .main { padding: 0 !important; overflow: visible !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; padding: 8px 10px !important; margin-bottom: 10px !important; break-inside: avoid; }
  .page-header { display: none !important; }
  .print-header { display: block; margin-bottom: 10px; padding-bottom: 6px; border-bottom: 2px solid var(--tp-red); }
  .print-header h1 { margin: 0 0 4px; font-size: 16px; color: var(--tp-red); }
  .print-header .muted { font-size: 10px; color: #555; }
  table.tp { font-size: 10px; box-shadow: none !important; }
  table.tp th, table.tp td { padding: 4px 6px; }
  table.tp thead { display: table-header-group; }
  tr { page-break-inside: avoid; }
  a { color: inherit !important; text-decoration: none !important; }
  .badge { padding: 1px 6px !important; border: 1px solid #aaa !important; background: white !important; color: #333 !important; }

  /* Schichtplan-spezifisch */
  .shift-grid { box-shadow: none !important; }
  .shift-grid table { font-size: 9px; table-layout: fixed; width: 100%; }
  .shift-grid th, .shift-grid td { padding: 0; }
  .shift-grid th.col-name { width: 130px; padding: 4px 6px; }
  .shift-grid th.col-totals { width: 65px; padding: 4px 6px; }
  .shift-grid .row-name { padding: 4px 6px; }
  .shift-grid .day-name { font-size: 9px; }
  .shift-grid .day-num { font-size: 10px; }
  .shift-grid .cell { min-height: 28px; padding: 2px; }
  .shift-grid .shift-chip { padding: 1px 3px; font-size: 9px; margin-bottom: 1px; border-width: 1px; border-left-width: 2px; }
  .shift-grid .shift-chip.chip-school { background: #e8f5e9 !important; border-left-color: #43a047 !important; }
  .shift-grid .shift-chip.chip-foreign { background: #fff8e7 !important; border-left-color: #f0a020 !important; }
  .shift-grid .chip-badge { font-size: 7px; padding: 0 3px; }
  .shift-grid .chip-badge-school { background: #43a047 !important; color: white !important; }
  .shift-grid .chip-badge-foreign { background: #f0a020 !important; color: white !important; }
  .shift-grid .abs-chip { padding: 2px 4px; font-size: 9px; }
  .shift-grid .totals { padding: 4px; }
  .shift-grid th.is-holiday, .shift-grid td.is-holiday { background: var(--tp-red-soft) !important; }
  .shift-grid th.is-weekend, .shift-grid td.is-weekend { background: #f5f5f5 !important; }
  .shift-grid tfoot .coverage-row td,
  .shift-grid tfoot .coverage-row th { background: #f0f0f0 !important; padding: 4px; }
  .shift-grid tfoot .coverage-row td:has(.coverage-cell.under) { background: var(--tp-red-soft) !important; }
  /* Ist/Soll-Spalte wird im Druck nicht ausgegeben */
  .shift-grid th.col-totals, .shift-grid td.col-totals { display: none !important; }

  /* Crew-Kalender */
  .crew-cal { box-shadow: none !important; overflow: visible !important; }
  .crew-cal table { font-size: 8px; }
  .crew-cal td.emp-name, .crew-cal th.col-name { width: 120px !important; padding: 3px 6px; position: static !important; }
  .crew-cal td.emp-name { font-size: 9px; }
  .crew-cal .day-head { padding: 2px 0; }
  .crew-cal .day-head .day-num { font-size: 9px; }
  .crew-cal .day-head .day-wd { font-size: 7px; }
  .crew-cal td.day-cell { height: 18px; }
  .crew-cal .abs-bar { min-height: 16px; font-size: 8px; }
  .crew-cal .market-row td { background: #f0f0f0 !important; }
  .crew-cal th.is-holiday, .crew-cal td.is-holiday { background: var(--tp-red-soft) !important; }
  .crew-cal th.is-weekend, .crew-cal td.is-weekend { background: #f5f5f5 !important; }
}
