/* ============================================
   BillFact - Facturatie & Klantenbeheer
   ============================================ */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --sidebar-w: 240px;
  --radius: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
}

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--gray-900);
  color: #fff;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--gray-700);
}

.sidebar-logo {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}
.sidebar-logo span { color: var(--primary); }

.sidebar-menu {
  list-style: none;
  flex: 1;
  padding: 0.5rem 0;
  overflow-y: auto;
}

.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.5rem;
  color: var(--gray-400);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}
.sidebar-menu a:hover {
  color: #fff;
  background: var(--gray-800);
}
.sidebar-menu a.active {
  color: #fff;
  background: var(--gray-800);
  border-left-color: var(--primary);
}
.sidebar-menu svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--gray-700);
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--gray-400);
}
.sidebar-footer a { color: var(--gray-400); text-decoration: none; }
.sidebar-footer a:hover { color: #fff; }

/* ---- HAMBURGER ---- */
.hamburger {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  background: var(--gray-900);
  color: #fff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  font-size: 1.2rem;
  cursor: pointer;
}

/* ---- CONTENT ---- */
.content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 2rem;
  max-width: 1200px;
  width: 100%;
}
.content-full {
  margin-left: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ---- PAGE HEADER ---- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
}
.page-actions { display: flex; gap: 0.5rem; }

/* ---- ALERTS ---- */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* ---- CARDS ---- */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 1.5rem;
  overflow: hidden;
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-header h3 { font-size: 1rem; font-weight: 600; }
.card-warning { border-left: 4px solid var(--danger); }

.card form, .card .detail-list, .card .detail-notes, .card p {
  padding: 1.25rem;
}

