@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:wght@700&display=swap');

:root {
  --color-primary: #2D6A4F;
  --color-primary-light: #52B788;
  --color-primary-dark: #1B4332;
  --color-accent: #D4A017;
  --color-accent-light: #F4D03F;
  --color-background: #F8F9F0;
  --color-surface: #FFFFFF;
  --color-text: #1A2E1A;
  --color-text-muted: #6B7C6B;
  --color-border: #D8E4D8;
  --color-error: #C0392B;
  --color-success: #27AE60;
  --color-warning: #E67E22;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
  --sidebar-width: 240px;
  --topbar-height: 60px;
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--color-background);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.6;
}

/* ─── LAYOUT ─────────────────────────────────────── */

.app-layout {
  display: flex;
  min-height: 100vh;
}

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

.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
}

.sidebar-logo-text {
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  color: white;
}

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

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

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  border-radius: 0;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255,255,255,0.12);
  color: white;
}

.sidebar-nav a.active {
  border-right: 3px solid var(--color-primary-light);
}

.sidebar-nav .icon { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 12px;
  color: rgba(255,255,255,0.5);
}

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

.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-content {
  padding: 24px;
  flex: 1;
}

/* ─── NOTIFICATIONS ──────────────────────────────── */

.notif-btn {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.notif-btn:hover { background: var(--color-background); }

.notif-badge {
  position: absolute;
  top: 2px; right: 2px;
  background: var(--color-error);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

.notif-panel {
  position: absolute;
  top: calc(var(--topbar-height) + 4px);
  right: 16px;
  width: 360px;
  max-height: 480px;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  overflow-y: auto;
  z-index: 200;
}

.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background 0.1s;
}

.notif-item:hover { background: var(--color-background); }
.notif-item.unread { background: #f0f8f4; border-left: 3px solid var(--color-primary); }
.notif-title { font-weight: 600; font-size: 13px; }
.notif-body { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }
.notif-time { font-size: 11px; color: var(--color-text-muted); margin-top: 4px; }

/* ─── CARDS ──────────────────────────────────────── */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
}

.card-body { padding: 20px; }

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.2;
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-card .stat-icon {
  color: var(--color-primary-light);
  margin-bottom: 8px;
}

/* ─── PROGRESS BAR ───────────────────────────────── */

.progress-container { margin: 12px 0; }
.progress-label { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 13px; }
.progress-bar-bg {
  height: 12px;
  background: var(--color-border);
  border-radius: 6px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.6s ease;
}
.progress-red { background: var(--color-error); }
.progress-orange { background: var(--color-warning); }
.progress-green { background: var(--color-success); }
.progress-blue { background: #3498DB; }

/* ─── TABLES ─────────────────────────────────────── */

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

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: var(--color-background);
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
  font-size: 13px;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafcfa; }

/* ─── BUTTONS ────────────────────────────────────── */

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

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

.btn-accent {
  background: var(--color-accent);
  color: white;
}
.btn-accent:hover { background: #b88a00; }

.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}
.btn-outline:hover { background: var(--color-primary); color: white; }

.btn-danger {
  background: var(--color-error);
  color: white;
}
.btn-danger:hover { background: #a93226; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── FORMS ──────────────────────────────────────── */

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

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 6px;
}

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

.form-control:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(45,106,79,0.12);
}

textarea.form-control { resize: vertical; min-height: 80px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 20px;
}

/* ─── BADGES ─────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-green { background: #d4edda; color: #155724; }
.badge-yellow { background: #fff3cd; color: #856404; }
.badge-red { background: #f8d7da; color: #721c24; }
.badge-blue { background: #cce5ff; color: #004085; }
.badge-gray { background: #e2e3e5; color: #383d41; }
.badge-orange { background: #ffe4cc; color: #7a3500; }

/* ─── STATUS BADGES ──────────────────────────────── */

.status-draft { @extend .badge-gray; }
.status-pending { @extend .badge-yellow; }
.status-confirmed { @extend .badge-blue; }
.status-shipped { @extend .badge-orange; }
.status-delivered { @extend .badge-green; }
.status-cancelled { @extend .badge-red; }
.status-disputed { @extend .badge-red; }

