/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:       #14243e;
  --navy-dark:  #0e1b30;
  --navy-text:  #1e2749;
  --gold:       #b1a06a;
  --yellow:     #ffd60a;
  --bg:         #f4f5f7;
  --surface:    #ffffff;
  --border:     #e4e7ec;
  --text:       #263447;
  --muted:      #8b95a7;
  --blue:       #7a9cc4;
  --green:      #1e9e6a;
  --red:        #d93a4a;
  --orange:     #d97530;
  --amber:      #c49010;
  --purple:     #7855c0;
  --radius:     8px;
  --shadow:     0 1px 3px rgba(16,27,48,.08);
  --shadow-md:  0 4px 14px rgba(16,27,48,.12);
  --shadow-lg:  0 8px 32px rgba(16,27,48,.18);
}

html, body { height: 100%; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cfd5de; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ===== Header / Topbar ===== */
header {
  background: var(--navy);
  height: 60px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.logo { height: 34px; width: auto; flex-shrink: 0; }

.topbar-brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
/* Weißer Logo-Kasten: das wika-Logo (dunkle Schrift) braucht auf dem
   Navy-Header einen hellen Untergrund */
.topbar-brand .logo-box {
  background: #fff;
  border-radius: 8px;
  padding: 5px 10px;
  display: flex;
  align-items: center;
}
.topbar-brand .logo-box img { height: 28px; width: auto; display: block; }

.header-divider {
  width: 1px;
  height: 28px;
  background: rgba(255,255,255,.15);
}

.header-text h1 {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .01em;
}
.header-text p {
  font-size: .72rem;
  color: var(--blue);
  margin-top: 1px;
}

/* Buttons inside topbar always on dark background */
header .btn {
  background: rgba(255,255,255,.1);
  color: rgba(255,255,255,.9);
  border: 1px solid rgba(255,255,255,.2);
}
header .btn:hover {
  background: rgba(255,255,255,.18);
  color: #fff;
  border-color: rgba(255,255,255,.35);
}
header .btn-yellow {
  background: var(--yellow);
  color: var(--navy-text);
  border-color: transparent;
  font-weight: 700;
}
header .btn-yellow:hover { filter: brightness(.95); }

/* ===== Card ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 6px;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: all .15s;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--navy);
  color: #fff;
}
.btn-primary:hover { background: var(--navy-dark); }

.btn-yellow {
  background: var(--yellow);
  color: var(--navy-text);
  font-weight: 700;
}
.btn-yellow:hover { filter: brightness(.95); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--muted); background: #f6f8fa; }

.btn-danger {
  background: #fdecee;
  color: var(--red);
  border: 1px solid #f5c6cb;
}
.btn-danger:hover { background: #fad8db; }

.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

.btn-sm {
  padding: 5px 12px;
  font-size: .78rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--navy-text);
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.btn-sm:hover { border-color: var(--navy); color: var(--navy); background: #f1f4f8; }

/* ===== Inputs ===== */
input, select, textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .92rem;
  font-family: inherit;
  color: var(--text);
  background: #f7f9fc;
  transition: border-color .15s, background .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--navy);
  background: #fff;
}
select option { background: #fff; color: var(--text); }
textarea { resize: vertical; min-height: 120px; }

label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

/* ===== Utility ===== */
.hidden { display: none !important; }

/* ============================================================
   FORM PAGE
   ============================================================ */
.form-page main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 16px;
}

.ticket-form, .success-box {
  width: 100%;
  max-width: 700px;
  padding: 40px 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 20px;
}

.form-row.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 560px) {
  .form-row.two-col { grid-template-columns: 1fr; }
  .ticket-form, .success-box { padding: 28px 20px; }
}

.form-section-label {
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.form-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}

/* ===== Bild-Upload ===== */
.upload-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 22px 16px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: #fafbfc;
  color: var(--muted);
  font-size: .85rem;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  margin-bottom: 0;
}
.upload-drop:hover, .upload-drop.drag {
  border-color: var(--navy);
  background: #f1f4f8;
  color: var(--navy-text);
}
.upload-icon { font-size: 1.5rem; }
.upload-hint { font-size: .72rem; color: var(--muted); font-weight: 400; }

.preview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}
.preview-grid:empty { display: none; }
.preview-item {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.preview-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(16,27,48,.75);
  color: #fff;
  font-size: .7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.preview-remove:hover { background: var(--red); }

/* ===== Anhang-Galerie (Board-Modal) ===== */
.anhang-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 4px;
}
.anhang-thumb {
  display: flex;
  flex-direction: column;
  width: 110px;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: #fafbfc;
  transition: box-shadow .15s, border-color .15s;
}
.anhang-thumb:hover { box-shadow: var(--shadow-md); border-color: #cfd5de; }
.anhang-thumb img {
  width: 100%;
  height: 78px;
  object-fit: cover;
  display: block;
}
.anhang-name {
  font-size: .68rem;
  color: var(--muted);
  padding: 4px 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Success Box */
.success-box {
  text-align: center;
  padding: 56px 44px;
}
.success-icon { font-size: 3.5rem; margin-bottom: 20px; }
.success-box h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: 12px; color: var(--navy-text); }
.success-box p  { color: var(--muted); margin-bottom: 6px; font-size: .9rem; }
.ticket-nr-display {
  display: inline-block;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--navy);
  font-family: 'Courier New', monospace;
  margin: 8px 0;
}

