/* ============================================================
   PLEX PAYMENT TRACKER – Modern Dark UI
   ============================================================ */

:root {
  --bg:        #0d0f18;
  --surface:   #161927;
  --elevated:  #1e2235;
  --border:    rgba(255,255,255,0.08);
  --accent:    #e5a00d;
  --accent-d:  #c4880a;
  --success:   #22c55e;
  --danger:    #ef4444;
  --warning:   #f59e0b;
  --info:      #3b82f6;
  --text:      #f1f5f9;
  --muted:     #94a3b8;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow:    0 4px 24px rgba(0,0,0,0.4);
  --font:      'Inter', system-ui, -apple-system, sans-serif;
  --sidebar-w: 240px;
}

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

html { scroll-behavior: smooth; }

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

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

/* ── SIDEBAR ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.sidebar-logo .logo-mark svg { color: var(--accent); }
.sidebar-logo small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.sidebar-nav {
  padding: 12px 10px;
  flex: 1;
}
.nav-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  padding: 12px 10px 6px;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 500;
  transition: all 0.15s;
  margin-bottom: 2px;
  cursor: pointer;
  text-decoration: none;
}
.nav-item:hover { background: var(--elevated); color: var(--text); text-decoration: none; }
.nav-item.active { background: rgba(229,160,13,0.15); color: var(--accent); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}
.sidebar-footer strong { color: var(--text); }

/* ── MAIN CONTENT ──────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title {
  font-size: 16px;
  font-weight: 600;
}
.topbar-actions { display: flex; gap: 10px; align-items: center; }

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

/* ── BUTTONS ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { text-decoration: none; filter: brightness(1.1); }
.btn:active { transform: scale(0.97); }
.btn svg { width: 15px; height: 15px; }

/* ── GLOBAL SVG SIZE GUARD ─────────────────────────────────── */
/* Alle inline SVGs bekommen eine Standardgröße damit sie nicht unkontrolliert wachsen */
svg { max-width: 100%; height: auto; }
.card-title svg   { width: 16px; height: 16px; vertical-align: middle; flex-shrink: 0; }
.card-subtitle svg{ width: 14px; height: 14px; flex-shrink: 0; }
.sync-status svg  { width: 13px; height: 13px; flex-shrink: 0; }
.topbar svg       { width: 16px; height: 16px; }
td svg, th svg    { width: 14px; height: 14px; }
.alert svg        { width: 14px; height: 14px; flex-shrink: 0; }
.transaction-item svg { width: 14px; height: 14px; }

