/* ─── Reset & Variables ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --blue:    #1e40af;
  --blue-lt: #3b82f6;
  --green:   #16a34a;
  --amber:   #d97706;
  --red:     #dc2626;
  --purple:  #7c3aed;
  --gray:    #6b7280;
  --bg:      #f1f5f9;
  --white:   #ffffff;
  --border:  #e2e8f0;
  --text:    #1e293b;
  --text-lt: #64748b;

  /* Status colors */
  --s-neu:          #3b82f6;
  --s-gesichtet:    #7c3aed;
  --s-bearbeitung:  #f59e0b;
  --s-warten:       #ef4444;
  --s-erledigt:     #10b981;
  --s-gesendet:     #6b7280;

  --header-h: 56px;
  --filter-h: 52px;
  --radius:   10px;
  --shadow:   0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.15);
}

html { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
}

/* ─── Header ─── */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  background: var(--blue);
  color: white;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.header-left, .header-right { display: flex; align-items: center; gap: 8px; }
.app-title { font-size: 18px; font-weight: 700; letter-spacing: -.3px; }

/* ─── Filter Bar ─── */
.filter-bar {
  position: fixed; top: var(--header-h); left: 0; right: 0; z-index: 90;
  height: var(--filter-h);
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  gap: 8px;
  overflow-x: auto;
}
.filter-group { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.filter-input, .filter-select {
  height: 34px; border: 1px solid var(--border); border-radius: 6px;
  padding: 0 10px; font-size: 13px; background: white; color: var(--text);
  outline: none;
}
.filter-input:focus, .filter-select:focus { border-color: var(--blue-lt); }
.filter-input { width: 160px; }
.task-count { font-size: 13px; color: var(--text-lt); white-space: nowrap; flex-shrink: 0; }

/* ─── Kanban Board ─── */
.kanban-board {
  position: fixed;
  top: calc(var(--header-h) + var(--filter-h));
  left: 0; right: 0; bottom: 0;
  display: flex; gap: 10px;
  overflow-x: auto; overflow-y: hidden;
  padding: 12px;
  align-items: flex-start;
}
.kanban-board::-webkit-scrollbar { height: 6px; }
.kanban-board::-webkit-scrollbar-track { background: transparent; }
.kanban-board::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ─── Kanban Column ─── */
.kanban-col {
  flex: 0 0 260px;
  background: #e8eef7;
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  max-height: 100%;
  transition: background .15s;
}
.kanban-col.drag-over { background: #dbeafe; }

.kanban-col-header {
  padding: 10px 12px;
  font-weight: 600; font-size: 13px;
  display: flex; align-items: center; justify-content: space-between;
  border-radius: var(--radius) var(--radius) 0 0;
  color: white;
  flex-shrink: 0;
}
#col-neu           .kanban-col-header { background: var(--s-neu); }
#col-gesichtet     .kanban-col-header { background: var(--s-gesichtet); }
#col-in-bearbeitung .kanban-col-header { background: var(--s-bearbeitung); }
#col-warten        .kanban-col-header { background: var(--s-warten); }
#col-erledigt      .kanban-col-header { background: var(--s-erledigt); }
#col-gesendet      .kanban-col-header { background: var(--s-gesendet); }

.col-count {
  background: rgba(255,255,255,.3); border-radius: 10px;
  padding: 1px 8px; font-size: 12px; font-weight: 700;
}

.kanban-cards {
  flex: 1; overflow-y: auto; padding: 8px;
  display: flex; flex-direction: column; gap: 8px;
  min-height: 60px;
}
.kanban-cards::-webkit-scrollbar { width: 4px; }
.kanban-cards::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

.col-empty {
  text-align: center; color: var(--text-lt); font-size: 13px;
  padding: 20px 0; display: none;
}
.kanban-cards.is-empty .col-empty { display: block; }

.btn-add-col {
  margin: 0 8px 8px; padding: 8px;
  background: none; border: 1.5px dashed #94a3b8; border-radius: 7px;
  color: var(--text-lt); font-size: 13px; cursor: pointer;
  transition: all .15s; flex-shrink: 0;
}
.btn-add-col:hover { background: rgba(0,0,0,.04); border-color: var(--blue-lt); color: var(--blue-lt); }

/* ─── Task Card ─── */
.task-card {
  background: white; border-radius: 8px;
  padding: 10px 12px; cursor: pointer;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--gray);
  transition: box-shadow .15s, transform .15s;
  user-select: none;
}
.task-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.task-card.dragging { opacity: .5; box-shadow: var(--shadow-lg); transform: rotate(2deg); }
.task-card[data-wichtigkeit="Hoch"]   { border-left-color: var(--red); }
.task-card[data-wichtigkeit="Mittel"] { border-left-color: var(--amber); }
.task-card[data-wichtigkeit="Niedrig"] { border-left-color: var(--gray); }

.card-prio {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; margin-bottom: 4px;
}
.prio-hoch   { color: var(--red); }
.prio-mittel { color: var(--amber); }
.prio-niedrig { color: var(--gray); }

.card-location { font-size: 12px; color: var(--text-lt); margin-bottom: 6px; }
.card-description {
  font-size: 14px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin-bottom: 8px;
}
.card-meta {
  display: flex; gap: 10px; font-size: 12px; color: var(--text-lt); flex-wrap: wrap;
}
.card-meta span { display: flex; align-items: center; gap: 3px; }

/* ─── List View ─── */
.list-view {
  position: fixed;
  top: calc(var(--header-h) + var(--filter-h));
  left: 0; right: 0; bottom: 0;
  overflow: auto; padding: 12px;
  background: var(--bg);
}
.task-table { width: 100%; border-collapse: collapse; background: white; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.task-table th {
  background: var(--blue); color: white; padding: 10px 14px;
  text-align: left; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.task-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.task-table tr:last-child td { border-bottom: none; }
.task-table tr:hover td { background: #f8fafc; }
.task-table tr { cursor: pointer; }

/* ─── Badges ─── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600;
}
.badge-hoch    { background: #fee2e2; color: var(--red); }
.badge-mittel  { background: #fef3c7; color: var(--amber); }
.badge-niedrig { background: #f1f5f9; color: var(--gray); }
.badge-status  { background: #eff6ff; color: var(--blue); }
.badge-offline { background: #fef2f2; color: var(--red); border-radius: 6px; padding: 3px 8px; font-size: 12px; font-weight: 600; }

.status-badge {
  padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600;
  display: inline-block; white-space: nowrap;
}
.status-neu           { background: #dbeafe; color: #1d4ed8; }
.status-gesichtet     { background: #ede9fe; color: #6d28d9; }
.status-in-bearbeitung{ background: #fef3c7; color: #b45309; }
.status-warten        { background: #fee2e2; color: #b91c1c; }
.status-erledigt      { background: #dcfce7; color: #15803d; }
.status-gesendet      { background: #f1f5f9; color: #475569; }

/* ─── Modals ─── */
.modal {
  display: none;
  position: fixed; inset: 0; z-index: 200;
  align-items: flex-end;
}
.modal.open {
  display: flex;
}
@media (min-width: 640px) { .modal.open { align-items: center; justify-content: flex-end; } }

.modal-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.45);
  animation: fadeIn .2s ease;
  pointer-events: none;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-panel {
  position: relative; z-index: 1;
  background: white;
  border-radius: 16px 16px 0 0;
  width: 100%; max-height: 92vh; overflow-y: auto;
  animation: slideUp .25s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (min-width: 640px) {
  .modal-panel {
    border-radius: var(--radius);
    width: 600px; max-height: 90vh;
    margin: 16px;
    animation: slideRight .2s ease;
  }
  @keyframes slideRight { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
}

.modal-header {
  position: sticky; top: 0; background: white; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 17px; font-weight: 700; }
.detail-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.modal-panel-sm { max-width: 520px; }
@media (min-width: 640px) { .modal-panel-sm { width: 520px; } }

/* ─── Detail Panel ─── */
.detail-content { padding: 16px; }

.detail-meta {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px;
}

.detail-section { margin-bottom: 20px; }
.detail-section h3 { font-size: 13px; font-weight: 700; color: var(--text-lt); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }

.detail-description { font-size: 16px; line-height: 1.6; }

.image-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.gallery-item { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; transition: transform .2s; }
.gallery-item img:hover { transform: scale(1.05); }
.gallery-item .btn-del-img {
  position: absolute; top: 4px; right: 4px;
  background: rgba(0,0,0,.6); color: white; border: none; border-radius: 50%;
  width: 22px; height: 22px; font-size: 13px; cursor: pointer; line-height: 1;
  display: none; align-items: center; justify-content: center;
}
.gallery-item:hover .btn-del-img { display: flex; }

.status-select-detail {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 14px; font-weight: 500; cursor: pointer; background: white;
}
.status-select-detail:focus { outline: none; border-color: var(--blue-lt); }

.verlauf-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.verlauf-item { display: flex; gap: 10px; font-size: 14px; }
.verlauf-time { font-size: 12px; color: var(--text-lt); white-space: nowrap; padding-top: 2px; flex-shrink: 0; }
.verlauf-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.verlauf-dot.notiz  { background: var(--blue-lt); }
.verlauf-dot.status { background: var(--amber); }
.verlauf-dot.system { background: #94a3b8; }
.verlauf-text { flex: 1; }

.note-input-area { display: flex; gap: 8px; margin-top: 8px; }
.note-input {
  flex: 1; padding: 8px 12px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 14px; resize: none;
}
.note-input:focus { outline: none; border-color: var(--blue-lt); }

/* ─── Upload Area ─── */
.upload-area { border: 2px dashed var(--border); border-radius: 8px; padding: 16px; text-align: center; }
.upload-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: 8px; background: var(--bg);
  cursor: pointer; font-size: 14px; color: var(--blue); font-weight: 500;
  transition: background .15s;
}
.upload-btn:hover { background: #dbeafe; }
.image-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.preview-item { position: relative; width: 72px; height: 72px; border-radius: 6px; overflow: hidden; }
.preview-item img { width: 100%; height: 100%; object-fit: cover; }
.preview-item .btn-remove-preview {
  position: absolute; top: 2px; right: 2px;
  background: rgba(0,0,0,.6); color: white; border: none; border-radius: 50%;
  width: 18px; height: 18px; font-size: 11px; cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}

/* ─── Form ─── */
.task-form { padding: 16px; }
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text-lt); }
.form-group textarea, .form-group input[type="text"], .form-group select {
  padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: white; color: var(--text);
}
.form-group textarea:focus, .form-group input:focus, .form-group select:focus {
  outline: none; border-color: var(--blue-lt);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.input-combo { display: flex; flex-direction: column; gap: 5px; }

/* ─── Buttons ─── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px;
  background: var(--blue); color: white;
  border: none; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: #1d4ed8; }
.btn-primary svg { width: 18px; height: 18px; }

.btn-ghost {
  padding: 7px 14px; border-radius: 8px;
  background: none; border: 1.5px solid var(--border);
  color: var(--text); font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background .15s;
}
.btn-ghost:hover { background: var(--bg); }

.btn-danger-ghost {
  padding: 7px 14px; border-radius: 8px;
  background: none; border: 1.5px solid #fca5a5;
  color: var(--red); font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background .15s;
}
.btn-danger-ghost:hover { background: #fee2e2; }

.btn-icon {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px;
  background: none; border: none; cursor: pointer; color: white;
  transition: background .15s;
}
.btn-icon:hover { background: rgba(255,255,255,.15); }
.btn-icon svg { width: 20px; height: 20px; }
.modal-header .btn-icon { color: var(--text-lt); }
.modal-header .btn-icon:hover { background: var(--bg); }

.btn-sm {
  padding: 5px 10px; font-size: 13px; border-radius: 6px;
}

/* ─── Toast ─── */
.toast-container {
  position: fixed; bottom: 20px; right: 20px; z-index: 999;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: #1e293b; color: white; border-radius: 8px;
  padding: 12px 16px; font-size: 14px; max-width: 320px;
  box-shadow: var(--shadow-lg); animation: toastIn .25s ease;
  pointer-events: auto;
}
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }
@keyframes toastIn { from { transform: translateY(20px); opacity: 0; } }

/* ─── Lightbox ─── */
.lightbox {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,.9); display: flex; align-items: center; justify-content: center;
}
.lightbox img { max-width: 95vw; max-height: 95vh; border-radius: 4px; }
.lightbox-close {
  position: absolute; top: 16px; right: 16px;
  background: rgba(255,255,255,.2); color: white; border: none;
  width: 40px; height: 40px; border-radius: 50%; font-size: 20px; cursor: pointer;
}

/* ─── Loading ─── */
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid rgba(255,255,255,.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: absolute; inset: 0; background: rgba(255,255,255,.6);
  display: flex; align-items: center; justify-content: center; z-index: 10;
}

/* ─── Drag & Drop placeholder ─── */
.drag-placeholder {
  border: 2px dashed #93c5fd; border-radius: 8px;
  height: 60px; background: #eff6ff;
}

/* ─── Upload in detail ─── */
.detail-upload-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px;
  background: #eff6ff; color: var(--blue);
  border: 1.5px solid #bfdbfe; font-size: 13px; font-weight: 500; cursor: pointer;
}
.detail-upload-btn:hover { background: #dbeafe; }

/* ─── Standorte Modal ─── */
.standort-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: var(--bg); border-radius: 8px;
  font-size: 14px;
}
.standort-item .btn-del-standort {
  background: none; border: none; color: #f87171; cursor: pointer;
  font-size: 18px; line-height: 1; padding: 2px 4px; border-radius: 4px;
}
.standort-item .btn-del-standort:hover { background: #fee2e2; }

/* ─── Responsive ─── */
@media (max-width: 420px) {
  .filter-bar { height: auto; padding: 8px; }
  .filter-group { flex-wrap: wrap; }
  .filter-input { width: 120px; }
  .app-title { font-size: 15px; }
  .btn-primary span { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .detail-actions .btn-ghost, .detail-actions .btn-danger-ghost { display: none; }
}

/* ─── Karteikarten (Mobile) ─── */
@media (max-width: 640px) {
  .kanban-col { flex: 0 0 295px; }

  .task-card {
    border-left: none;
    border-radius: 10px;
    padding: 0;
    overflow: hidden;
    background: #fffdf5;
    box-shadow: 0 4px 14px rgba(0,0,0,.11), 0 1px 4px rgba(0,0,0,.07);
    position: relative;
  }

  /* Farbige Lasche oben */
  .task-card::before {
    content: '';
    display: block;
    height: 7px;
    background: var(--gray);
    border-radius: 0;
  }
  .task-card[data-wichtigkeit="Hoch"]::before   { background: var(--red); }
  .task-card[data-wichtigkeit="Mittel"]::before  { background: var(--amber); }
  .task-card[data-wichtigkeit="Niedrig"]::before { background: #94a3b8; }

  /* Linienstruktur wie Karteikarte */
  .task-card::after {
    content: '';
    position: absolute;
    bottom: 36px; left: 0; right: 0;
    height: 1px;
    background: #ede9d8;
  }

  .task-card .card-prio        { padding: 10px 14px 2px; font-size: 10px; }
  .task-card .card-location    { padding: 0 14px 4px; font-size: 13px; }
  .task-card .card-description {
    padding: 4px 14px 12px;
    font-size: 15px; font-weight: 500; line-height: 1.5;
    -webkit-line-clamp: 3;
  }
  .task-card .card-meta {
    padding: 8px 14px;
    background: rgba(0,0,0,.02);
  }

  /* Eselsohr-Effekt an der oberen rechten Ecke */
  .task-card .card-corner {
    position: absolute;
    top: 7px; right: 0;
    width: 0; height: 0;
    border-style: solid;
    border-width: 0 14px 14px 0;
    border-color: transparent rgba(0,0,0,.07) transparent transparent;
  }
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
