/* css/app.css - HaushaltsProfi */
:root {
  --bg: #0f1117;
  --bg2: #1a1f2e;
  --bg3: #222840;
  --border: #2a3148;
  --text: #e0e6f0;
  --text-muted: #6b7fa3;
  --primary: #4f9cf9;
  --primary-dark: #3b82f6;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #06b6d4;
  --sidebar-w: 220px;
  --topbar-h: 56px;
  --radius: 10px;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Segoe UI', system-ui, sans-serif; font-size: 14px; background: var(--bg); color: var(--text); }
a { text-decoration: none; color: inherit; }

/* ─── SCROLLBAR ─────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── LOGIN PAGE ─────────────── */
#login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; position: relative; }
.login-bg { position: fixed; inset: 0; background: radial-gradient(ellipse at 30% 40%, #1e3a5f 0%, #0f1117 60%); z-index: 0; }
.login-card { position: relative; z-index: 1; width: 100%; max-width: 400px; background: var(--bg2); border: 1px solid var(--border); border-radius: 16px; padding: 40px; box-shadow: var(--shadow); }
.login-logo { text-align: center; margin-bottom: 32px; }
.login-icon { font-size: 3rem; display: block; margin-bottom: 12px; }
.login-logo h1 { font-size: 1.6rem; font-weight: 700; color: var(--primary); }
.login-logo p { color: var(--text-muted); font-size: 0.88rem; margin-top: 4px; }

/* ─── APP LAYOUT ─────────────── */
#app { display: flex; height: 100vh; overflow: hidden; }

/* ─── SIDEBAR ─────────────────── */
#sidebar { width: var(--sidebar-w); background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; transition: width 0.3s; z-index: 100; }
.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 0 20px; height: var(--topbar-h); border-bottom: 1px solid var(--border); font-size: 1.1rem; font-weight: 700; color: var(--primary); }
.logo-text { white-space: nowrap; overflow: hidden; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 20px; cursor: pointer; border-radius: 0; transition: background 0.15s, color 0.15s; white-space: nowrap; overflow: hidden; }
.nav-item:hover { background: var(--bg3); }
.nav-item.active { background: rgba(79,156,249,0.15); color: var(--primary); border-right: 3px solid var(--primary); }
.nav-icon { font-size: 1.1rem; flex-shrink: 0; width: 22px; text-align: center; }
.nav-label { font-size: 0.9rem; }
.sidebar-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; flex-shrink: 0; }
.user-name { flex: 1; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-btn { color: var(--text-muted); font-size: 1.1rem; cursor: pointer; padding: 4px; border-radius: 4px; transition: color 0.2s; }
.logout-btn:hover { color: var(--danger); }

/* ─── MAIN CONTENT ───────────── */
#main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#topbar { height: var(--topbar-h); display: flex; align-items: center; gap: 14px; padding: 0 24px; border-bottom: 1px solid var(--border); background: var(--bg2); flex-shrink: 0; }
#menu-toggle { background: none; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; padding: 4px; display: none; }
#topbar-title { font-size: 1rem; font-weight: 600; flex: 1; }
#topbar-actions { display: flex; gap: 8px; }
#view-container { flex: 1; overflow-y: auto; padding: 24px; }

/* ─── VIEW HEADER ────────────── */
.view-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.view-header h2 { font-size: 1.3rem; font-weight: 700; }

/* ─── CARDS / GRID ───────────── */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card-title { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ─── STAT CARDS ─────────────── */
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.stat-label { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 1.6rem; font-weight: 700; margin: 6px 0 2px; }
.stat-sub { font-size: 0.8rem; color: var(--text-muted); }
.stat-green { color: var(--success); }
.stat-red { color: var(--danger); }
.stat-blue { color: var(--primary); }
.stat-yellow { color: var(--warning); }

/* ─── TABLES ─────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 14px; font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--border); font-weight: 600; }
td { padding: 11px 14px; border-bottom: 1px solid rgba(42,49,72,0.5); font-size: 0.9rem; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }
.amount-pos { color: var(--success); font-weight: 600; }
.amount-neg { color: var(--danger); font-weight: 600; }
.amount-neu { color: var(--info); font-weight: 600; }

/* ─── FORMS ──────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.82rem; color: var(--text-muted); margin-bottom: 6px; font-weight: 500; }
.form-control { width: 100%; padding: 9px 13px; background: var(--bg); border: 1px solid var(--border); border-radius: 7px; color: var(--text); font-size: 0.92rem; transition: border-color 0.2s; }
.form-control:focus { outline: none; border-color: var(--primary); }
select.form-control option { background: var(--bg2); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ─── BUTTONS ────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: none; border-radius: 7px; font-size: 0.9rem; font-weight: 500; cursor: pointer; transition: all 0.15s; white-space: nowrap; }
.btn-sm { padding: 5px 11px; font-size: 0.82rem; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #16a34a; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { background: transparent; border: none; color: var(--text-muted); cursor: pointer; padding: 5px 7px; border-radius: 5px; transition: all 0.15s; font-size: 1rem; }
.btn-icon:hover { color: var(--text); background: var(--bg3); }

/* ─── BADGES ─────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; }
.badge-success { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-info { background: rgba(6,182,212,0.15); color: var(--info); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }

/* ─── ALERTS ─────────────────── */
.alert { padding: 10px 14px; border-radius: 7px; font-size: 0.88rem; margin-bottom: 14px; }
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); color: #86efac; }

/* ─── PROGRESS BARS ──────────── */
.progress { height: 8px; background: var(--bg3); border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 4px; transition: width 0.6s ease; }
.progress-over { background: var(--danger) !important; }

/* ─── MODAL ──────────────────── */
#modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.65); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
#modal-overlay.hidden { display: none; }
#modal-box { background: var(--bg2); border: 1px solid var(--border); border-radius: 14px; width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow); }
#modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
#modal-title { font-size: 1rem; font-weight: 600; }
#modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.1rem; cursor: pointer; padding: 4px 8px; border-radius: 4px; }
#modal-close:hover { background: var(--bg3); color: var(--text); }
#modal-body { padding: 22px; }

/* ─── TOAST ──────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--bg2); border: 1px solid var(--border); border-radius: 9px; padding: 12px 18px; font-size: 0.9rem; box-shadow: var(--shadow); animation: slideIn 0.3s ease; min-width: 220px; }
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-info { border-left: 3px solid var(--primary); }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── CHARTS (canvas) ─────────── */
.chart-container { position: relative; height: 220px; }

/* ─── MISC ───────────────────── */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.color-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.konto-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 20px; font-size: 0.8rem; background: var(--bg3); }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.9rem; }
.pagination { display: flex; align-items: center; gap: 8px; margin-top: 16px; justify-content: flex-end; }
.page-btn { padding: 5px 11px; border-radius: 5px; border: 1px solid var(--border); background: var(--bg2); color: var(--text); cursor: pointer; font-size: 0.85rem; }
.page-btn:hover { background: var(--bg3); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar .form-control { width: auto; min-width: 120px; }
.typ-einnahme { color: var(--success); }
.typ-ausgabe { color: var(--danger); }
.typ-umbuchung { color: var(--info); }
.sidebar-collapsed { width: 60px !important; }
.sidebar-collapsed .logo-text,
.sidebar-collapsed .nav-label,
.sidebar-collapsed .user-name { display: none; }
.sidebar-collapsed .nav-item { justify-content: center; padding: 10px 0; }
.sidebar-collapsed .sidebar-footer { padding: 14px 0; justify-content: center; }
.sidebar-collapsed .logout-btn { display: none; }

/* ─── RESPONSIVE ─────────────── */
@media (max-width: 900px) {
  #menu-toggle { display: block; }
  #sidebar { position: fixed; left: -240px; top: 0; height: 100%; transition: left 0.3s; box-shadow: var(--shadow); }
  #sidebar.open { left: 0; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  #view-container { padding: 16px; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}
