/* ═══════════════════════════════════════════════════════
   Tourenverwaltung 3.5 — Web Design System
   Matching Desktop Theme: Standard (Hell) / Indigo
   ═══════════════════════════════════════════════════════ */
:root {
  --primary: #6366F1; --primary-hover: #4F46E5; --primary-light: #EEF2FF;
  --success: #10B981; --success-hover: #059669;
  --danger: #EF4444;  --danger-hover: #DC2626;
  --warning: #F59E0B;
  --surface: #FFFFFF;  --surface-alt: #F8FAFC;
  --bg: #F1F5F9;
  --sidebar-bg: #FFFFFF;
  --text: #1E293B;  --text-sec: #64748B;  --text-muted: #94A3B8;
  --border: #E2E8F0;  --border-light: #F1F5F9;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.15);
  --radius: 10px; --radius-sm: 6px; --radius-pill: 20px;
  --trans: .15s ease;
  --row-h: 32px; --time-col: 65px; --header-h: 32px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body, #app { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; font-size: 14px; line-height: 1.5;
  overflow: hidden;
}
.hidden { display: none !important; }
.screen { height: 100vh; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: 500 13px/1 'Inter', sans-serif;
  cursor: pointer; transition: all var(--trans); white-space: nowrap; user-select: none;
}
.btn:hover { border-color: var(--text-muted); }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: var(--success-hover); }
.btn-danger  { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); }
.btn-ghost { background: none; border-color: transparent; color: var(--text-sec); }
.btn-ghost:hover { background: var(--bg); }
.btn-pill { border-radius: var(--radius-pill); }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-sidebar {
  width: 100%; justify-content: flex-start; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: transparent; border: none; color: var(--text-sec);
  font-size: 13px; font-weight: 500;
}
.btn-sidebar:hover { background: var(--bg); color: var(--text); }
.btn-icon { font-size: 16px; width: 20px; text-align: center; }
.mt-2 { margin-top: 8px; }

/* ─── Inputs ─── */
input, select, textarea {
  font: 400 14px 'Inter', sans-serif; color: var(--text);
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); outline: none; width: 100%;
  transition: border-color var(--trans), box-shadow var(--trans);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}
input::placeholder { color: var(--text-muted); }
label { display: block; font-size: 12px; font-weight: 600; color: var(--text-sec); margin-bottom: 4px; }
.form-group { margin-bottom: 12px; }
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }

/* ─── Login ─── */
#login-screen {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1E293B 0%, #334155 50%, #1E293B 100%);
}
.login-card {
  background: var(--surface); border-radius: 16px; padding: 40px;
  width: 400px; max-width: 90vw; box-shadow: var(--shadow-lg); text-align: center;
}
.login-logo { margin-bottom: 8px; }
.login-logo img { width: 72px; height: 72px; border-radius: 16px; display: inline-block; }
.login-card h1 { font-size: 22px; font-weight: 700; color: var(--primary); }
.login-sub { font-size: 13px; color: var(--text-sec); margin-bottom: 28px; }
.login-card .form-group { text-align: left; }
.error-msg { background: #FEF2F2; color: var(--danger); padding: 8px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 12px; }

/* ─── Menu Bar ─── */
#menubar {
  display: flex; align-items: center; height: 36px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 8px; gap: 0; font-size: 13px; user-select: none; flex-shrink: 0;
}
.menu-group { position: relative; }
.menu-trigger {
  padding: 6px 12px; cursor: pointer; color: var(--text-sec); transition: all var(--trans);
  border-radius: var(--radius-sm);
}
.menu-trigger:hover, .menu-trigger.open { background: var(--bg); color: var(--text); }
.menu-dropdown {
  display: none; position: absolute; top: 100%; left: 0; min-width: 220px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); z-index: 200; padding: 4px;
}
.menu-dropdown.show, .menu-dropdown.open { display: block; }
.menu-dropdown hr { border: none; border-top: 1px solid var(--border-light); margin: 4px 0; }
.menu-item {
  padding: 8px 12px; cursor: pointer; border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 8px; transition: background var(--trans);
}
.menu-item:hover { background: var(--primary-light); color: var(--primary); }
.mi-key { margin-left: auto; padding-left: 24px; font-size: 11px; color: var(--text-muted); font-family: monospace; }
.menu-spacer { flex: 1; }
.menu-user { font-size: 12px; color: var(--text-muted); padding-right: 8px; }

/* ─── Content Layout ─── */
#content { display: flex; flex: 1; overflow: hidden; height: calc(100vh - 36px - 34px); }
#main-screen { display: flex; flex-direction: column; }

