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

:root {
  --sidebar-w: 220px;
  --topbar-h: 52px;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --primary: #4f7df0;
  --primary-hover: #3d6de0;
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 8px;
  --shadow: 0 1px 4px rgba(0,0,0,.08);
  --sidebar-bg: #1a1f2e;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #4f7df0;

  /* Status colours */
  --s-leer:          #e2e8f0;
  --s-angefragt:     #fef9c3;
  --s-erhalten:      #dbeafe;
  --s-in-bearbeitung:#cffafe;
  --s-korrektur:     #fee2e2;
  --s-freigegeben:   #dcfce7;
  --s-druckfertig:   #166534;
  --s-druckfertig-fg:#fff;
}

body { font-family: system-ui, -apple-system, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font: inherit; }
input, select, textarea { font: inherit; }
ul { list-style: none; }
.hidden { display: none !important; }

/* ── Spinner ─────────────────────────────────────────────────────── */
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-center { display: flex; align-items: center; justify-content: center; padding: 4rem; }

/* ── Login ───────────────────────────────────────────────────────── */
.login-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.login-card { background: var(--surface); border-radius: 16px; box-shadow: 0 8px 32px rgba(0,0,0,.12); padding: 2.5rem; width: 100%; max-width: 380px; }
.login-card h1 { font-size: 1.5rem; font-weight: 700; color: var(--text); margin-bottom: .25rem; }
.login-sub { color: var(--text-muted); margin-bottom: 1.75rem; }
.login-card label { display: block; font-size: .8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 1rem; margin-bottom: .3rem; }
.login-card input { width: 100%; padding: .65rem .85rem; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: .95rem; outline: none; transition: border-color .15s; }
.login-card input:focus { border-color: var(--primary); }
.btn-full { width: 100%; }
.form-error { background: #fef2f2; color: var(--danger); border: 1px solid #fca5a5; border-radius: var(--radius); padding: .6rem .85rem; font-size: .88rem; margin-top: .75rem; }

/* ── Layout ──────────────────────────────────────────────────────── */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: var(--sidebar-w); background: var(--sidebar-bg); display: flex; flex-direction: column; flex-shrink: 0; transition: width .2s; overflow: hidden; }
.sidebar.collapsed { width: 0; }
.sidebar-header { padding: 1.25rem 1rem; border-bottom: 1px solid rgba(255,255,255,.07); }
.sidebar-logo { color: #fff; font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; }
.nav-list { flex: 1; padding: .75rem 0; overflow-y: auto; }
.nav-list li + li { margin-top: 2px; }
.nav-link { display: flex; align-items: center; gap: .5rem; padding: .55rem 1rem; color: var(--sidebar-text); border-radius: 6px; margin: 0 .5rem; transition: background .15s, color .15s; font-size: .88rem; }
.nav-link:hover, .nav-link.active { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--sidebar-active); color: #fff; }
.nav-link-sm { font-size: .8rem; opacity: .7; padding: .4rem 1rem; margin: 0 .5rem; }
.sidebar-footer { padding: .75rem 0; border-top: 1px solid rgba(255,255,255,.07); }
.nav-user { padding: .35rem 1rem .1rem; color: var(--sidebar-text); font-size: .82rem; opacity: .7; }
.main-wrap { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 1.25rem; gap: 1rem; flex-shrink: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.main-content { flex: 1; overflow-y: auto; padding: 1.75rem; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1rem; border-radius: var(--radius); border: none; font-size: .88rem; font-weight: 500; transition: background .15s, opacity .15s; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); border: 1.5px solid var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .85; }
.btn-icon { background: transparent; border: none; padding: .4rem; font-size: 1rem; color: var(--text-muted); border-radius: var(--radius); }
.btn-icon:hover { background: var(--bg); }
.btn-xs { padding: .25rem .6rem; font-size: .78rem; background: rgba(255,255,255,.15); color: #fff; border: none; border-radius: 5px; }
.btn-xs:hover { background: rgba(255,255,255,.25); }

/* ── Forms ───────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .35rem; }
.form-control { width: 100%; padding: .6rem .85rem; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: .93rem; outline: none; background: var(--surface); transition: border-color .15s; }
.form-control:focus { border-color: var(--primary); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── Cards ───────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.card-body { padding: 1.25rem; }
.page-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-header h1 { font-size: 1.35rem; font-weight: 700; }
.page-header .actions { margin-left: auto; display: flex; gap: .5rem; }

/* ── Issue grid ──────────────────────────────────────────────────── */
.issue-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.issue-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.25rem; cursor: pointer; transition: box-shadow .2s, transform .15s; }
.issue-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); transform: translateY(-2px); }
.issue-card-title { font-weight: 700; font-size: 1rem; margin-bottom: .2rem; }
.issue-card-sub { color: var(--text-muted); font-size: .83rem; margin-bottom: .85rem; }
.issue-progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-bottom: .6rem; }
.issue-progress-bar { height: 100%; background: var(--success); border-radius: 3px; transition: width .4s; }
.issue-meta { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ── Status badges ───────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: .2rem .6rem; border-radius: 99px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.badge-leer          { background: var(--s-leer); color: #475569; }
.badge-angefragt     { background: var(--s-angefragt); color: #854d0e; }
.badge-erhalten      { background: var(--s-erhalten); color: #1e40af; }
.badge-in_bearbeitung{ background: var(--s-in-bearbeitung); color: #0e7490; }
.badge-korrektur     { background: var(--s-korrektur); color: #991b1b; }
.badge-freigegeben   { background: var(--s-freigegeben); color: #166534; }
.badge-druckfertig   { background: var(--s-druckfertig); color: var(--s-druckfertig-fg); }
.badge-planung       { background: #ede9fe; color: #5b21b6; }
.badge-produktion    { background: #fef3c7; color: #92400e; }
.badge-abgeschlossen { background: #dcfce7; color: #166534; }
.badge-archiv        { background: #e2e8f0; color: #475569; }
.badge-anzeige       { background: #ede9fe; color: #5b21b6; }
.badge-artikel       { background: #dbeafe; color: #1e40af; }
.badge-redaktionell  { background: #cffafe; color: #0e7490; }
.badge-bildstrecke   { background: #fce7f3; color: #9d174d; }
.badge-sponsor       { background: #fef9c3; color: #854d0e; }
.badge-trennseite    { background: #f1f5f9; color: #475569; }
.badge-sonstiges     { background: #f3f4f6; color: #374151; }

/* ── Content block list ──────────────────────────────────────────── */
.content-list { display: flex; flex-direction: column; gap: .4rem; }
.content-item { background: var(--surface); border: 1.5px solid var(--border); border-radius: 10px; display: flex; align-items: center; gap: .75rem; padding: .65rem .9rem; cursor: grab; transition: box-shadow .15s; user-select: none; }
.content-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.content-item.dragging { opacity: .4; }
.content-item.drag-over { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(79,125,240,.3); }
.content-item.is-cover { background: #f8f9ff; border-style: dashed; cursor: default; }
.drag-handle { color: var(--text-muted); font-size: 1.1rem; cursor: grab; flex-shrink: 0; }
.content-item.is-cover .drag-handle { display: none; }
.content-pages { font-size: .8rem; color: var(--text-muted); min-width: 60px; flex-shrink: 0; }
.content-title { flex: 1; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content-item-actions { display: flex; gap: .3rem; flex-shrink: 0; }
.content-thumb { width: 36px; height: 36px; border-radius: 5px; object-fit: cover; background: var(--bg); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: .7rem; color: var(--text-muted); overflow: hidden; }
.content-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ── Detail panel ────────────────────────────────────────────────── */
.detail-layout { display: grid; grid-template-columns: 1fr 360px; gap: 1.5rem; align-items: start; }
@media (max-width: 900px) { .detail-layout { grid-template-columns: 1fr; } }
.detail-main { display: flex; flex-direction: column; gap: 1.25rem; }
.detail-sidebar { display: flex; flex-direction: column; gap: 1.25rem; }
.section-title { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); margin-bottom: .75rem; }
.file-item { display: flex; align-items: center; gap: .65rem; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .4rem; }
.file-item-name { flex: 1; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item-meta { font-size: .75rem; color: var(--text-muted); }
.file-preview-wrap { text-align: center; background: var(--bg); border-radius: var(--radius); padding: 1rem; border: 1px solid var(--border); }
.file-preview-wrap img { max-width: 100%; max-height: 300px; border-radius: 6px; }
.file-preview-wrap embed { width: 100%; height: 300px; border-radius: 6px; }
.file-no-preview { padding: 2rem; text-align: center; color: var(--text-muted); }

/* ── Comments & notes ────────────────────────────────────────────── */
.comment-list { display: flex; flex-direction: column; gap: .6rem; }
.comment-item { padding: .65rem .85rem; border-radius: var(--radius); background: var(--bg); }
.comment-item.system { background: #eff6ff; border-left: 3px solid var(--primary); }
.comment-meta { font-size: .75rem; color: var(--text-muted); margin-bottom: .25rem; }
.note-item { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: .6rem; }
.note-item.resolved { opacity: .6; }
.note-header { display: flex; align-items: center; gap: .5rem; padding: .55rem .75rem; background: var(--bg); }
.note-body { padding: .6rem .75rem; font-size: .9rem; }
.note-replies { border-top: 1px solid var(--border); }
.reply-item { padding: .5rem .75rem; background: #fafbfc; border-bottom: 1px solid var(--border); font-size: .87rem; }
.reply-item:last-child { border-bottom: none; }
.reply-meta { font-size: .72rem; color: var(--text-muted); margin-bottom: .15rem; }
.note-reply-form { padding: .5rem .75rem; display: flex; gap: .4rem; }
.note-reply-form input { flex: 1; padding: .4rem .65rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .85rem; }

/* ── Preview grid ────────────────────────────────────────────────── */
.preview-toolbar { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.preview-toolbar h2 { font-size: 1.1rem; font-weight: 700; }
.view-toggle { display: flex; border: 1.5px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.view-toggle button { padding: .4rem .85rem; border: none; background: transparent; font-size: .82rem; transition: background .15s; }
.view-toggle button.active { background: var(--primary); color: #fff; }
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 1rem; }
.thumb-cell { display: flex; flex-direction: column; align-items: center; gap: .4rem; }
.thumb-box { width: 100%; aspect-ratio: 3/4; background: var(--border); border-radius: 6px; overflow: hidden; display: flex; align-items: center; justify-content: center; position: relative; cursor: pointer; transition: box-shadow .15s; border: 2px solid transparent; }
.thumb-box:hover { box-shadow: 0 2px 12px rgba(0,0,0,.12); }
.thumb-box img { width: 100%; height: 100%; object-fit: cover; }
.thumb-box .thumb-pdf-icon { font-size: 2rem; color: var(--text-muted); }
.thumb-box .status-dot { position: absolute; bottom: 4px; right: 4px; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid #fff; }
.thumb-label { font-size: .72rem; color: var(--text-muted); text-align: center; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb-page { font-size: .78rem; font-weight: 600; text-align: center; }

/* Status dot colours */
.dot-leer           { background: #94a3b8; }
.dot-angefragt      { background: #eab308; }
.dot-erhalten       { background: #3b82f6; }
.dot-in_bearbeitung { background: #06b6d4; }
.dot-korrektur      { background: #ef4444; }
.dot-freigegeben    { background: #22c55e; }
.dot-druckfertig    { background: #15803d; }

/* ── Spread view ─────────────────────────────────────────────────── */
.spread-nav { display: flex; align-items: center; justify-content: center; gap: 1.5rem; margin-bottom: 1.25rem; }
.spread-wrap { display: flex; justify-content: center; gap: .5rem; }
.spread-page { flex: 1; max-width: 420px; aspect-ratio: 3/4; background: #fff; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; display: flex; flex-direction: column; position: relative; box-shadow: 0 2px 12px rgba(0,0,0,.1); }
.spread-page .spread-content { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.spread-page .spread-content img { width: 100%; height: 100%; object-fit: cover; }
.spread-page .spread-content embed { width: 100%; height: 100%; }
.spread-page-label { font-size: .75rem; text-align: center; padding: .3rem; background: var(--bg); border-top: 1px solid var(--border); font-weight: 500; }
.spread-placeholder { flex: 1; max-width: 420px; }

/* ── Legend ──────────────────────────────────────────────────────── */
.legend { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.25rem; }
.legend-item { display: flex; align-items: center; gap: .35rem; font-size: .75rem; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }

/* ── Pool ────────────────────────────────────────────────────────── */
.pool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; }
.pool-item { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.pool-thumb { width: 100%; aspect-ratio: 4/3; background: var(--bg); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.pool-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pool-thumb .pool-file-icon { font-size: 2.5rem; color: var(--text-muted); }
.pool-item-body { padding: .5rem; }
.pool-item-name { font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: .3rem; }
.pool-item-actions { display: flex; gap: .3rem; }
.pool-item.assigned { border-color: var(--success); }

/* ── Table ───────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); padding: .6rem .85rem; border-bottom: 2px solid var(--border); background: var(--bg); white-space: nowrap; }
td { padding: .65rem .85rem; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: .88rem; }
tr:hover td { background: #f8fafc; }
.sort-btn { background: none; border: none; cursor: pointer; color: inherit; font: inherit; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; display: flex; align-items: center; gap: .2rem; }
.filter-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .85rem; }
.filter-row select, .filter-row input { padding: .4rem .7rem; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: .83rem; }

/* ── Notifications ───────────────────────────────────────────────── */
.notif-btn { position: relative; font-size: 1.1rem; }
.notif-badge { position: absolute; top: 2px; right: 2px; background: var(--danger); color: #fff; font-size: .65rem; font-weight: 700; min-width: 16px; height: 16px; border-radius: 99px; display: flex; align-items: center; justify-content: center; padding: 0 3px; }
.notif-wrap { position: relative; }
.notif-dropdown { position: absolute; right: 0; top: calc(100% + .5rem); width: 340px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 100; overflow: hidden; }
.notif-header { display: flex; align-items: center; justify-content: space-between; padding: .75rem 1rem; background: var(--sidebar-bg); color: #fff; font-size: .88rem; font-weight: 600; }
.notif-dropdown ul { max-height: 360px; overflow-y: auto; }
.notif-item { padding: .75rem 1rem; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .1s; }
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: #eff6ff; }
.notif-item p { font-size: .85rem; margin-bottom: .2rem; }
.notif-item time { font-size: .72rem; color: var(--text-muted); }
.notif-empty { padding: 1.5rem; text-align: center; color: var(--text-muted); font-size: .88rem; }

/* ── Modal ───────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: 0 16px 48px rgba(0,0,0,.2); width: 100%; max-width: 560px; max-height: 90vh; display: flex; flex-direction: column; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 1rem; font-weight: 700; }
.modal-body { overflow-y: auto; padding: 1.25rem; flex: 1; }
.modal-footer { padding: .85rem 1.25rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .5rem; }

/* ── Toast ───────────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 300; display: flex; flex-direction: column; gap: .5rem; }
.toast { padding: .75rem 1.1rem; border-radius: var(--radius); font-size: .88rem; font-weight: 500; box-shadow: 0 4px 12px rgba(0,0,0,.15); animation: slide-in .25s ease; max-width: 320px; }
.toast-success { background: #166534; color: #fff; }
.toast-error   { background: #991b1b; color: #fff; }
.toast-info    { background: #1e40af; color: #fff; }
@keyframes slide-in { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Upload area ─────────────────────────────────────────────────── */
.upload-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 1.5rem; text-align: center; color: var(--text-muted); cursor: pointer; transition: border-color .2s, background .2s; }
.upload-zone:hover, .upload-zone.dragover { border-color: var(--primary); background: rgba(79,125,240,.04); }
.upload-zone input { display: none; }
.progress-bar-wrap { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: .5rem; }
.progress-bar-inner { height: 100%; background: var(--primary); border-radius: 3px; transition: width .2s; }

/* ── Users table ─────────────────────────────────────────────────── */
.role-chip { display: inline-block; padding: .15rem .55rem; border-radius: 99px; font-size: .72rem; font-weight: 700; text-transform: uppercase; }
.role-admin     { background: #fee2e2; color: #991b1b; }
.role-redaktion { background: #dbeafe; color: #1e40af; }
.role-design    { background: #ede9fe; color: #5b21b6; }
.role-gast      { background: #f1f5f9; color: #475569; }

/* ── Utility ─────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-sm    { font-size: .82rem; }
.mt-1  { margin-top: .5rem; }
.mt-2  { margin-top: 1rem; }
.mb-1  { margin-bottom: .5rem; }
.mb-2  { margin-bottom: 1rem; }
.flex  { display: flex; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