/* ---- STATS ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: #fff;
  padding: 1.25rem;
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.stat-label {
  font-size: 0.8rem;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}
.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
}
.stat-value.warn { color: var(--warning); }
.stat-sub { font-size: 0.8rem; color: var(--gray-500); margin-top: 0.25rem; }

/* ---- TABLE ---- */
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th, .table td {
  padding: 0.65rem 1rem;
  text-align: left;
  font-size: 0.875rem;
}
.table thead th {
  background: var(--gray-50);
  color: var(--gray-600);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--gray-200);
}
.table tbody tr { border-bottom: 1px solid var(--gray-100); }
.table tbody tr:hover { background: var(--gray-50); }
.table a { color: #000; text-decoration: none; }
.table a.btn-primary { color: #fff; }
.table a:hover { text-decoration: underline; }
td.empty { text-align: center; color: var(--gray-400); padding: 2rem; }

/* ---- BADGES ---- */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-gray { background: var(--gray-200); color: var(--gray-600); }
[data-status="concept"] { background: var(--gray-200); color: var(--gray-600); }
[data-status="verzonden"] { background: var(--primary-light); color: var(--primary-dark); }
[data-status="betaald"] { background: #d1fae5; color: #065f46; }
[data-status="verlopen"] { background: #fee2e2; color: #991b1b; }
[data-status="geannuleerd"] { background: var(--gray-200); color: var(--gray-500); }
[data-status="deels_betaald"] { background: #fef3c7; color: #92400e; }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: #fff;
  color: var(--gray-700);
  font-size: 0.875rem;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.78rem; }
.btn-full { width: 100%; justify-content: center; }

/* ---- FORMS ---- */
.input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: #fff;
  color: var(--gray-800);
  transition: border-color 0.2s;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
textarea.input { resize: vertical; }
select.input { cursor: pointer; }

.form-group {
  margin-bottom: 1rem;
  flex: 1;
  min-width: 150px;
}
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 0.3rem;
}
.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* ---- FILTER BAR ---- */
.filter-bar {
  margin-bottom: 1rem;
}
.filter-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.filter-form .input { max-width: 300px; }
.filter-form select.input { max-width: 180px; }

/* ---- DETAIL ---- */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.detail-list { display: flex; flex-direction: column; gap: 0.5rem; }
.detail-item {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.9rem;
}
.detail-label { color: var(--gray-500); }
.detail-notes { margin-top: 0.5rem; font-size: 0.85rem; color: var(--gray-600); }
.text-warn { color: var(--danger); }

/* ---- FACTUUR TOTALEN ---- */
.factuur-totalen {
  margin-left: auto;
  max-width: 300px;
  margin-top: 1rem;
}
.totaal-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  font-size: 0.9rem;
}
.totaal-row-groot {
  border-top: 2px solid var(--primary);
  margin-top: 0.25rem;
  padding-top: 0.5rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
}

/* ---- LOGIN ---- */
.login-page {
  background: linear-gradient(135deg, var(--gray-900) 0%, #1e3a5f 100%);
  justify-content: center;
  align-items: center;
}
.login-container {
  background: #fff;
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  width: 100%;
  max-width: 400px;
}
.login-header {
  text-align: center;
  margin-bottom: 2rem;
}
.login-header p {
  color: var(--gray-500);
  margin-top: 0.25rem;
  font-size: 0.9rem;
}
.login-form .form-group { margin-bottom: 1.25rem; }
.login-form .btn { margin-top: 0.5rem; padding: 0.7rem; font-size: 1rem; }

/* ---- CHART ---- */
#omzetGrafiek {
  padding: 1.25rem;
  width: 100%;
}

/* ---- LOGIN CARD (portaal) ---- */
.login-card {
  background: #fff;
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  width: 100%;
  max-width: 400px;
}
.login-logo {
  font-size: 1.8rem;
  font-weight: 800;
  text-align: center;
  color: var(--gray-900);
  letter-spacing: -0.5px;
}
.login-logo span { color: var(--primary); }

/* ---- PORTAAL CONTENT ---- */
.portaal-content {
  margin-left: var(--sidebar-w);
  padding: 2rem;
  flex: 1;
  overflow-x: hidden;
  max-width: 100%;
  box-sizing: border-box;
}

/* ---- TICKET BERICHTEN ---- */
.ticket-berichten {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.ticket-bericht {
  padding: 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
}
.bericht-klant {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
}
.bericht-beheerder {
  background: var(--primary-light);
  border: 1px solid #93c5fd;
}
.bericht-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
}
.bericht-datum { color: var(--gray-400); }
.bericht-inhoud { white-space: pre-wrap; line-height: 1.6; }

/* ---- EXTRA BADGE STATUSES ---- */
[data-status="actief"] { background: #d1fae5; color: #065f46; }
[data-status="nieuw"] { background: var(--primary-light); color: var(--primary-dark); }
[data-status="gepauzeerd"] { background: #fef3c7; color: #92400e; }
[data-status="opgezegd"] { background: #fee2e2; color: #991b1b; }
[data-status="open"] { background: var(--primary-light); color: var(--primary-dark); }
[data-status="beantwoord"] { background: #d1fae5; color: #065f46; }
[data-status="wacht_op_klant"] { background: #fef3c7; color: #92400e; }
[data-status="gesloten"] { background: var(--gray-200); color: var(--gray-500); }
[data-status="definitief"] { background: var(--primary-light); color: var(--primary-dark); }
[data-status="verwerkt"] { background: #d1fae5; color: #065f46; }
[data-status="inactief"] { background: var(--gray-200); color: var(--gray-500); }
[data-status="hoog"] { background: #fed7aa; color: #c2410c; }
[data-status="urgent"] { background: #fee2e2; color: #991b1b; }
[data-status="laag"] { background: var(--gray-200); color: var(--gray-500); }
[data-status="normaal"] { background: var(--primary-light); color: var(--primary-dark); }

/* ---- TOPBAR ---- */
.topbar { display:flex; justify-content:flex-end; align-items:center; padding:0.5rem 0; margin-bottom:0.5rem; }
.topbar-user { display:flex; align-items:center; gap:0.5rem; font-size:0.85rem; color:#6b7280; background:#f9fafb; padding:0.4rem 0.75rem; border-radius:8px; border:1px solid #e5e7eb; }
.topbar-user span { font-weight:500; color:#374151; }
.topbar-user a { color:#9ca3af; display:flex; align-items:center; transition:color 0.2s; }
.topbar-user a:hover { color:#ef4444; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .hamburger { display: block; }
  .content { margin-left: 0; padding: 1rem; padding-top: 4rem; }
  .topbar-user span { font-size:0.8rem; }
  .detail-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .filter-form { flex-direction: column; }
  .filter-form .input, .filter-form select.input { max-width: 100%; }
  .form-row { flex-direction: column; }
  .table { font-size: 0.8rem; }
  .table th, .table td { padding: 0.5rem 0.5rem; }
  .factuur-totalen { max-width: 100%; }
}
