/* ═══════════════════════════════════════════════════════
   Messe-System v2 – Admin CSS
   ═══════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:      #3b82f6;
  --brand-dark: #1d4ed8;
  --sidebar-bg: #0f172a;
  --sidebar-w:  240px;
  --topbar-h:   60px;
  --bg:         #f8fafc;
  --surface:    #ffffff;
  --border:     #e2e8f0;
  --text:       #0f172a;
  --text-2:     #475569;
  --text-3:     #94a3b8;
  --radius:     8px;
  --shadow:     0 1px 3px rgba(0,0,0,.08);
  --shadow-md:  0 4px 12px rgba(0,0,0,.1);
}

body { font-family: 'Inter', system-ui, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }

/* ── Auth ─────────────────────────────────────────────── */
.auth-body { background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-wrap { width: 100%; max-width: 420px; padding: 1rem; }
.login-card { background: var(--surface); border-radius: 16px; padding: 2.5rem; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo h1 { font-size: 1.5rem; font-weight: 700; margin-top: .75rem; }
.login-logo p { color: var(--text-2); margin-top: .25rem; }
.login-form { display: flex; flex-direction: column; gap: 1rem; }

/* ── Shell ────────────────────────────────────────────── */
.admin-body { background: var(--bg); }
.admin-shell { display: flex; min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar { width: var(--sidebar-w); background: var(--sidebar-bg); color: #94a3b8; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; transition: transform .25s; }
.sidebar-logo { padding: 1.25rem 1rem; border-bottom: 1px solid #1e293b; }
.logo-text { font-weight: 700; font-size: 1.1rem; color: #f1f5f9; letter-spacing: -.02em; }
.logo-img { max-height: 36px; max-width: 180px; object-fit: contain; }
.sidebar-nav { flex: 1; padding: .75rem 0; overflow-y: auto; }
.nav-section { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: #475569; padding: .75rem 1rem .25rem; }
.nav-item { display: flex; align-items: center; gap: .625rem; padding: .5rem 1rem; color: #94a3b8; transition: background .15s, color .15s; cursor: pointer; font-size: 13.5px; }
.nav-item:hover { background: #1e293b; color: #e2e8f0; text-decoration: none; }
.nav-item.active { background: #1e3a5f; color: #60a5fa; font-weight: 500; border-right: 2px solid var(--brand); }
.nav-item i { width: 16px; text-align: center; flex-shrink: 0; }
.sidebar-user { padding: 1rem; border-top: 1px solid #1e293b; display: flex; align-items: center; gap: .625rem; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; flex-shrink: 0; }
.user-info { flex: 1; overflow: hidden; }
.user-name { font-size: 13px; font-weight: 500; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: #64748b; text-transform: capitalize; }
.logout-btn { background: none; border: none; color: #64748b; cursor: pointer; padding: .25rem; border-radius: 4px; }
.logout-btn:hover { color: #ef4444; }

/* ── Main ─────────────────────────────────────────────── */
.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 1rem; padding: 0 1.5rem; position: sticky; top: 0; z-index: 50; }
.sidebar-toggle { display: none; background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-2); }
.page-title { font-size: 1.1rem; font-weight: 600; flex: 1; }
.topbar-right { display: flex; gap: .5rem; }
.content-area { padding: 1.5rem; flex: 1; }

/* ── Buttons ──────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1rem; border-radius: var(--radius); font-weight: 500; font-size: 13.5px; border: 1px solid transparent; cursor: pointer; transition: all .15s; white-space: nowrap; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-danger  { background: #ef4444; color: #fff; border-color: #ef4444; }
.btn-danger:hover { background: #dc2626; }
.btn-white   { background: rgba(255,255,255,.9); color: var(--text); border-color: transparent; }
.btn-white:hover { background: #fff; }
.btn-sm { padding: .3rem .75rem; font-size: 12.5px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Forms ────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .375rem; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text); }
.form-control { width: 100%; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); transition: border-color .15s; }
.form-control:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
textarea.form-control { resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-page { max-width: 720px; }

/* ── Cards ────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header h2 { font-size: 15px; font-weight: 600; }
.card-body { padding: 1.25rem; }
.card-body.p0 { padding: 0; }
.card-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .5rem; }
.form-card { margin-top: 1rem; }

/* ── Tables ───────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th { padding: .625rem 1rem; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); border-bottom: 1px solid var(--border); text-align: left; }
.table td { padding: .625rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg); }
.empty { text-align: center; color: var(--text-3); font-size: 13px; }

/* ── Stats ────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; display: flex; align-items: center; gap: 1rem; }
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.stat-icon.blue   { background: #eff6ff; color: #3b82f6; }
.stat-icon.green  { background: #f0fdf4; color: #10b981; }
.stat-icon.amber  { background: #fffbeb; color: #f59e0b; }
.stat-icon.purple { background: #f5f3ff; color: #8b5cf6; }
.stat-icon.red    { background: #fef2f2; color: #ef4444; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-2); margin-top: .25rem; }

/* ── Dashboard Grid ───────────────────────────────────── */
.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 1rem; }
@media(max-width:1100px) { .dashboard-grid { grid-template-columns: 1fr 1fr; } .dashboard-grid > .card:first-child { grid-column: 1/-1; } }
@media(max-width:700px)  { .dashboard-grid { grid-template-columns: 1fr; } }

/* ── Badges ───────────────────────────────────────────── */
.badge { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: capitalize; }
.badge-active, .badge-published { background: #dcfce7; color: #166534; }
.badge-inactive, .badge-draft   { background: #f1f5f9; color: #475569; }
.badge-archived                 { background: #fef3c7; color: #92400e; }
.badge-planned                  { background: #eff6ff; color: #1d4ed8; }

/* ── Alerts ───────────────────────────────────────────── */
.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 13.5px; }
.alert-error   { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }

/* Toast */
.toast { padding: .5rem 1rem; border-radius: var(--radius); font-size: 13px; animation: fadeIn .3s ease; }
.toast-success { background: #dcfce7; color: #166534; }
.toast-error   { background: #fef2f2; color: #991b1b; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; } }

/* ── Page Actions ─────────────────────────────────────── */
.page-actions { display: flex; gap: .5rem; margin-bottom: 1.25rem; align-items: center; }
.filter-group { display: flex; gap: .25rem; }
.icon-btn { color: var(--text-3); padding: .25rem; }
.icon-btn:hover { color: var(--brand); }

/* ── Empty State ──────────────────────────────────────── */
.empty-state { text-align: center; padding: 4rem 2rem; color: var(--text-2); }
.empty-state i { font-size: 3rem; color: var(--text-3); margin-bottom: 1rem; display: block; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: .5rem; }
.empty-state p { color: var(--text-3); margin-bottom: 1.5rem; }

/* ── Katalog Grid (admin) ─────────────────────────────── */
.katalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.25rem; }
.katalog-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); transition: box-shadow .2s; }
.katalog-card:hover { box-shadow: var(--shadow-md); }
.katalog-cover { position: relative; aspect-ratio: 3/4; overflow: hidden; background: #f1f5f9; }
.katalog-cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--text-3); font-size: 3rem; }
.katalog-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.5); display: flex; gap: .5rem; align-items: center; justify-content: center; opacity: 0; transition: opacity .2s; }
.katalog-card:hover .katalog-overlay { opacity: 1; }
.katalog-badge { position: absolute; top: .5rem; right: .5rem; }
.katalog-info { padding: 1rem; }
.katalog-info h3 { font-size: 14px; font-weight: 600; margin-bottom: .5rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.katalog-meta { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; color: var(--text-2); font-size: 12px; }
.type-badge { background: var(--bg); padding: .15rem .5rem; border-radius: 4px; font-size: 11px; }
.katalog-actions { display: flex; gap: .5rem; }

/* ── Type Selector ────────────────────────────────────── */
.type-selector { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
.type-option input { display: none; }
.type-card { border: 2px solid var(--border); border-radius: 10px; padding: 1rem; text-align: center; cursor: pointer; transition: all .15s; }
.type-card i { font-size: 1.5rem; color: var(--text-3); display: block; margin-bottom: .5rem; }
.type-card strong { display: block; font-size: 13px; margin-bottom: .25rem; }
.type-card small { color: var(--text-2); font-size: 11px; }
.type-option input:checked + .type-card { border-color: var(--brand); background: #eff6ff; }
.type-option input:checked + .type-card i { color: var(--brand); }

/* ── Editor Layout ────────────────────────────────────── */
.editor-layout { display: grid; grid-template-columns: 280px 1fr; gap: 0; height: calc(100vh - var(--topbar-h) - 3rem); }
.editor-sidebar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius) 0 0 var(--radius); display: flex; flex-direction: column; overflow: hidden; }
.editor-sidebar-header { padding: .75rem 1rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.editor-sidebar-header h3 { font-size: 13.5px; font-weight: 600; }
.editor-sidebar-actions { display: flex; gap: .4rem; }
.drop-zone { margin: .75rem; border: 2px dashed var(--border); border-radius: var(--radius); padding: 1.25rem 1rem; text-align: center; cursor: pointer; color: var(--text-3); font-size: 13px; display: flex; flex-direction: column; align-items: center; gap: .5rem; transition: border-color .15s, background .15s; }
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--brand); background: #eff6ff; color: var(--brand); }
.drop-zone.uploading { background: #f0fdf4; }
.drop-zone i { font-size: 1.5rem; }
.pages-list { flex: 1; overflow-y: auto; padding: .5rem; display: flex; flex-direction: column; gap: .375rem; }
.page-thumb { display: grid; grid-template-columns: 24px 60px 1fr; gap: .5rem; align-items: center; padding: .5rem; border-radius: 6px; cursor: pointer; border: 1px solid transparent; transition: all .15s; }
.page-thumb:hover { background: var(--bg); border-color: var(--border); }
.page-thumb.active { background: #eff6ff; border-color: var(--brand); }
.thumb-number { font-size: 11px; color: var(--text-3); text-align: center; }
.thumb-preview { aspect-ratio: 3/4; border-radius: 4px; overflow: hidden; background: #f1f5f9; }
.thumb-preview img { width: 100%; height: 100%; object-fit: cover; }
.thumb-html { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--text-3); }
.thumb-actions { display: flex; flex-direction: column; gap: .25rem; }
.thumb-btn { background: none; border: 1px solid var(--border); border-radius: 4px; padding: .2rem .4rem; cursor: pointer; font-size: 11px; color: var(--text-2); }
.thumb-btn:hover { background: var(--bg); }
.thumb-btn-danger:hover { background: #fef2f2; color: #ef4444; border-color: #fca5a5; }

/* ── Editor Main ──────────────────────────────────────── */
.editor-main { border: 1px solid var(--border); border-left: none; border-radius: 0 var(--radius) var(--radius) 0; display: flex; flex-direction: column; background: var(--surface); overflow: hidden; }
.editor-toolbar { padding: .75rem 1rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.editor-title { display: flex; align-items: center; gap: .75rem; font-weight: 600; font-size: 14px; }
.editor-tools { display: flex; gap: .5rem; align-items: center; }
.editor-preview { flex: 1; overflow: auto; background: #64748b; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.preview-empty { display: flex; flex-direction: column; align-items: center; gap: .75rem; color: rgba(255,255,255,.6); text-align: center; }
.preview-empty i { font-size: 3rem; }
.preview-page { max-width: 500px; width: 100%; box-shadow: 0 8px 40px rgba(0,0,0,.4); }
.preview-page img { width: 100%; display: block; border-radius: 2px; }
.html-preview { min-height: 600px; }
.html-editor-panel { display: flex; flex-direction: column; border-top: 1px solid var(--border); }
.html-editor-header { padding: .75rem 1rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.html-editor-header h4 { font-weight: 600; }
.html-editor-tools { display: flex; align-items: center; gap: .75rem; font-size: 13px; }

/* ── Modal ────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal { background: var(--surface); border-radius: 12px; width: 480px; max-width: 95vw; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-header { padding: 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-3); font-size: 1rem; }
.modal-body { padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
.modal-footer { padding: 1.25rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .5rem; }

/* ── Responsive ───────────────────────────────────────── */
@media(max-width:900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .editor-layout { grid-template-columns: 1fr; height: auto; }
  .editor-sidebar { height: 300px; border-radius: var(--radius) var(--radius) 0 0; }
  .editor-main { border-left: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); }
  .form-row { grid-template-columns: 1fr; }
  .type-selector { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