/* ─── PRODUCER CARDS ─────────────────────────────── */

.producer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.producer-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}

.producer-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.producer-card-img {
  height: 140px;
  background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.producer-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.producer-card-body { padding: 16px; flex: 1; }
.producer-card-name { font-weight: 600; font-size: 15px; }
.producer-card-location { font-size: 12px; color: var(--color-text-muted); margin-top: 4px; }
.producer-card-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ─── STARS ──────────────────────────────────────── */

.stars { color: var(--color-accent); font-size: 14px; }
.stars-empty { color: #D8E4D8; }

/* ─── OUTLET BADGE ───────────────────────────────── */

.outlet-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--color-accent);
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
}

/* ─── ALERT BOXES ────────────────────────────────── */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  border-left: 4px solid;
}

.alert-success { background: #d4edda; color: #155724; border-color: var(--color-success); }
.alert-error { background: #f8d7da; color: #721c24; border-color: var(--color-error); }
.alert-warning { background: #fff3cd; color: #856404; border-color: var(--color-warning); }
.alert-info { background: #cce5ff; color: #004085; border-color: #3498DB; }

.success-msg { color: var(--color-success); font-size: 13px; padding: 8px 0; }
.error-msg { color: var(--color-error); font-size: 13px; padding: 8px 0; }

/* ─── GRID UTILITIES ─────────────────────────────── */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ─── PAGE HEADER ────────────────────────────────── */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h1 {
  font-family: 'Playfair Display', serif;
  font-size: 24px;
  color: var(--color-primary-dark);
}

.page-header p { color: var(--color-text-muted); margin-top: 4px; font-size: 13px; }

/* ─── LOGIN PAGE ─────────────────────────────────── */

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

.login-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

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

.login-logo img {
  width: 80px;
  height: 80px;
  border-radius: 16px;
  object-fit: cover;
}

.login-title {
  font-family: 'Playfair Display', serif;
  font-size: 26px;
  color: var(--color-primary-dark);
  text-align: center;
  margin-bottom: 4px;
}

.login-subtitle {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 13px;
  margin-bottom: 28px;
}

/* ─── FILTERS BAR ────────────────────────────────── */

.filters-bar {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-label { font-size: 11px; font-weight: 600; color: var(--color-text-muted); text-transform: uppercase; }

.filter-select {
  padding: 7px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--color-text);
  background: white;
  cursor: pointer;
  min-width: 140px;
}

.search-input {
  padding: 8px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  flex: 1;
  min-width: 200px;
}

/* ─── PUBLIC TRACE PAGE ──────────────────────────── */

.trace-page {
  min-height: 100vh;
  background: var(--color-background);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.trace-card {
  max-width: 480px;
  width: 100%;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  overflow: hidden;
}

.trace-header {
  background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary));
  padding: 24px;
  text-align: center;
  color: white;
}

.trace-header img { width: 60px; border-radius: 12px; margin-bottom: 12px; }
.trace-header h1 { font-family: 'Playfair Display', serif; font-size: 22px; }

.trace-body { padding: 24px; }
.trace-seal {
  background: var(--color-primary);
  color: white;
  text-align: center;
  padding: 16px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
}

/* ─── HTMX LOADING ───────────────────────────────── */

.htmx-request .htmx-indicator { display: inline-block; }
.htmx-indicator { display: none; }

/* ─── MODAL ──────────────────────────────────────── */

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

.modal {
  background: white;
  border-radius: var(--radius-md);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title { font-size: 16px; font-weight: 600; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--color-border); display: flex; gap: 10px; justify-content: flex-end; }

/* ─── MISC ───────────────────────────────────────── */

.text-muted { color: var(--color-text-muted); }
.text-primary { color: var(--color-primary); }
.text-sm { font-size: 12px; }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.w-full { width: 100%; }

.divider { border: none; border-top: 1px solid var(--color-border); margin: 16px 0; }

/* ─── RESPONSIVE ─────────────────────────────────── */

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

/* ─── HTMX ANIMATIONS ────────────────────────────── */

[hx-swap="innerHTML"].htmx-settling * { transition: opacity 0.2s; }
