/* =====================================================================
   RESET & CUSTOM PROPERTIES
   ===================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Eure Bowcamp Palette */
  --primary:          #0059c6; /* Bowcamp Blau */
  --primary-dark:     #00479e; /* Etwas dunkleres Blau für Hover-Effekte */
  --accent:           #fe6c01; /* Bowcamp Orange */
  --accent-dark:      #d95c00; /* Etwas dunkleres Orange für Hover */
  
  --danger:           #ef4444;
  --danger-bg:        #fef2f2;
  --success:          #22c55e;
  --success-bg:       #f0fdf4;
  --info-bg:          #eff6ff;
  --info-text:        #0059c6;

  /* Surfaces */
  --bg:               #f1f5f9;
  --surface:          #ffffff;
  --border:           #e2e8f0;
  --border-dark:      #cbd5e1;

  /* Text */
  --text:             #1e293b;
  --text-muted:       #64748b;

  /* Drop feedback */
  --drop-valid-bg:    rgba(34, 197, 94, 0.22);
  --drop-valid-border:#22c55e;
  --drop-invalid-bg:  rgba(239, 68, 68, 0.18);
  --drop-invalid-border:#ef4444;

  /* Layout */
  --header-h:         58px;
  --sidebar-w:        272px;
  --time-gutter-w:    70px;
  --room-min-w:       155px;
  --row-h:            44px;   

  /* Misc */
  --radius:           6px;
  --shadow-sm:        0 1px 2px rgba(0,0,0,0.08);
  --shadow:           0 1px 3px rgba(0,0,0,0.10), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:        0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
}

/* =====================================================================
   BASE
   ===================================================================== */
html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

/* =====================================================================
   APP SHELL
   ===================================================================== */
.app-header {
  height: var(--header-h);
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  position: relative;
  z-index: 40;
}

.app-logo {
  font-size: 1.4rem;
  line-height: 1;
}

