/* Derewol Admin — charte DerewolPrint (#1e4d2b / #f5c842) */

:root {
  --vert: #1e4d2b;
  --vert-clair: #2d6b3d;
  --jaune: #f5c842;
  --noir: #111510;
  --bg: #faf8f2;
  --surface: #ffffff;
  --text: #1a1f1a;
  --muted: #5c6659;
  --border: #d4dbd2;
  --danger: #c62828;
  --warning: #e65100;
  --whatsapp: #25d366;
  --radius: 12px;
  --sidebar-w: 220px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
}

/* ── Login ─────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(145deg, var(--vert) 0%, #0f2818 100%);
}

.login-box {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 36px 32px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.25);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.logo-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--jaune);
}

.logo-text {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--noir);
}

.logo-text b {
  color: var(--vert);
}

.admin-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-left: 6px;
}

.login-box h2 {
  margin: 0 0 20px;
  font-size: 1.25rem;
  color: var(--vert);
}

.login-box input {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  background: var(--bg);
}

.login-box input:focus {
  outline: none;
  border-color: var(--vert);
}

/* ── Dashboard layout ──────────────────────────── */
.dashboard-page {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--vert);
  color: #e8f5e9;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-logo .logo-mark {
  width: 36px;
  height: 36px;
}

.sidebar-logo .logo-text {
  color: #fff;
  font-size: 1.15rem;
}

.sidebar-logo .logo-text b {
  color: var(--jaune);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.nav-item.active {
  background: var(--jaune);
  color: var(--noir);
}

.btn-logout {
  margin: 12px 14px 0;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.btn-logout:hover {
  background: rgba(255, 255, 255, 0.1);
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 48px;
  overflow-y: auto;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.view h1 {
  margin: 0 0 8px;
  font-size: 1.5rem;
  color: var(--vert);
}

.view-intro {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--muted);
  max-width: 720px;
}

.view-intro code {
  font-size: 12px;
  background: #eef2ee;
  padding: 2px 6px;
  border-radius: 4px;
}

.view-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.count-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  background: var(--jaune);
  color: var(--noir);
  vertical-align: middle;
}

.search-input {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  min-width: 220px;
  font-size: 14px;
  font-family: inherit;
}

/* ── Stats ─────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
}

.stat-card--highlight {
  border-color: var(--vert-clair);
  box-shadow: 0 0 0 1px rgba(30, 77, 43, 0.08);
}

.stat-card--warning {
  border-left: 4px solid var(--warning);
}

.stat-card--revenue {
  border-left: 4px solid var(--jaune);
}

.stat-icon {
  font-size: 22px;
  color: var(--vert);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--noir);
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}

.section-card h2 {
  margin: 0 0 16px;
  font-size: 1.05rem;
  color: var(--vert);
}

.expiring-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.expiring-row:last-child {
  border-bottom: none;
}

.text-muted {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.expiring-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Tables ────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: #f0f4f1;
  font-weight: 600;
  color: var(--vert);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.data-table tbody tr:hover {
  background: #fafcf9;
}

.data-table code {
  font-size: 12px;
  background: #f0f4f1;
  padding: 2px 6px;
  border-radius: 4px;
}

.code-cell {
  margin-right: 6px;
}

.td-actions {
  white-space: nowrap;
}

.loading,
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 24px !important;
}

/* ── Badges ───────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge-active {
  background: #e8f5e9;
  color: #2e7d32;
}

.badge-pending {
  background: #fff8e1;
  color: #f57f17;
}

.badge-expired,
.badge-muted {
  background: #eceff1;
  color: #546e7a;
}

.badge-used {
  background: #e3f2fd;
  color: #1565c0;
}

.badge-warning {
  background: #fff3e0;
  color: #e65100;
}

/* ── Buttons ───────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  background: var(--vert);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-primary:hover {
  background: var(--vert-clair);
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn-secondary {
  padding: 10px 18px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  margin-right: 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  color: var(--text);
}

.btn-action:hover {
  border-color: var(--vert);
  color: var(--vert);
}

.btn-danger {
  border-color: #ffcdd2;
  color: var(--danger);
}

.btn-danger:hover {
  background: #ffebee;
}

.btn-icon {
  padding: 4px 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  vertical-align: middle;
}

.btn-icon:hover {
  color: var(--vert);
}

.btn-whatsapp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 18px;
  border-radius: 8px;
  background: var(--whatsapp);
  color: #fff !important;
  font-weight: 600;
  text-decoration: none;
  font-size: 14px;
}

.btn-whatsapp:hover {
  filter: brightness(1.08);
}

.btn-whatsapp-sm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--whatsapp);
  color: #fff !important;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

/* ── Filters ───────────────────────────────────── */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.filter-btn {
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  color: var(--muted);
}

.filter-btn.active {
  border-color: var(--vert);
  background: var(--vert);
  color: #fff;
}

/* ── Modal ─────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.modal-box {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px 26px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.modal-box h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
  color: var(--vert);
}

.modal-hint {
  margin: 0 0 18px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.form-group select,
.form-group input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}

.gen-result {
  margin: 16px 0;
  padding: 16px;
  background: var(--bg);
  border-radius: 8px;
  text-align: center;
}

.gen-code-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.gen-code-display span {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  font-family: ui-monospace, monospace;
  color: var(--vert);
}

.gen-code-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 10px 0 0;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.error-msg {
  padding: 10px 12px;
  border-radius: 8px;
  background: #ffebee;
  color: #b71c1c;
  font-size: 13px;
  margin-top: 12px;
}

/* ── Responsive ────────────────────────────────── */
@media (max-width: 900px) {
  .dashboard-page {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 12px 14px;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
    padding: 8px 0;
  }

  .btn-logout {
    margin: 0;
    width: auto;
  }

  .main-content {
    padding: 20px 16px;
  }
}
