/* ═══════════════════════════════════════════════════════
   Gashi Lingua – Rechnungs-App
   ═══════════════════════════════════════════════════════ */

:root {
  --rot:        #c0392b;
  --rot-dunkel: #a93226;
  --dunkel:     #1a2332;
  --dunkel2:    #243044;
  --text:       #2c3e50;
  --text-hell:  #7f8c8d;
  --bg:         #f0f2f5;
  --card:       #ffffff;
  --border:     #e0e0e0;
  --gruen:      #27ae60;
  --orange:     #e67e22;
  --blau:       #2980b9;
  --sidebar-w:  240px;
  --header-h:   56px;
  --radius:     8px;
  --shadow:     0 2px 8px rgba(0,0,0,0.08);
}

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

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

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

/* ── Sidebar ───────────────────────────────────────────── */

.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--dunkel);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo .brand {
  font-size: 18px;
  font-weight: 700;
  color: white;
  letter-spacing: 0.3px;
}

.sidebar-logo .brand span {
  color: var(--rot);
}

.sidebar-logo .sub {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  margin-top: 2px;
}

.sidebar nav {
  flex: 1;
  padding: 12px 0;
}

.nav-section {
  padding: 8px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.3);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.7);
  font-size: 13.5px;
  cursor: pointer;
  transition: all 0.15s;
  border-left: 3px solid transparent;
  text-decoration: none;
}

.nav-item:hover {
  background: rgba(255,255,255,0.07);
  color: white;
  text-decoration: none;
}

.nav-item.active {
  background: rgba(192,57,43,0.18);
  color: white;
  border-left-color: var(--rot);
  font-weight: 600;
}

.nav-item .icon {
  width: 18px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.btn-logout {
  width: 100%;
  padding: 8px 12px;
  background: rgba(192,57,43,0.2);
  color: rgba(255,255,255,0.8);
  border: 1px solid rgba(192,57,43,0.3);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}

.btn-logout:hover {
  background: var(--rot);
  color: white;
}

/* ── Hauptbereich ─────────────────────────────────────── */

.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--header-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h1 {
  font-size: 18px;
  font-weight: 600;
  flex: 1;
}

.content {
  padding: 28px;
  flex: 1;
}

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

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Stat-Karten ──────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-left: 4px solid var(--border);
}

.stat-card.rot     { border-left-color: var(--rot); }
.stat-card.gruen   { border-left-color: var(--gruen); }
.stat-card.orange  { border-left-color: var(--orange); }
.stat-card.blau    { border-left-color: var(--blau); }
.stat-card.dunkel  { border-left-color: var(--dunkel); }

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-hell);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-hell);
}

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

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  background: var(--bg);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-hell);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:hover {
  background: #fafafa;
}

tbody td {
  padding: 10px 12px;
  vertical-align: middle;
}

.td-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--rot);
  color: white;
}
.btn-primary:hover { background: var(--rot-dunkel); color: white; }

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-success {
  background: var(--gruen);
  color: white;
}
.btn-success:hover { background: #229954; }

.btn-icon {
  padding: 6px 10px;
  background: transparent;
  color: var(--text-hell);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}

.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-icon.danger:hover { background: #fde8e8; color: var(--rot); border-color: var(--rot); }
.btn-icon.success:hover { background: #e8f8ef; color: var(--gruen); border-color: var(--gruen); }
.btn-icon.primary:hover { background: #fde8e6; color: var(--rot); border-color: var(--rot); }

.btn-sm {
  padding: 5px 10px;
  font-size: 12.5px;
}

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

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-hell);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--text);
  background: white;
  transition: border-color 0.15s;
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--rot);
  box-shadow: 0 0 0 3px rgba(192,57,43,0.1);
}

.form-row {
  display: grid;
  gap: 16px;
}

.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* ── Badges / Status ──────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-entwurf    { background: #eef2f7; color: #5d6d7e; }
.badge-gesendet   { background: #e8f4fd; color: var(--blau); }
.badge-bezahlt    { background: #e8f8ef; color: var(--gruen); }
.badge-storniert  { background: #fde8e8; color: var(--rot); }
.badge-gemahnt    { background: #fef5e7; color: var(--orange); }
.badge-angenommen { background: #e8f8ef; color: var(--gruen); }
.badge-abgelehnt  { background: #fde8e8; color: var(--rot); }
.badge-abgelaufen { background: #f4f4f4; color: #999; }

/* ── Modal ────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: white;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal.modal-lg { max-width: 900px; }
.modal.modal-xl { max-width: 1100px; }

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-hell);
  line-height: 1;
  padding: 4px;
  border-radius: 4px;
}
.modal-close:hover { background: var(--bg); }

.modal-body {
  padding: 24px;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  position: sticky;
  bottom: 0;
  background: white;
}

/* ── Positionstabelle (Rechnungen/Angebote) ──────────── */

.pos-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 8px;
  font-size: 13px;
}

.pos-table th {
  background: var(--dunkel);
  color: white;
  padding: 8px 10px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
}

.pos-table td {
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.pos-table td input,
.pos-table td select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
}

.pos-table td input:focus,
.pos-table td select:focus {
  outline: none;
  border-color: var(--rot);
}

.pos-gesamt-block {
  text-align: right;
  padding: 12px 0;
}

.pos-summe-zeile {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 16px;
  padding: 4px 0;
  font-size: 13.5px;
}

.pos-summe-zeile.total {
  font-size: 16px;
  font-weight: 700;
  padding-top: 8px;
  border-top: 2px solid var(--dunkel);
  margin-top: 4px;
}

/* ── Toolbar / Filter ─────────────────────────────────── */

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar .search-box {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}

.search-input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13.5px;
  background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 10px center;
}

.search-input:focus {
  outline: none;
  border-color: var(--rot);
}

.filter-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13.5px;
  background: white;
  color: var(--text);
}

/* ── Alerts ───────────────────────────────────────────── */

.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13.5px;
}

.alert-success { background: #e8f8ef; color: #1e8449; border: 1px solid #a9dfbf; }
.alert-error   { background: #fde8e8; color: #a93226; border: 1px solid #f5b7b1; }
.alert-info    { background: #e8f4fd; color: #1a5276; border: 1px solid #aed6f1; }
.alert.hidden  { display: none; }

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

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--dunkel) 0%, var(--dunkel2) 100%);
}

.login-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  padding: 40px 40px 36px;
  width: 100%;
  max-width: 380px;
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo .brand-big {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
}

.login-logo .brand-big span {
  color: var(--rot);
}

.login-logo .sub {
  font-size: 12px;
  color: var(--text-hell);
  margin-top: 4px;
}

/* ── Leere Zustände ───────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-hell);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 16px;
}

/* ── Ladereifen ───────────────────────────────────────── */

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(192,57,43,0.2);
  border-top-color: var(--rot);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ── Toast ────────────────────────────────────────────── */

#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  z-index: 9999;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.25s;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

#toast.success { background: var(--gruen); color: white; }
#toast.error   { background: var(--rot); color: white; }
#toast.info    { background: var(--blau); color: white; }

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

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