.app-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.header-subtitle {
  font-size: 0.78rem;
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-body {
  display: flex;
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

/* =====================================================================
   SIDEBAR
   ===================================================================== */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.section-heading {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
}

/* ── Form ── */
.form-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.form-group {
  margin-bottom: 11px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input::placeholder {
  color: #94a3b8;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.form-group input.invalid {
  border-color: var(--danger);
}

.form-group input.invalid:focus {
  box-shadow: 0 0 0 3px rgba(239,68,68,0.12);
}

.required {
  color: var(--danger);
  margin-left: 1px;
}

.field-error {
  display: block;
  font-size: 0.72rem;
  color: var(--danger);
  margin-top: 3px;
  min-height: 1em;
}

.form-actions {
  display: flex;
  gap: 7px;
  margin-top: 6px;
}

/* ── Buttons ── */
.btn {
  padding: 7px 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s, transform 0.1s, box-shadow 0.14s;
  white-space: nowrap;
  line-height: 1.4;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent); 
  color: #fff;
  flex: 1;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover { background: var(--accent-dark); }

.btn-secondary {
  background: var(--border);
  color: var(--text);
}

.btn-secondary:hover { background: var(--border-dark); }

/* ── Unplaced tray ── */
.tray-section {
  padding: 14px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tray-hint {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  line-height: 1.45;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--primary);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 9px;
}

.unplaced-tray {
  flex: 1;
  overflow-y: auto;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s, background 0.15s;
}

.unplaced-tray.drag-over {
  border-color: var(--primary);
  background: rgba(37,99,235,0.04);
}

.tray-empty {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  padding: 20px 0;
  font-style: italic;
}

/* ── Tray cards ── */
.tray-card {
  border-radius: var(--radius);
  padding: 8px 10px;
  cursor: grab;
  border-left: 4px solid transparent;
  background: var(--surface);
  box-shadow: var(--shadow);
  position: relative;
  transition: box-shadow 0.14s, opacity 0.14s;
  user-select: none;
  list-style: none;
}

.tray-card:hover {
  box-shadow: var(--shadow-md);
}

.tray-card.dragging {
  opacity: 0.35;
  cursor: grabbing;
}

.tray-card .card-title {
  font-weight: 600;
  font-size: 0.83rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tray-card .card-speaker {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.tray-card .card-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Icon buttons (edit/delete on cards) ── */
.card-actions {
  position: absolute;
  top: 5px;
  right: 5px;
  display: none;
  gap: 3px;
}

.tray-card:hover .card-actions,
.session-card:hover .card-actions {
  display: flex;
}

.btn-icon {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.65;
  transition: opacity 0.12s, background 0.12s;
  background: rgba(255,255,255,0.45);
  color: inherit;
  flex-shrink: 0;
}

.btn-icon:hover { opacity: 1; background: rgba(255,255,255,0.75); }
.btn-icon.btn-delete:hover { background: rgba(239,68,68,0.18); color: #991b1b; }

/* =====================================================================
   SCHEDULE AREA
   ===================================================================== */
.schedule-area {
  flex: 1;
  overflow: auto;
  position: relative;
  background: var(--bg);
}

/* ── Sticky room-name header ── */
.schedule-header {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 2px solid var(--border-dark);
  min-width: max-content;   /* prevent header from collapsing when body is wide */
}

.corner-cell {
  width: var(--time-gutter-w);
  flex-shrink: 0;
  background: var(--bg);
  /* Sticky left so the corner stays visible on horizontal scroll */
  position: sticky;
  left: 0;
  z-index: 25;
}

.room-headers {
  display: flex;
  flex: 1;
}

.room-header {
  flex: 1;
  min-width: var(--room-min-w);
  padding: 9px 10px;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text);
  text-align: center;
  border-left: 1px solid var(--border);
  background: var(--surface);
  letter-spacing: 0.01em;
}

/* ── Schedule body ── */
.schedule-body {
  display: flex;
  align-items: flex-start;
  min-width: max-content;
}

/* ── Time gutter ── */
.time-gutter {
  width: var(--time-gutter-w);
  flex-shrink: 0;
  position: relative;
  /* Stick to left on horizontal scroll */
  position: sticky;
  left: 0;
  z-index: 10;
  background: var(--bg);
}

.time-tick {
  position: absolute;
  left: 0;
  right: 0;
  height: var(--row-h);
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 3px 8px 0 0;
  font-size: 0.68rem;
  color: var(--text-muted);
  pointer-events: none;
  white-space: nowrap;
}

/* Tick mark line on the right edge */
.time-tick::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 5px;
  height: 1px;
  background: var(--border-dark);
}

.time-tick.tick-hour {
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--text);
}

.time-tick.tick-hour::after {
  width: 7px;
  background: var(--text-muted);
}

.time-tick.tick-end {
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--text);
}

.time-tick.tick-end::after {
  width: 7px;
  background: var(--text-muted);
}

/* ── Room columns ── */
.room-columns {
  display: flex;
  flex: 1;
}

.room-column {
  flex: 1;
  min-width: var(--room-min-w);
  position: relative;
  border-left: 1px solid var(--border);
}

/* Background cells — visual grid lines and drop targets */
.cell {
  height: var(--row-h);
  border-bottom: 1px solid var(--border);
  box-sizing: border-box;
  transition: background 0.08s;
}

/* Hour boundaries — slightly stronger line every 4 rows */
.cell:nth-child(4n) {
  border-bottom-color: var(--border-dark);
}

/* Half-hour — subtle mid line */
.cell:nth-child(2n):not(:nth-child(4n)) {
  border-bottom-color: #dde3ec;
}

/* =====================================================================
   SESSION CARDS  (placed on grid)
   ===================================================================== */
.session-card {
  position: absolute;
  left: 3px;
  right: 3px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 5px 7px;
  cursor: grab;
  overflow: hidden;
  z-index: 5;
  box-shadow: var(--shadow);
  user-select: none;
  transition: box-shadow 0.14s, opacity 0.14s;
}

.session-card:hover {
  box-shadow: var(--shadow-md);
  z-index: 6;
}

.session-card.dragging {
  opacity: 0.35;
  cursor: grabbing;
}

/* Visual overlap warning */
.session-card.overlapping {
  outline: 2px solid var(--danger);
  outline-offset: 1px;
}

.session-card .card-title {
  font-weight: 700;
  font-size: 0.78rem;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.session-card .card-speaker {
  font-size: 0.7rem;
  opacity: 0.87;
  margin-top: 2px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.session-card .card-time {
  font-size: 0.66rem;
  opacity: 0.72;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* =====================================================================
   DROP OVERLAY  (shown while dragging over a column)
   ===================================================================== */
.drop-overlay {
  position: absolute;
  left: 0;
  right: 0;
  border-radius: var(--radius);
  pointer-events: none;
  z-index: 8;
  border: 2px dashed transparent;
  transition: background 0.05s;
}

.drop-overlay.drop-valid {
  background: var(--drop-valid-bg);
  border-color: var(--drop-valid-border);
}

.drop-overlay.drop-invalid {
  background: var(--drop-invalid-bg);
  border-color: var(--drop-invalid-border);
}

/* =====================================================================
   LOADING OVERLAY
   ===================================================================== */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(241,245,249,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  font-size: 0.9rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* =====================================================================
   TOAST NOTIFICATIONS
   ===================================================================== */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 15px;
  border-radius: var(--radius);
  font-size: 0.84rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  max-width: 320px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.22s, transform 0.22s;
  pointer-events: auto;
  line-height: 1.4;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-error   { background: var(--danger-bg);  color: #991b1b; border-left: 4px solid var(--danger); }
.toast-success { background: var(--success-bg); color: #15803d; border-left: 4px solid var(--success); }
.toast-info    { background: var(--info-bg);    color: var(--info-text); border-left: 4px solid var(--primary); }

/* =====================================================================
   SCROLLBARS  (WebKit)
   ===================================================================== */
.schedule-area::-webkit-scrollbar,
.sidebar::-webkit-scrollbar,
.unplaced-tray::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.schedule-area::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track,
.unplaced-tray::-webkit-scrollbar-track {
  background: transparent;
}

.schedule-area::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb,
.unplaced-tray::-webkit-scrollbar-thumb {
  background: var(--border-dark);
  border-radius: 3px;
}

.schedule-area::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover,
.unplaced-tray::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
/* =====================================================================
   DAY TABS & HEADER SPACER
   ===================================================================== */
.day-tabs {
  display: flex;
  gap: 8px;
  margin-left: 20px;
}

.day-tab {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  padding: 6px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  transition: background 0.2s, transform 0.1s;
}

.day-tab:hover { background: rgba(255, 255, 255, 0.35); }
.day-tab:active { transform: scale(0.95); }

.day-tab.active {
  background: var(--accent); /* Nutzt das Bowcamp Orange! */
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.header-spacer { flex: 1; }

.btn-print {
  background: #fff;
  color: var(--primary);
  font-weight: bold;
}
.btn-print:hover { background: #f8fafc; }

/* =====================================================================
   DRUCK-LAYOUT (@media print)
   ===================================================================== */
.print-only { display: none; }

@media print {
  /* Seiten-Grundeinstellungen fürs Papier */
  @page { size: landscape; margin: 1cm; }
  
  body, html {
    height: auto !important;
    background: #fff !important;
    overflow: visible !important;
  }

  /* Verstecke alles, was auf dem Papier stört */
  .app-header, .sidebar, #toast-container, .drop-overlay {
    display: none !important;
  }

  /* Passe das Raster für den Druck an */
  .app-body {
    height: auto !important;
    display: block !important;
  }

  .schedule-area {
    height: auto !important;
    overflow: visible !important;
    background: #fff !important;
  }

  /* Hebe die Fixierung der Spalten für den Druck auf, 
     damit nichts abgeschnitten wird */
  .schedule-header, .corner-cell, .time-gutter {
    position: static !important;
  }

  /* Blende die Druck-Überschrift ein */
  .print-only {
    display: block;
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 20px;
    color: #000;
  }

  /* Zwingt den Browser, die blauen und orangenen Hintergründe zu drucken */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}
/* =====================================================================
   MOBILE OPTIMIERUNG (Hamburger-Menü)
   ===================================================================== */
.mobile-menu-btn {
  display: none;
  font-size: 1.4rem;
  width: 34px;
  height: 34px;
  background: transparent;
  color: #fff;
}
.mobile-menu-btn:hover { background: rgba(255,255,255,0.2); }

.mobile-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 45;
}

/* Greift nur bei Bildschirmen kleiner als 768px (Tablets hochkant & Handys) */
@media (max-width: 768px) {
  .mobile-menu-btn { display: flex; }
  
  .app-body { position: relative; }
  
  .sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-md);
  }

  /* Diese Klasse wird per JavaScript hinzugefügt, um das Menü zu öffnen */
  .sidebar.open { transform: translateX(0); }
  
  .mobile-overlay.open { display: block; }
}