.btn-primary   { background: var(--accent);  color: #000; }
.btn-secondary { background: var(--elevated); color: var(--text); border: 1px solid var(--border); }
.btn-success   { background: var(--success);  color: #fff; }
.btn-danger    { background: var(--danger);   color: #fff; }
.btn-ghost     { background: transparent;     color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); background: var(--elevated); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 8px; }

/* ── CARDS ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── STAT CARDS ────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.accent   { background: rgba(229,160,13,0.15); color: var(--accent); }
.stat-icon.success  { background: rgba(34,197,94,0.15);  color: var(--success); }
.stat-icon.danger   { background: rgba(239,68,68,0.15);  color: var(--danger); }
.stat-icon.info     { background: rgba(59,130,246,0.15); color: var(--info); }
.stat-body {}
.stat-value { font-size: 26px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── TABLES ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--elevated); }
td { padding: 12px 14px; vertical-align: middle; }

/* ── BADGES ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success  { background: rgba(34,197,94,0.15);  color: #4ade80; }
.badge-danger   { background: rgba(239,68,68,0.15);  color: #f87171; }
.badge-warning  { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-info     { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-muted    { background: rgba(148,163,184,0.1); color: var(--muted); }
.badge-accent   { background: rgba(229,160,13,0.15); color: var(--accent); }

/* ── PAYMENT GRID ──────────────────────────────────────────── */
.payment-grid-wrap { overflow-x: auto; }
.payment-grid {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
}
.payment-grid th, .payment-grid td {
  padding: 8px 10px;
  border: 1px solid var(--border);
  text-align: center;
  white-space: nowrap;
}
.payment-grid th { background: var(--elevated); color: var(--muted); font-size: 11px; font-weight: 600; }
.payment-grid td.user-col { text-align: left; font-weight: 500; min-width: 160px; }
.pg-paid     { background: rgba(34,197,94,0.15);  color: #4ade80; font-weight: 700; border-radius: 6px; }
.pg-pending  { background: rgba(245,158,11,0.15); color: #fbbf24; font-weight: 700; border-radius: 6px; }
.pg-overdue  { background: rgba(239,68,68,0.15);  color: #f87171; font-weight: 700; border-radius: 6px; }
.pg-inactive { background: rgba(148,163,184,0.05); color: #475569; }
.pg-cell { display: inline-block; padding: 4px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; cursor: pointer; transition: filter 0.15s; }
.pg-cell:hover { filter: brightness(1.3); }

/* ── FORMS ─────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 12px; font-weight: 600; color: var(--muted); }
input, select, textarea {
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font);
  transition: border-color 0.15s;
  outline: none;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(229,160,13,0.15);
}
input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
}
.checkbox-row label { font-size: 13px; color: var(--text); font-weight: 500; cursor: pointer; margin: 0; }
textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11px; color: var(--muted); }

/* ── MODAL ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  transform: translateY(20px);
  transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── ALERTS ────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  border-left: 3px solid;
}
.alert-success { background: rgba(34,197,94,0.1);  border-color: var(--success); color: #4ade80; }
.alert-danger  { background: rgba(239,68,68,0.1);  border-color: var(--danger);  color: #f87171; }
.alert-info    { background: rgba(59,130,246,0.1); border-color: var(--info);    color: #60a5fa; }
.alert-warning { background: rgba(245,158,11,0.1); border-color: var(--warning); color: #fbbf24; }

/* ── LAYOUT UTILITIES ──────────────────────────────────────── */
.flex       { display: flex; }
.flex-col   { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.mb-5 { margin-bottom: 32px; }
.mt-3 { margin-top: 16px; }
.text-muted { color: var(--muted); }
.text-sm    { font-size: 12px; }
.text-right { text-align: right; }
.w-full     { width: 100%; }
.font-mono  { font-family: 'Courier New', monospace; font-size: 12px; }

/* ── AVATAR ────────────────────────────────────────────────── */
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #ff6b35);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #000;
  flex-shrink: 0;
}

/* ── PROGRESS BAR ──────────────────────────────────────────── */
.progress { background: var(--elevated); border-radius: 20px; height: 6px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 20px; background: var(--accent); transition: width 0.3s; }
.progress-bar.success { background: var(--success); }
.progress-bar.danger  { background: var(--danger);  }

/* ── TABS ──────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab-item {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
}
.tab-item:hover { color: var(--text); text-decoration: none; }
.tab-item.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── SEARCH ────────────────────────────────────────────────── */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}
.search-box svg {
  position: absolute;
  left: 10px;
  color: var(--muted);
  width: 15px;
  height: 15px;
}
.search-box input {
  padding-left: 34px;
  width: 240px;
}

/* ── PLEX STATUS DOT ───────────────────────────────────────── */
.plex-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}
.plex-dot.on  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.plex-dot.off { background: var(--muted); }
.plex-dot.err { background: var(--danger); }

/* ── TRANSACTION LIST ──────────────────────────────────────── */
.transaction-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.transaction-item:last-child { border-bottom: none; }
.transaction-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.amount-in  { color: var(--success); font-weight: 700; }
.amount-out { color: var(--danger);  font-weight: 700; }

/* ── SYNC STATUS ───────────────────────────────────────────── */
.sync-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── EMPTY STATE ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 16px; opacity: 0.3; }
.empty-state h3 { color: var(--text); margin-bottom: 8px; }

/* ── TOAST ─────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 13px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease;
  max-width: 360px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger);  }
.toast.info    { border-left: 3px solid var(--info);    }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(20px); } }

/* ── SETTINGS PAGE ─────────────────────────────────────────── */
.settings-section { margin-bottom: 32px; }
.settings-section h3 { font-size: 14px; font-weight: 600; margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }

/* ── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-w: 60px; }
  .nav-item span, .sidebar-logo small, .sidebar-logo .logo-text, .nav-label, .sidebar-footer { display: none; }
  .sidebar-logo { padding: 16px 12px; }
  .sidebar-logo .logo-mark { justify-content: center; }
  .page-content { padding: 20px; }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ── ARTICLE CARDS ─────────────────────────────────────────── */
.article-card {
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
}
.article-price {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
}
.article-price span { font-size: 14px; color: var(--muted); font-weight: 400; }

/* ── DELETE CONFIRM ────────────────────────────────────────── */
[data-confirm] { cursor: pointer; }
