/* ============================================
   DCN AI – Beheer (admin)
   ============================================ */

:root {
  --bg-main: #0d0d0f;
  --bg-card: #171719;
  --bg-input: #2d2d30;
  --border: rgba(255, 255, 255, 0.08);
  --text: #ececec;
  --text-muted: #9b9ba5;
  --accent: #2d7d46;
  --accent-hover: #3d9d56;
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body.admin-page {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg-main);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ----- Header ----- */
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 28px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  min-height: 56px;
}

.admin-brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.admin-brand a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 1.05rem;
}

.admin-brand a:hover {
  color: var(--accent);
}

.admin-brand .admin-title {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9rem;
}

.admin-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-user {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}

.admin-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}

.admin-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.admin-btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: white;
}

/* ----- Main content ----- */
.admin-main {
  flex: 1;
  padding: 32px 28px 48px;
  max-width: 880px;
  margin: 0 auto;
  width: 100%;
}

.admin-main .admin-page-title {
  margin: 0 0 28px;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

/* ----- Sections ----- */
.admin-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 20px;
}

.admin-section:last-child {
  margin-bottom: 0;
}

.admin-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.admin-section h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.admin-section-header .admin-btn {
  flex-shrink: 0;
}

.admin-section-header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ----- Add user form in modal ----- */
.admin-form-inline label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.admin-form-inline input[type="email"],
.admin-form-inline input[type="password"] {
  width: 100%;
  max-width: 280px;
  padding: 8px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}
.admin-form-inline .admin-modal-actions {
  margin-top: 12px;
  padding-top: 12px;
}

/* ----- Table ----- */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th,
.admin-table td {
  padding: 14px 16px 14px 0;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.admin-table th:first-child,
.admin-table td:first-child {
  padding-left: 0;
}

.admin-table th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-bottom: 10px;
}

.admin-table th:last-child,
.admin-table td:last-child {
  padding-right: 0;
  text-align: right;
  min-width: 110px;
}

.admin-table tbody tr:hover {
  background: transparent;
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-table td {
  color: var(--text);
}

/* ----- Badges ----- */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
}

.badge-approved {
  background: rgba(45, 125, 70, 0.2);
  color: #86efac;
}

.badge-pending {
  background: rgba(234, 179, 8, 0.15);
  color: #fde047;
}

.badge-suspended {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.badge-current {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

/* ----- Table buttons ----- */
.admin-table .btn-sm {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  background: var(--accent);
  color: white;
  font-family: var(--font);
  transition: background 0.15s;
  margin-right: 8px;
}

.admin-table .btn-sm:last-of-type {
  margin-right: 0;
}

.admin-table .btn-sm:hover {
  background: var(--accent-hover);
}

.admin-table .btn-sm:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.admin-table .btn-sm.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.admin-table .btn-sm.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}

/* ----- Metrics ----- */
.admin-model-info {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.admin-model-info code {
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.admin-chat-log-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.admin-chat-log-page-info {
  font-size: 13px;
  color: var(--text-muted);
}

.admin-chat-log-pagination-btns {
  display: flex;
  gap: 8px;
}

.admin-chat-log-pagination-btns .admin-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.admin-muted {
  font-size: 12px;
  color: var(--text-muted);
}

.management-form .form-row {
  margin-bottom: 12px;
}

.management-form .form-row label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.management-form .form-row input,
.management-form .form-row select {
  width: 100%;
  max-width: 320px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.invoice-period-row--outstanding > td:first-child {
  box-shadow: inset 3px 0 0 rgba(234, 179, 8, 0.45);
}

.invoice-manual-cell {
  vertical-align: top;
  min-width: 140px;
}

.invoice-manual-total {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.invoice-manual-breakdown {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.invoice-manual-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.invoice-manual-desc {
  flex: 1 1 120px;
  min-width: 0;
}

.invoice-manual-amt {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.admin-table .invoice-manual-del {
  flex-shrink: 0;
  margin-left: auto;
}

.invoice-actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  vertical-align: middle;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

@media (min-width: 640px) {
  .metrics-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.metric-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  min-height: 88px;
}

.metric-card .value {
  font-size: 2rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.metric-card .label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}

.metric-card-highlight {
  border-color: rgba(45, 125, 70, 0.35);
  background: rgba(45, 125, 70, 0.06);
}

.metric-card-highlight .value {
  color: #86efac;
}

/* ----- States ----- */
.admin-loading {
  color: var(--text-muted);
  padding: 64px 24px;
  text-align: center;
  font-size: 15px;
}

.admin-error {
  background: rgba(220, 53, 69, 0.08);
  border: 1px solid rgba(220, 53, 69, 0.2);
  color: #f87171;
  padding: 24px 28px;
  border-radius: var(--radius);
  font-size: 15px;
}

.admin-outstanding-warning {
  background: rgba(234, 179, 8, 0.12);
  border: 1px solid rgba(234, 179, 8, 0.35);
  color: #fde047;
  padding: 14px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 24px;
}

.admin-empty {
  color: var(--text-muted);
  font-size: 14px;
  padding: 32px 16px;
  text-align: center;
}

/* ----- Zoeken ----- */
.admin-search-wrap {
  margin-bottom: 24px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.admin-search-wrap input {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  min-width: 220px;
  max-width: 320px;
}

.admin-search-wrap input::placeholder {
  color: var(--text-muted);
}

.admin-search-wrap input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ----- Modal (gebruik per gebruiker) ----- */
.admin-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.admin-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.admin-modal h3 {
  margin: 0 0 16px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.admin-modal-dl {
  margin: 0;
  display: grid;
  gap: 10px 16px;
}

.admin-modal-dl dt {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

.admin-modal-dl dd {
  margin: 0;
  font-size: 14px;
  color: var(--text);
  text-align: right;
}

.admin-modal-dl .row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
}

.admin-modal-wide {
  max-width: 640px;
}

.admin-log-preview {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-log-modal-content p {
  margin: 12px 0 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.admin-log-modal-content p:first-child {
  margin-top: 0;
}

.admin-log-full {
  background: rgba(0, 0, 0, 0.2);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow-y: auto;
  margin: 0 0 12px;
  border: 1px solid var(--border);
}

.admin-log-exchange {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.admin-log-exchange:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
}

.admin-log-exchange-date {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.admin-modal-actions {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

@media (max-width: 600px) {
  .admin-header {
    padding: 12px 16px;
  }
  .admin-main {
    padding: 20px 16px 32px;
  }
  .admin-section {
    padding: 20px 20px;
  }
  .admin-user {
    display: none;
  }
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  .metric-card-highlight .value {
    color: var(--text);
  }
}
