/* ============================================================
   GeoCMS Backend – Stylesheet
   ============================================================ */

:root {
  --bg:        #f1f5f9;
  --surface:   #ffffff;
  --sidebar:   #1e293b;
  --sidebar-hover: #334155;
  --sidebar-active: #2563eb;
  --primary:   #2563eb;
  --primary-h: #1d4ed8;
  --danger:    #dc2626;
  --warning:   #d97706;
  --success:   #16a34a;
  --text:      #1e293b;
  --muted:     #64748b;
  --border:    #e2e8f0;
  --radius:    6px;
  --shadow:    0 1px 4px rgba(0,0,0,.08);
  --sidebar-w: 220px;
  --header-h:  52px;
  --font:      'Inter', system-ui, sans-serif;
}

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

html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

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

/* ── Layout ─────────────────────────────────────────────────── */

.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 18px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
  letter-spacing: .3px;
}
.sidebar-logo span { color: var(--primary); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 0; }

.nav-group-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #475569;
  padding: 14px 18px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  color: #94a3b8;
  cursor: pointer;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(37,99,235,.18); color: #fff;
  border-left-color: var(--sidebar-active); }
.nav-item .icon { width: 16px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 12px 18px;
  font-size: 12px;
  color: #64748b;
}
.sidebar-footer a { color: #94a3b8; }

/* Main area */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 90;
  box-shadow: var(--shadow);
}

.topbar-title { font-size: 16px; font-weight: 600; }

.topbar-right { display: flex; align-items: center; gap: 14px; }

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.role-badge {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 1px 9px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.role-badge.admin  { background: #fef3c7; border-color: #fbbf24; color: #92400e; }
.role-badge.editor { background: #dbeafe; border-color: #93c5fd; color: #1e40af; }
.role-badge.viewer { background: #f1f5f9; border-color: #cbd5e1; color: #475569; }

.page-content { padding: 24px; flex: 1; }

/* ── Typographie ─────────────────────────────────────────────── */

h1 { font-size: 22px; font-weight: 700; margin: 0 0 20px; }
h2 { font-size: 17px; font-weight: 600; margin: 0 0 14px; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 10px; }

/* ── Karten / Panels ─────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body { padding: 18px; }

/* ── Tabellen ────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 9px 12px;
  background: var(--bg);
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  white-space: nowrap;
}
.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f8fafc; }

/* ── Formulare ───────────────────────────────────────────────── */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-full { grid-column: 1 / -1; }

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--muted); }
.form-group label .req { color: var(--danger); margin-left: 2px; }

input[type=text], input[type=email], input[type=url], input[type=number],
input[type=password], input[type=search], select, textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
textarea { resize: vertical; min-height: 80px; }

.toggle-wrap { display: flex; align-items: center; gap: 8px; }
.toggle-wrap label { font-size: 13px; font-weight: normal; color: var(--text); }

input[type=color] {
  width: 44px; height: 32px; padding: 2px;
  border-radius: var(--radius); cursor: pointer;
}

.color-row { display: flex; align-items: center; gap: 8px; }
.color-row input[type=text] { flex: 1; }

/* ── Buttons ─────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, box-shadow .15s;
  white-space: nowrap;
  font-family: inherit;
}
.btn:hover { text-decoration: none; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-h); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--bg); }
.btn-success  { background: var(--success); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 5px 7px; }
.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Flash-Nachrichten ───────────────────────────────────────── */

.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
}
.flash-success { background: #dcfce7; border: 1px solid #86efac; color: #166534; }
.flash-error   { background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; }
.flash-warning { background: #fef9c3; border: 1px solid #fde047; color: #854d0e; }
.flash-info    { background: #dbeafe; border: 1px solid #93c5fd; color: #1e40af; }

/* ── Badges / Tags ───────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
}
.badge-blue   { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.badge-green  { background: #dcfce7; color: #166534; border-color: #86efac; }
.badge-red    { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.badge-yellow { background: #fef9c3; color: #854d0e; border-color: #fde047; }

/* ── Tabs ────────────────────────────────────────────────────── */

.tabs { border-bottom: 2px solid var(--border); display: flex; gap: 0; margin-bottom: 20px; }
.tab-btn {
  padding: 9px 18px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Karten-Editor ───────────────────────────────────────────── */

#map-editor {
  width: 100%; height: 450px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* ── Icon-Picker ─────────────────────────────────────────────── */

.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
}
.icon-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 6px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 11px;
  text-align: center;
  transition: border-color .15s;
}
.icon-item:hover { border-color: var(--primary); }
.icon-item.selected { border-color: var(--primary); background: #eff6ff; }
.icon-item img { width: 32px; height: 32px; object-fit: contain; }

/* ── Stil-Vorschau ───────────────────────────────────────────── */

.style-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--bg);
  border-radius: var(--radius);
}
.style-preview svg { flex-shrink: 0; }

/* ── Panorama-Hinweis ────────────────────────────────────────── */

.pano-hint {
  padding: 10px 14px;
  background: #f0fdf4;
  border: 1px dashed #86efac;
  border-radius: var(--radius);
  font-size: 12px;
  color: #166534;
}

/* ── Media-Galerie im Backend ────────────────────────────────── */

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.media-item {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.media-item img { width: 100%; height: 110px; object-fit: cover; display: block; flex-shrink: 0; }
.media-item-body {
  padding: 6px 8px 4px;
  flex: 1;
  min-width: 0;
}
.media-item-info {
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-type-badge {
  display: inline-block;
  background: var(--border);
  color: var(--muted);
  font-size: 9px; padding: 1px 5px;
  border-radius: 3px; font-weight: 700;
  margin-top: 2px;
}
.media-item-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.media-item-actions button {
  flex: 1;
  padding: 3px 0;
  font-size: 13px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.media-item-actions button:hover { background: var(--border); color: var(--text); }
.media-item-actions .btn-del:hover { background: #fee2e2; color: #dc2626; }
.media-item-del {
  /* Legacy — wird durch .media-item-actions ersetzt */
  display: none;
}

/* ── GUID-Box ────────────────────────────────────────────────── */

.guid-box {
  font-family: monospace;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  word-break: break-all;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* ── Embed-Code-Box ──────────────────────────────────────────── */

.code-box {
  background: #1e293b;
  color: #e2e8f0;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: monospace;
  font-size: 12px;
  overflow-x: auto;
  white-space: pre;
}

/* ── Login ───────────────────────────────────────────────────── */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sidebar);
}
.login-card {
  width: 360px;
  background: var(--surface);
  border-radius: 10px;
  padding: 36px;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
}
.login-logo {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 28px;
}
.login-logo span { color: var(--primary); }

/* ── Drag-Handle ─────────────────────────────────────────────── */

[data-sortable] .drag-handle {
  cursor: grab;
  color: var(--muted);
  padding: 0 6px;
}

/* ── Responsive ──────────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .form-grid.cols-2, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: auto; }
}