/* ═══════════════════════════════════════════════════════════════════
   Rechnungsprogramm – Stylesheet
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --primary:     #1e3a5f;
  --accent:      #2563eb;
  --purple:      #7c3aed;
  --purple-light:#f5f3ff;
  --sidebar-w:   240px;
  --sidebar-bg:  #1e3a5f;
  --bg:          #f1f5f9;
  --card-radius: 12px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  margin: 0;
  color: #1e293b;
  font-size: 14px;
}

/* ── Login ── */
.login-page { background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%); }
.login-card  { width: 420px; border-radius: var(--card-radius); border: none; }
.login-icon  { font-size: 3rem; }

/* ── Mobile Top Bar ── */
.mobile-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 98;
  background: var(--sidebar-bg);
  padding: 10px 16px;
  align-items: center;
  gap: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.btn-hamburger {
  background: none;
  border: none;
  color: rgba(255,255,255,.85);
  font-size: 24px;
  padding: 0;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.mobile-topbar-title {
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  flex: 1;
}

/* ── Sidebar Backdrop ── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 149;
}
.sidebar-backdrop.show { display: block; }

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  z-index: 150;
  overflow-y: auto;
  transition: transform .25s ease;
}
.sidebar-header { border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-title  { font-size: 15px; letter-spacing: .5px; }

.sidebar-link {
  color: rgba(255,255,255,.7) !important;
  border-radius: 8px !important;
  padding: 9px 12px !important;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  transition: all .15s;
  text-decoration: none;
}
.sidebar-link:hover { background: rgba(255,255,255,.08) !important; color: #fff !important; }
.sidebar-link.active { background: var(--accent) !important; color: #fff !important; }
.sidebar-link i { font-size: 16px; width: 20px; text-align: center; }

.avatar-circle {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 13px;
}

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 28px 32px;
}

.page-header { margin-bottom: 24px; }
.page-title  { font-size: 22px; font-weight: 700; color: var(--primary); margin: 0; }

/* ── Stats Cards ── */
.stat-card {
  border-radius: var(--card-radius);
  padding: 20px;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 80px; height: 80px;
  background: rgba(255,255,255,.1);
  border-radius: 50%;
}
.stat-blue   { background: linear-gradient(135deg, #2563eb, #3b82f6); }
.stat-green  { background: linear-gradient(135deg, #16a34a, #22c55e); }
.stat-orange { background: linear-gradient(135deg, #d97706, #f59e0b); }
.stat-red    { background: linear-gradient(135deg, #dc2626, #ef4444); }
.stat-purple { background: linear-gradient(135deg, #7c3aed, #a78bfa); }

.stat-icon  { font-size: 22px; opacity: .9; margin-bottom: 8px; }
.stat-value { font-size: 24px; font-weight: 700; margin-bottom: 2px; }
.stat-label { font-size: 12px; opacity: .85; }

/* ── Cards ── */
.card { border-radius: var(--card-radius); border: 1px solid #e2e8f0; }
.card-header { background: transparent; border-bottom: 1px solid #f1f5f9; font-size: 15px; }

/* ── Tables ── */
.table th { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: #64748b; }
.table td { font-size: 13px; vertical-align: middle; }

/* ── Status Badges ── */
.badge-draft    { background: #e2e8f0; color: #475569; }
.badge-sent     { background: #dbeafe; color: #1d4ed8; }
.badge-paid     { background: #dcfce7; color: #15803d; }
.badge-overdue  { background: #fee2e2; color: #b91c1c; }
.badge-cancelled{ background: #f1f5f9; color: #94a3b8; }

/* ── Purple Helpers ── */
.text-purple    { color: var(--purple) !important; }
.bg-purple      { background: var(--purple) !important; }
.bg-purple-light{ background: var(--purple-light) !important; }
.border-purple  { border-color: #ddd6fe !important; }
.btn-outline-purple {
  color: var(--purple);
  border-color: var(--purple);
}
.btn-outline-purple:hover {
  background: var(--purple);
  color: #fff;
}

/* ── Invoice Items Table ── */
#itemsTable { font-size: 13px; }
#itemsTable input { font-size: 13px; }
#itemsTable textarea { font-size: 13px; min-height: 56px; resize: vertical; }

/* ── AI Cost Preview ── */
.ai-cost-preview { border-radius: 8px; }

/* ── Action Buttons ── */
.action-btn { padding: 3px 8px; font-size: 12px; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ── Toast ── */
.toast { min-width: 280px; }
.toast.bg-success { --bs-toast-bg: #16a34a; color: #fff; }
.toast.bg-danger  { --bs-toast-bg: #dc2626; color: #fff; }

/* ── Modals ── */
.modal-content { border-radius: var(--card-radius); border: none; box-shadow: 0 25px 50px rgba(0,0,0,.15); }
.modal-xl { max-width: 1000px; }

/* ── Filter Buttons ── */
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }


/* ════════════════════════════════════════════════════════════════════
   RESPONSIVE  –  Mobile
   ════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── Show hamburger bar ── */
  .mobile-topbar { display: flex; }

  /* ── Sidebar slides in from left ── */
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }

  /* ── Main content: no left margin, tighter padding ── */
  .main-content {
    margin-left: 0;
    padding: 16px;
  }

  /* ── Page headers: wrap on small screens ── */
  .page-header {
    flex-wrap: wrap !important;
    gap: 10px;
  }
  .page-header > button {
    width: 100%;
  }
  .page-title { font-size: 18px; }

  /* ── Stats ── */
  .stat-value { font-size: 20px; }
  .stat-card  { padding: 14px 16px; }
  .stat-icon  { font-size: 18px; margin-bottom: 4px; }

  /* ── Tables: horizontal scroll + smaller font ── */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table th, .table td { font-size: 12px; }

  /* ── Card padding: tighter on mobile ── */
  .card-body.px-4 { padding-left: 16px !important; padding-right: 16px !important; }
  .card-header.px-4 { padding-left: 16px !important; padding-right: 16px !important; }

  /* ── Modals: full width, scrollable ── */
  .modal-dialog {
    margin: 8px auto !important;
    max-width: calc(100% - 16px) !important;
  }
  .modal-xl,
  .modal-lg {
    max-width: calc(100% - 16px) !important;
  }
  .modal-content {
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
  }
  .modal-body { padding: 16px !important; }
  .modal-header { padding: 12px 16px !important; }
  .modal-footer { padding: 10px 16px !important; }

  /* ── Invoice modal: make date/tax row stack nicely ── */
  #invoiceModal .col-md-2,
  #invoiceModal .col-md-3,
  #invoiceModal .col-md-4,
  #invoiceModal .col-md-6 {
    width: 50%;
  }
  #invoiceModal .col-md-2:last-of-type { width: 100%; }

  /* ── Items table: allow scroll ── */
  #itemsTable { min-width: 560px; }

  /* ── Filter bar: wrap ── */
  .filter-btn { font-size: 11px; padding: 3px 8px; }

  /* ── Button groups in tables ── */
  .btn-group-sm .btn { padding: 2px 5px; font-size: 11px; }
  .action-btn { padding: 2px 6px; font-size: 11px; }

  /* ── Login card ── */
  .login-card {
    width: calc(100% - 32px) !important;
    padding: 28px 20px !important;
  }

  /* ── Dropdown menus full width ── */
  .dropdown-menu { min-width: 180px !important; }

  /* ── AI cost preview: stack on mobile ── */
  .ai-cost-preview .row > .col-4 { margin-bottom: 4px; }

  /* ── Settings: hide second column items stack naturally ── */
  .row.g-4 > [class*="col-lg"] { width: 100%; }

  /* ── Hide low-priority table columns on mobile ── */
  .col-hide-mobile { display: none; }
}

@media (max-width: 400px) {
  .main-content { padding: 10px; }
  .stat-value { font-size: 18px; }
  #invoiceModal .col-md-2,
  #invoiceModal .col-md-3 { width: 100%; }
}
