/* Big Dutchman Mediaplanung - CI: Orange #ea6f18, Inter, schwarz/weiss */

:root {
  --orange: #ea6f18;
  --orange-dark: #c95a0e;
  --orange-light: #fef0e6;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --bg: #fafafa;
  --bg-card: #ffffff;
  --sidebar-bg: #1f1f1f;
  --sidebar-fg: #e5e5e5;
  --sidebar-active: #ea6f18;
  --success: #16a34a;
  --success-bg: #ecfdf5;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.06);
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--orange); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.6rem; margin: 0 0 .25rem; font-weight: 700; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; font-weight: 600; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.negative { color: var(--error); }

/* Sidebar */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: 230px;
  background: var(--sidebar-bg); color: var(--sidebar-fg);
  display: flex; flex-direction: column;
  padding: 1.25rem 0;
}
.brand {
  padding: 0 1.25rem 1.25rem; display: flex; align-items: center; gap: .6rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-mark {
  background: var(--orange); color: white;
  width: 36px; height: 36px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.brand-mark.large { width: 56px; height: 56px; font-size: 20px; }
.brand-text { font-weight: 700; font-size: 1.05rem; }

.sidebar nav { flex: 1; display: flex; flex-direction: column; padding: 1rem .5rem; gap: 2px; }
.sidebar nav a {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .85rem; border-radius: 6px;
  color: var(--sidebar-fg); font-weight: 500; font-size: 13px;
}
.sidebar nav a i { width: 18px; text-align: center; opacity: .75; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.sidebar nav a.active { background: var(--orange); color: white; }
.sidebar nav a.active i { opacity: 1; }

.sidebar-footer { padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,.08); }
.user-info { display: flex; align-items: center; gap: .6rem; margin-bottom: .75rem; }
.user-info i { font-size: 24px; }
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.link-btn {
  background: none; border: none; color: var(--sidebar-fg);
  padding: 0; cursor: pointer; font-size: 12px; opacity: .7;
}
.link-btn:hover { opacity: 1; }

/* Main */
main { padding: 1.5rem 2rem; max-width: 1400px; }
main.with-sidebar { margin-left: 230px; }
main.full { margin: 0 auto; }

.page-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 1.25rem; gap: 1rem; flex-wrap: wrap;
}
.page-header p { margin: 0; }
.page-actions { display: flex; gap: .5rem; align-items: center; }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.card.no-pad { padding: 0; overflow: hidden; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
.card-header h2 { margin: 0; }

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-bottom: 1.25rem; }
.grid-cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-cols-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.span-2 { grid-column: span 2; }
/* Burger-Menue + Backdrop (versteckt auf Desktop) */
.burger { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 900px) {
  .grid-2, .grid-cols-2, .grid-cols-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  main.with-sidebar { margin-left: 0; padding: 1rem; padding-top: 4.5rem; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .2s ease-out;
    z-index: 1001;
    width: 260px;
  }
  body.sidebar-open .sidebar { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .burger {
    display: flex; position: fixed; top: 0.75rem; left: 0.75rem;
    z-index: 1002;
    width: 44px; height: 44px;
    background: var(--orange); color: white;
    border: none; border-radius: 8px;
    align-items: center; justify-content: center; font-size: 18px;
    cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.15);
  }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0;
    background: rgba(0,0,0,.4); z-index: 1000;
    opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  /* Beim Klick auf einen Link im Mobile-Menue: zumachen */
}

/* KPI */
.kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex; gap: 1rem; align-items: center;
  box-shadow: var(--shadow);
}
.kpi-icon {
  width: 42px; height: 42px; border-radius: 8px;
  background: var(--orange-light); color: var(--orange);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  flex-shrink: 0;
}
.kpi-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.kpi-value { font-size: 1.5rem; font-weight: 700; margin-top: 2px; }
.kpi-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: .65rem .9rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table th { background: #fafafa; font-weight: 600; color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
.data-table tbody tr:hover { background: #fafafa; }
.data-table th.sortable {
  cursor: pointer; user-select: none;
  padding-right: 1.5rem; position: relative;
}
.data-table th.sortable::after {
  content: "↕"; position: absolute; right: .5rem; top: 50%; transform: translateY(-50%);
  color: #d1d5db; font-size: 11px;
}
.data-table th.sortable[data-sort-dir="asc"]::after { content: "▲"; color: var(--orange); }
.data-table th.sortable[data-sort-dir="desc"]::after { content: "▼"; color: var(--orange); }

.table-filter {
  display: flex; align-items: center; gap: .6rem;
  background: white; border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .55rem .85rem;
  margin-bottom: .75rem;
  position: relative;
}
.table-filter i { color: var(--text-muted); }
.table-filter input {
  border: none; flex: 1; height: auto;
  background: transparent; padding: 0; font-size: 14px;
}
.table-filter input:focus { box-shadow: none; outline: none; }

.audit-diff-table {
  margin-top: .35rem; font-size: 12px;
}
.audit-diff-table th { text-align: left; padding: 2px 8px 2px 0; font-weight: 600; color: var(--text-muted); }
.audit-diff-table td { padding: 2px 6px; }
.data-table.compact th, .data-table.compact td { padding: .5rem .75rem; }
.row-actions { display: flex; gap: .25rem; align-items: center; white-space: nowrap; }
/* Wenn .row-actions direkt auf einer Tabellenzelle/-spalte sitzt: Tabellen-Layout
   beibehalten, damit der Inhalt nicht vertikal aus der Zeile rutscht. */
.data-table th.row-actions,
.data-table td.row-actions {
  display: table-cell;
  text-align: right;
  vertical-align: middle;
  white-space: nowrap;
  width: 1%;
}
/* inline-flex-Buttons (Stift, Speichern …) richten sich sonst an der unsichtbaren
   Textbaseline der Zelle aus - bei mehrzeiligen Nachbarzellen wandert die Baseline,
   und die Buttons wirken zueinander versetzt. */
.data-table td .btn { vertical-align: middle; }
.data-table td.row-actions .btn + .btn { margin-left: 2px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  background: white; border: 1px solid var(--border);
  color: var(--text); padding: .5rem .9rem;
  border-radius: 6px; font-size: 13px; font-weight: 500;
  cursor: pointer; font-family: inherit;
  text-decoration: none; transition: all .15s;
}
.btn:hover { background: #f9fafb; border-color: #d1d5db; text-decoration: none; }
.btn-primary { background: var(--orange); border-color: var(--orange); color: white; }
.btn-primary:hover { background: var(--orange-dark); border-color: var(--orange-dark); }
.btn-danger { background: white; border-color: var(--error); color: var(--error); }
.btn-danger:hover { background: var(--error-bg); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: #f3f4f6; border-color: transparent; }
.btn-sm { padding: .35rem .6rem; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; padding: .7rem; font-size: 14px; }
.btn-group { display: inline-flex; gap: 2px; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-top-left-radius: 6px; border-bottom-left-radius: 6px; }
.btn-group .btn:last-child  { border-top-right-radius: 6px; border-bottom-right-radius: 6px; }

/* Forms */
label {
  display: flex; flex-direction: column; gap: .3rem;
  font-size: 12px; color: var(--text-muted); font-weight: 500;
}
label span { display: block; }
input[type=text], input[type=number], input[type=date], input[type=url], input[type=password],
input[type=search], input[type=email], select, textarea {
  width: 100%;
  height: 38px;
  padding: .5rem .65rem;
  border: 1px solid var(--border); border-radius: 6px;
  background: white; font-size: 14px; font-family: inherit;
  color: var(--text); transition: border-color .1s, box-shadow .1s;
  box-sizing: border-box;
}
textarea {
  height: auto;
  min-height: 70px;
}
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%236b7280' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .65rem center;
  padding-right: 1.8rem;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(234,111,24,.12);
}
input[disabled] { background: #f9fafb; color: var(--text-muted); }
textarea { resize: vertical; min-height: 70px; }

.form-grid { display: flex; flex-direction: column; gap: 0; }
.req { color: var(--orange); font-weight: 700; margin-left: 2px; }
fieldset.card { border: 1px solid var(--border); padding: 1.25rem; }
fieldset.card legend {
  padding: 0 .5rem; font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .5px; color: var(--orange);
}
.form-actions {
  display: flex; justify-content: flex-end; gap: .5rem;
  padding-top: .5rem;
  position: sticky; bottom: 0; background: linear-gradient(to bottom, transparent, var(--bg) 40%);
  padding-bottom: .5rem;
}

.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { width: auto; flex: 1; min-width: 180px; }

/* Filter bar */
.filter-bar {
  display: flex; gap: .5rem; align-items: center;
  margin-bottom: 1rem; flex-wrap: wrap;
  background: white; padding: .75rem; border-radius: var(--radius);
  border: 1px solid var(--border);
}
.filter-bar .field { position: relative; flex: 1; min-width: 220px; }
.filter-bar .field i { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.filter-bar .field input { padding-left: 2rem; }
.filter-bar select { width: auto; min-width: 140px; }

/* Badges */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
  background: #f3f4f6; color: #4b5563;
}
.badge-geplant { background: #fef3c7; color: #92400e; }
.badge-gebucht { background: #dbeafe; color: #1e40af; }
.badge-versendet { background: #e0e7ff; color: #4338ca; }
.badge-geschlossen { background: #d1fae5; color: #065f46; }
.badge-storniert { background: #fee2e2; color: #991b1b; }

/* Tabs */
.tabs {
  display: flex; gap: 2px; border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem; flex-wrap: wrap;
}
.tab {
  padding: .65rem 1rem; color: var(--text-muted);
  font-weight: 500; font-size: 13px; border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--orange); border-bottom-color: var(--orange); }

/* Nur-Lesen-Banner */
.readonly-banner {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  padding: .75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  display: flex; align-items: center; gap: .6rem;
  font-size: 13px;
}
.readonly-banner i { color: #d97706; }
/* Visuelle Hinweise im Viewer-Modus: disabled-inputs werden vom JS gesetzt;
   hier nur die Form-Actions ausblenden falls JS noch nicht gelaufen ist. */
body.viewer .attachment-upload { display: none; }
body.viewer .form-actions button[type=submit] { display: none; }

/* Flash */
.flash {
  padding: .75rem 1rem; border-radius: 6px; margin-bottom: 1rem;
  display: flex; align-items: center; gap: .5rem; font-size: 13px;
}
.flash-success { background: var(--success-bg); color: var(--success); border: 1px solid #a7f3d0; }
.flash-error { background: var(--error-bg); color: var(--error); border: 1px solid #fca5a5; }

/* Login */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1f1f1f 0%, #2d2d2d 100%);
  padding: 1rem;
}
.login-card {
  background: white; padding: 2.5rem; border-radius: 12px;
  width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-brand h1 { margin: .75rem 0 .25rem; }
.login-brand p { margin: 0; color: var(--text-muted); font-size: 13px; }
.login-card form label { margin-bottom: 1rem; }
.login-card form label span { font-weight: 500; color: var(--text); margin-bottom: .35rem; }

/* Chart container: fixe Hoehe verhindert unendliches Wachstum durch Chart.js
   (maintainAspectRatio:false braucht einen Parent mit definierter Hoehe). */
.chart-box {
  position: relative;
  height: 280px;
  width: 100%;
}
.chart-box.tall { height: 340px; }

/* UTM */
.utm-preview {
  margin-top: 1rem; padding: .75rem 1rem;
  background: var(--orange-light); border-radius: 6px;
  border: 1px solid #fbd9be;
}
.utm-preview code {
  display: block; margin-top: .25rem; font-size: 12px;
  word-break: break-all; color: var(--text); font-family: 'JetBrains Mono', 'Consolas', monospace;
}
.utm-result {
  display: flex; gap: .75rem; align-items: center;
  padding: 1rem; background: #f9fafb; border-radius: 6px;
}
.utm-result code {
  flex: 1; font-size: 13px; word-break: break-all;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
}

/* Anhaenge / Attachments */
.attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}
.attachment-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color .1s, box-shadow .1s;
}
.attachment-card:hover { border-color: var(--orange); box-shadow: 0 4px 12px rgba(234,111,24,.08); }
.attachment-thumb {
  display: block; height: 130px;
  background: #f9fafb;
  position: relative; overflow: hidden;
}
.attachment-thumb img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.attachment-icon {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; font-size: 48px; color: var(--text-muted);
}
.attachment-icon .fa-file-pdf { color: #dc2626; }
.attachment-meta { padding: .6rem .75rem .35rem; flex: 1; min-width: 0; }
.attachment-name {
  font-size: 12px; font-weight: 500; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.attachment-actions {
  display: flex; justify-content: flex-end; gap: 0;
  padding: 0 .5rem .5rem;
  border-top: 1px solid var(--border);
  margin-top: .5rem; padding-top: .35rem;
}

.attachment-upload {
  display: flex; gap: .75rem; align-items: stretch;
  margin-top: 1rem;
}
.attachment-dropzone {
  flex: 1;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex; align-items: center; gap: .75rem;
  color: var(--text-muted); font-size: 13px;
  cursor: pointer;
  transition: border-color .1s, background .1s;
  background: #fafafa;
}
.attachment-dropzone:hover { border-color: var(--orange); background: var(--orange-light); }
.attachment-dropzone i { font-size: 24px; color: var(--orange); }
.attachment-dropzone input[type=file] {
  height: auto;
  border: none; background: transparent; padding: 0;
  width: auto; flex: 1;
}
.attachment-dropzone input[type=file]:focus { box-shadow: none; }

/* Kalender */
.calendar { width: 100%; border-collapse: collapse; table-layout: fixed; }
.calendar th {
  background: #fafafa; color: var(--text-muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: .4px;
  padding: .5rem; border-bottom: 1px solid var(--border);
  text-align: center;
}
.calendar td { vertical-align: top; border: 1px solid var(--border); padding: .35rem; height: 110px; }
.calendar td.cal-empty { background: #fafafa; }
.calendar td.cal-today { background: #fef0e6; }
.cal-daynum { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: .3rem; }
.cal-today .cal-daynum { color: var(--orange); }
.cal-event {
  display: block; font-size: 11px;
  padding: 2px 6px; margin-bottom: 2px;
  border-radius: 3px; border-left: 3px solid var(--orange);
  background: #fff; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-decoration: none;
}
.cal-event:hover { background: var(--orange); color: white; text-decoration: none; }
.cal-event-dus { border-left-color: #fbbf24; background: #fefbeb; }
.cal-event-dus:hover { background: #fbbf24; color: white; }
.cal-wf-print  { border-left-color: #6b7280; }
.cal-wf-display { border-left-color: #3b82f6; }
.cal-wf-newsletter { border-left-color: #10b981; }
.cal-wf-sonstige { border-left-color: #a855f7; }
.cal-legend {
  display: inline-block; width: 14px; height: 4px; border-radius: 2px;
  background: var(--orange); margin: 0 .25rem 0 .5rem; vertical-align: middle;
}
.cal-legend.cal-wf-print { background: #6b7280; }
.cal-legend.cal-wf-display { background: #3b82f6; }
.cal-legend.cal-wf-newsletter { background: #10b981; }
.cal-legend.cal-wf-sonstige { background: #a855f7; }

/* Progress bar */
.progress {
  width: 100%; max-width: 180px;
  height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden;
  margin-bottom: 2px;
}
.progress .bar { height: 100%; background: var(--orange); transition: width .3s; }
.progress .bar.over { background: var(--error); }