footer {
  text-align: center;
  padding: 20px;
  font-size: .78rem;
  color: var(--muted);
}

/* ============================================================
   BOARD PAGE
   ============================================================ */
.board-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Stats Bar */
.stats-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex;
  gap: 24px;
  align-items: center;
  font-size: .82rem;
  flex-shrink: 0;
}
.stat-item {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
}
.stat-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.stat-val {
  font-weight: 700;
  color: var(--navy-text);
}
.stats-bar-right { margin-left: auto; display: flex; gap: 12px; align-items: center; }

/* Board Toolbar */
.board-toolbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.board-toolbar input,
.board-toolbar select {
  width: auto;
  padding: 8px 12px;
  font-size: .85rem;
}
.board-toolbar input { min-width: 200px; }
.toolbar-spacer { flex: 1; }

.board-page main {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 20px 24px 24px;
  background: var(--bg);
  min-height: 0;
}

/* Kanban Board */
.kanban-board {
  display: flex;
  gap: 16px;
  height: 100%;
  min-width: max-content;
}

/* Column */
.kanban-col {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: #eef1f5;
  max-height: 100%;
}

.col-header {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.col-header-left { display: flex; align-items: center; gap: 10px; }

.col-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.col-title {
  font-weight: 700;
  font-size: .88rem;
  color: var(--navy-text);
  letter-spacing: .01em;
}

.col-count {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 2px 9px;
  font-size: .75rem;
  font-weight: 700;
  color: var(--muted);
  min-width: 28px;
  text-align: center;
}

.col-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: background .15s;
  min-height: 0;
}

.col-body.drag-over {
  background: rgba(20,36,62,.06);
  outline: 2px dashed rgba(20,36,62,.2);
  outline-offset: -4px;
}

.col-empty {
  text-align: center;
  color: var(--muted);
  font-size: .8rem;
  padding: 32px 8px;
  opacity: .7;
}

/* ===== Ticket Card ===== */
.ticket-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  cursor: grab;
  box-shadow: var(--shadow);
  transition: box-shadow .2s, transform .15s, border-color .2s;
  user-select: none;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

.ticket-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--card-accent, var(--blue));
}

.ticket-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: #cfd5de;
}

.ticket-card.dragging {
  opacity: .35;
  cursor: grabbing;
  transform: rotate(1deg) scale(.98);
}

.card-inner { padding: 12px 14px 12px 18px; }

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  gap: 8px;
}

.card-top-left { display: flex; flex-direction: column; gap: 4px; }

.ticket-nr {
  font-size: .7rem;
  font-weight: 700;
  color: var(--muted);
  font-family: 'Courier New', monospace;
  letter-spacing: .04em;
}
.ticket-nr.large { font-size: .95rem; }

.prio-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .68rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: .06em;
  border: 1px solid;
  white-space: nowrap;
}

.card-title {
  font-weight: 600;
  font-size: .88rem;
  line-height: 1.35;
  color: var(--navy-text);
  margin-bottom: 10px;
}

.card-kategorie {
  display: inline-block;
  font-size: .72rem;
  background: #f1f4f8;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  color: var(--muted);
  margin-bottom: 10px;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  gap: 8px;
}

.card-author {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .75rem;
  color: var(--muted);
  min-width: 0;
  flex: 1;
}

.avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .6rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
}

.card-author-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.card-date {
  font-size: .7rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.card-actions-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px 10px 18px;
  background: #fafbfc;
  border-top: 1px solid var(--border);
}

.status-select {
  flex: 1;
  padding: 5px 8px;
  font-size: .75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

/* ============================================================
   BOARD HEADER nav
   ============================================================ */
.header-nav {
  display: flex;
  gap: 4px;
  margin-left: 16px;
}
.nav-item {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: .83rem;
  color: rgba(255,255,255,.65);
  transition: all .15s;
  cursor: pointer;
  font-weight: 500;
}
.nav-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.1); color: #fff; }

/* ============================================================
   MODAL
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(16,27,48,.45);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  width: 100%;
  max-width: 680px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 32px;
  z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  width: 32px; height: 32px;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.modal-close:hover { background: var(--border); color: var(--text); }

.modal-header {
  margin-bottom: 24px;
  padding-right: 40px;
}
.modal-header > .modal-header-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--navy-text);
}

.modal-section-title {
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 10px;
  margin-top: 20px;
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 4px;
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .82rem;
  flex-wrap: wrap;
}
.meta-label {
  font-weight: 600;
  color: var(--muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  min-width: 70px;
}
.meta-row select {
  width: auto;
  padding: 4px 8px;
  font-size: .8rem;
}

.beschreibung-box {
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: .88rem;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: 4px;
  white-space: pre-wrap;
}

.kommentare { margin-top: 4px; }

.kommentar-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.kommentar {
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .85rem;
}
.kommentar-meta {
  font-size: .73rem;
  color: var(--muted);
  margin-bottom: 5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.kommentar-meta .avatar { width: 18px; height: 18px; font-size: .55rem; }

.no-comments {
  font-size: .82rem;
  color: var(--muted);
  font-style: italic;
  padding: 16px;
  text-align: center;
  background: #fafbfc;
  border-radius: 8px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.kommentar-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

.error { color: var(--red); padding: 24px; text-align: center; }
