/* ============================================================
   EAB – main.css  |  Layout, Custom Properties, Navigation
   ============================================================ */

:root {
  /* Farben */
  --c-primary:        #2563eb;
  --c-primary-dark:   #1d4ed8;
  --c-primary-light:  #dbeafe;
  --c-income:         #16a34a;
  --c-expense:        #dc2626;
  --c-warning:        #d97706;

  /* Graustufen */
  --c-sidebar:        #1e293b;
  --c-sidebar-hover:  #334155;
  --c-sidebar-active: #2563eb;
  --c-bg:             #f8fafc;
  --c-surface:        #ffffff;
  --c-border:         #e2e8f0;
  --c-border-focus:   #93c5fd;
  --c-text:           #0f172a;
  --c-text-muted:     #64748b;
  --c-text-light:     #94a3b8;

  /* Abstände */
  --sidebar-width:    260px;
  --header-height:    60px;
  --space-xs:         0.25rem;
  --space-sm:         0.5rem;
  --space-md:         1rem;
  --space-lg:         1.5rem;
  --space-xl:         2rem;

  /* Sonstiges */
  --radius-sm:  4px;
  --radius:     8px;
  --radius-lg:  12px;
  --shadow-sm:  0 1px 2px rgba(0,0,0,.05);
  --shadow:     0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg:  0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --transition: 150ms ease;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.5;
  min-height: 100dvh;
}
a  { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font: inherit; border: none; background: none; }

/* ── App-Layout ─────────────────────────────────────────── */
#app {
  display: flex;
  min-height: 100dvh;
}

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--c-sidebar);
  color: #f1f5f9;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset-block: 0;
  left: 0;
  z-index: 200;
  transition: transform var(--transition);
  overflow-y: auto;
}

.sidebar[hidden] { display: none; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) var(--space-md);
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.sidebar-logo-icon {
  width: 36px;
  height: 36px;
  background: var(--c-primary);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: .03em;
}

.sidebar-close {
  color: var(--c-text-light);
  display: none;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-md) var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: .6rem var(--space-sm);
  border-radius: var(--radius);
  color: #cbd5e1;
  font-size: .9375rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  user-select: none;
}

.nav-item:hover {
  background: var(--c-sidebar-hover);
  color: #f1f5f9;
  text-decoration: none;
}

.nav-item.active {
  background: var(--c-sidebar-active);
  color: #fff;
}

.nav-item-icon {
  font-size: 1.1rem;
  width: 1.5rem;
  text-align: center;
  flex-shrink: 0;
}

.nav-section-label {
  font-size: .6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #475569;
  padding: var(--space-md) var(--space-sm) var(--space-xs);
}

.sidebar-footer {
  padding: var(--space-md);
  border-top: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: .875rem;
  color: #94a3b8;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Overlay (mobile) ────────────────────────────────────── */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 199;
}
.sidebar-overlay[hidden] { display: none; }

/* ── App-Shell (rechter Bereich) ─────────────────────────── */
.app-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-left: var(--sidebar-width);
  min-width: 0;
}

/* ── App-Header ─────────────────────────────────────────── */
.app-header {
  height: var(--header-height);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 0 var(--space-lg);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.app-header[hidden] { display: none; }

#menu-toggle {
  display: none;
  color: var(--c-text-muted);
}

.page-title {
  font-size: 1.125rem;
  font-weight: 600;
  flex: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.header-user {
  font-size: .875rem;
  color: var(--c-text-muted);
  font-weight: 500;
}

/* ── Main Content ───────────────────────────────────────── */
.app-main {
  flex: 1;
  padding: var(--space-xl);
  min-height: calc(100dvh - var(--header-height));
}

/* ── Loading Screen ─────────────────────────────────────── */
.loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.loading-screen[hidden] { display: none; }

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--c-border);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Icon Button ────────────────────────────────────────── */
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  color: var(--c-text-muted);
  transition: background var(--transition);
  font-size: 1.1rem;
}

.icon-btn:hover { background: var(--c-bg); }

/* ── Toast Container ────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

/* ── Responsive: Mobile ─────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    display: flex;
  }

  .sidebar[hidden] {
    display: flex;
    transform: translateX(-100%);
  }

  .sidebar-close { display: grid; }

  .app-shell { margin-left: 0; }

  #menu-toggle { display: grid; }

  .app-main { padding: var(--space-md); }

  .header-user { display: none; }
}