/* ─── Sidebar ─── */
#sidebar {
  width: 220px; flex-shrink: 0; background: var(--sidebar-bg);
  border-right: 1px solid var(--border); padding: 16px 12px;
  display: flex; flex-direction: column; gap: 16px; overflow-y: auto;
}
.kw-card {
  background: var(--primary); color: #fff; border-radius: var(--radius);
  padding: 14px; text-align: center; box-shadow: var(--shadow);
}
.kw-label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; opacity: .8; }
.kw-number { display: block; font-size: 36px; font-weight: 700; line-height: 1.1; }
.sidebar-actions { display: flex; flex-direction: column; gap: 2px; }

/* ─── Mini Calendar ─── */
.mini-cal { font-size: 12px; }
.mini-cal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.mini-cal-header span { font-weight: 600; font-size: 13px; }
.mini-cal-header button { background: none; border: none; cursor: pointer; font-size: 14px; color: var(--text-sec); padding: 2px 6px; border-radius: 4px; }
.mini-cal-header button:hover { background: var(--bg); }
.mini-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; gap: 1px; }
.mini-cal-dow { padding: 4px 2px; font-size: 11px; font-weight: 500; color: var(--text-muted); }
.mini-cal-day {
  padding: 4px 2px; cursor: pointer; border-radius: 4px; font-size: 12px;
  transition: all var(--trans);
}
.mini-cal-day.empty { cursor: default; }
.mini-cal-day:not(.empty):hover { background: var(--primary-light); }
.mini-cal-day.today { background: var(--primary); color: #fff; font-weight: 700; }
.mini-cal-day.in-week { background: var(--primary-light); }
.mini-cal-day.today.in-week { background: var(--primary); color: #fff; }

/* ─── Main Area ─── */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ─── Week Nav ─── */
#week-nav {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--surface);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.nav-left, .nav-right { display: flex; gap: 4px; align-items: center; }
.week-label { flex: 1; text-align: center; font-weight: 600; font-size: 14px; color: var(--text); }
.search-input { width: 200px; padding: 6px 12px; font-size: 13px; border-radius: var(--radius-pill); }

/* ─── Vehicle Tabs ─── */
.tabs-bar {
  display: flex; gap: 0; padding: 0 12px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  overflow-x: auto; flex-shrink: 0;
}
.tab-item {
  display: flex; align-items: center; gap: 6px; padding: 8px 14px;
  font-size: 13px; font-weight: 500; color: var(--text-sec);
  cursor: pointer; border-bottom: 2px solid transparent;
  white-space: nowrap; transition: all var(--trans); user-select: none;
}
.tab-item:hover { color: var(--text); background: var(--surface-alt); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════
   Schedule Grid
   ═══════════════════════════════════════════════════════ */
.schedule-container { flex: 1; overflow: auto; position: relative; background: var(--surface); }

.schedule-grid { display: flex; min-width: 100%; position: relative; }

.schedule-time-col {
  width: var(--time-col); flex-shrink: 0; position: sticky; left: 0;
  z-index: 5; background: var(--surface-alt); border-right: 1px solid var(--border);
}
.schedule-time-header {
  height: var(--header-h); border-bottom: 1px solid var(--border);
  background: var(--surface-alt); position: sticky; top: 0; z-index: 6;
}
.time-label {
  height: var(--row-h); display: flex; align-items: flex-start; justify-content: flex-end;
  padding: 1px 8px 0 0; font-size: 11px; color: var(--text-muted); font-weight: 500;
}

.schedule-days { display: flex; flex: 1; }
.schedule-day {
  flex: 1; min-width: 120px; position: relative;
  border-right: 1px solid var(--border-light);
}
.schedule-day:last-child { border-right: none; }

.day-header {
  height: var(--header-h); display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 4;
  user-select: none;
}
.day-header.weekend { color: var(--text-muted); }
.day-header.today { color: var(--primary); background: var(--primary-light); }

.day-slots { position: relative; }
.day-slot {
  height: var(--row-h); border-bottom: 1px solid var(--border-light);
}
.day-slot.half { border-bottom-style: dotted; border-bottom-color: #f0f0f0; }
.day-slot.work { background: #fff; }
.day-slot.non-work { background: #F8FAFC; }
.day-slot.weekend { background: #F1F5F9; }

/* Appointment blocks */
.apt-block {
  position: absolute; left: 2px; right: 2px;
  border-radius: 6px; padding: 3px 6px; cursor: pointer;
  font-size: 11px; line-height: 1.3; overflow: hidden;
  border: 1px solid rgba(0,0,0,.12);
  transition: box-shadow var(--trans), transform var(--trans);
  z-index: 2;
}
.apt-block:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); z-index: 3; }
.apt-block.fixed { border: 2.5px solid var(--danger); }
.apt-block.dragging { opacity: .7; z-index: 10; box-shadow: var(--shadow-lg); }
.apt-vehicle { font-weight: 700; font-size: 10px; text-transform: uppercase; opacity: .85; white-space: nowrap; overflow: hidden; }
.apt-address { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.apt-product { font-size: 10px; opacity: .75; white-space: nowrap; overflow: hidden; }

/* Selection preview (drag to create) */
.select-preview {
  position: absolute; left: 2px; right: 2px;
  background: rgba(99,102,241,0.12); border: 2px dashed var(--primary);
  border-radius: 6px; z-index: 3; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: var(--primary);
}

/* ─── Status Bar ─── */
#statusbar {
  height: 34px; display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: var(--surface); border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-sec); flex-shrink: 0; position: relative;
}
.status-progress {
  position: absolute; top: 0; left: 0; height: 3px; width: 0;
  background: var(--primary); transition: width .3s linear; border-radius: 0 2px 2px 0;
}
#status-text.connected { color: var(--success); }
#status-text.error { color: var(--danger); }

/* ═══════════════════════════════════════════════════════
   Modals
   ═══════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15,23,42,.45); z-index: 500;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-box {
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg);
  width: 90vw; max-height: 90vh; display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-box.sm { max-width: 500px; }
.modal-box.md { max-width: 750px; }
.modal-box.lg { max-width: 1050px; }
.modal-box.xl { max-width: 1200px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
#modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none; border: none; font-size: 20px; cursor: pointer;
  color: var(--text-muted); padding: 4px 8px; border-radius: var(--radius-sm);
  transition: all var(--trans);
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { flex: 1; overflow-y: auto; padding: 20px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 20px; border-top: 1px solid var(--border); flex-shrink: 0;
}

/* ─── Context Menu ─── */
.ctx-menu {
  position: fixed; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md); z-index: 600;
  padding: 4px; min-width: 180px;
}
.ctx-menu hr { border: none; border-top: 1px solid var(--border-light); margin: 4px 0; }
.ctx-item {
  padding: 8px 12px; cursor: pointer; font-size: 13px;
  border-radius: var(--radius-sm); transition: background var(--trans);
}
.ctx-item:hover { background: var(--primary-light); color: var(--primary); }

/* ─── Tooltip ─── */
.tooltip {
  position: fixed; background: var(--text); color: #fff;
  padding: 8px 12px; border-radius: var(--radius-sm); font-size: 12px;
  line-height: 1.4; max-width: 300px; z-index: 700;
  box-shadow: var(--shadow-md); pointer-events: none;
}

/* ─── Data Tables (in modals) ─── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 8px 12px; font-size: 11px; font-weight: 600;
  color: var(--text-sec); text-transform: uppercase; letter-spacing: .5px;
  background: var(--surface-alt); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1;
}
.data-table td { padding: 8px 12px; font-size: 13px; border-bottom: 1px solid var(--border-light); }
.data-table tr { cursor: pointer; transition: background var(--trans); }
.data-table tbody tr:hover { background: var(--primary-light); }
.data-table tbody tr.selected { background: var(--primary-light); outline: 2px solid var(--primary); }

/* ─── Tabs inside modals ─── */
.modal-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.modal-tab {
  padding: 8px 16px; font-size: 13px; font-weight: 500; cursor: pointer;
  border-bottom: 2px solid transparent; color: var(--text-sec);
  transition: all var(--trans);
}
.modal-tab:hover { color: var(--text); }
.modal-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── Info/Status messages ─── */
.info-bar {
  padding: 8px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 12px;
}
.info-bar.success { background: #ECFDF5; color: var(--success); }
.info-bar.error { background: #FEF2F2; color: var(--danger); }
.info-bar.info { background: var(--primary-light); color: var(--primary); }

/* ─── Print View ─── */
.print-content {
  font-family: 'Inter', sans-serif; padding: 24px; font-size: 12px;
}
.print-content h2 { font-size: 16px; margin-bottom: 12px; border-bottom: 2px solid #333; padding-bottom: 4px; }
.print-content h3 { font-size: 14px; margin: 16px 0 8px; color: #555; }
.print-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.print-table th, .print-table td { padding: 6px 10px; text-align: left; border-bottom: 1px solid #ddd; font-size: 12px; }
.print-table th { font-weight: 600; background: #f5f5f5; }
.print-fixed { color: var(--danger); font-weight: 700; }

/* ─── Responsive ─── */
@media (max-width: 768px) {
  #sidebar { display: none; }
  #week-nav { flex-wrap: wrap; padding: 8px; gap: 6px; }
  .week-label { order: -1; width: 100%; text-align: center; font-size: 13px; }
  .search-input { width: 120px; }
  .schedule-day { min-width: 80px; }
}

@media print {
  #menubar, #sidebar, #week-nav, #statusbar, .tabs-bar, .schedule-container { display: none !important; }
  .modal-overlay { position: static; background: none; }
  .modal-box { box-shadow: none; border: none; max-width: 100%; width: 100%; max-height: none; }
  .modal-header, .modal-footer { display: none; }
}
