/* =========================================================
   KOPERASI KONSUMEN MARKETPLACE — Design System
   Palet: Biru Tua (institusi & kepercayaan) + Hijau Zamrud (pertumbuhan)
   ========================================================= */

:root {
  --navy-900: #12293F;
  --navy-800: #1B3A5C;
  --navy-700: #23486F;
  --navy-100: #E7EDF3;

  --emerald-700: #24614A;
  --emerald-600: #2E7D5B;
  --emerald-100: #E1F2EA;

  --amber-500: #E8A33D;
  --amber-100: #FCF0DC;

  --red-600: #C0392B;
  --red-100: #FBE9E7;

  --ink-900: #1E2732;
  --ink-600: #566275;
  --ink-400: #8A96A6;

  --surface: #F4F6F8;
  --card: #FFFFFF;
  --border: #E3E8EE;

  --whatsapp: #25D366;
  --whatsapp-dark: #1DA851;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 10px 30px rgba(18, 41, 63, 0.07);
  --shadow-pop: 0 16px 40px rgba(18, 41, 63, 0.14);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--surface);
  color: var(--ink-900);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, .heading-font {
  font-family: 'Poppins', 'Inter', sans-serif;
  color: var(--navy-900);
  margin: 0 0 8px;
  line-height: 1.25;
}

h1 { font-size: 26px; font-weight: 600; }
h2 { font-size: 21px; font-weight: 600; }
h3 { font-size: 17px; font-weight: 600; }
p  { margin: 0 0 12px; color: var(--ink-600); }

a { color: var(--emerald-600); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--emerald-100); }

:focus-visible {
  outline: 2px solid var(--emerald-600);
  outline-offset: 2px;
}

/* ---------- Layout Shell ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  background: var(--navy-900);
  color: #fff;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  transform: translateX(0);
  transition: transform .25s ease;
  z-index: 40;
}

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

.sidebar-brand .logo-badge {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--emerald-600), var(--emerald-700));
  display: flex; align-items: center; justify-content: center;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
}

.sidebar-brand strong {
  font-family: 'Poppins', sans-serif;
  font-size: 14.5px;
  color: #fff;
  display: block;
  line-height: 1.3;
}
.sidebar-brand span {
  font-size: 11.5px;
  color: rgba(255,255,255,0.55);
}

.sidebar-nav {
  padding: 14px 12px;
  overflow-y: auto;
  flex: 1;
}

.sidebar-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.35);
  padding: 14px 12px 6px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.75);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  text-decoration: none;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}

.sidebar-nav a.active {
  background: var(--emerald-600);
  color: #fff;
}

.sidebar-nav .icon { width: 18px; text-align: center; font-size: 15px; }

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px;
  color: rgba(255,255,255,0.45);
}

/* ---------- Main Content ---------- */
.main-content {
  margin-left: 250px;
  flex: 1;
  min-width: 0;
  width: 100%;
}

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar .menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--navy-800);
  cursor: pointer;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
}

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--navy-100);
  color: var(--navy-800);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
}

.role-badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--emerald-100);
  color: var(--emerald-700);
  font-weight: 600;
}

.page-wrap {
  padding: 22px 24px 60px;
  max-width: 1180px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-header p { margin: 0; }

/* ---------- Card ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 22px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

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

@media (max-width: 980px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* ---------- Stat Card ---------- */
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 18px 20px;
}
.stat-card .stat-label {
  font-size: 12.5px;
  color: var(--ink-400);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-bottom: 6px;
}
.stat-card .stat-value {
  font-family: 'Poppins', sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--navy-900);
}
.stat-card .stat-sub {
  font-size: 12.5px;
  color: var(--ink-400);
  margin-top: 4px;
}
.stat-card.accent-emerald .stat-value { color: var(--emerald-700); }
.stat-card.accent-amber .stat-value { color: var(--amber-500); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease, transform .1s ease, box-shadow .15s ease;
  line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--navy-800);
  color: #fff;
}
.btn-primary:hover { background: var(--navy-700); }

.btn-accent {
  background: var(--emerald-600);
  color: #fff;
}
.btn-accent:hover { background: var(--emerald-700); }

.btn-outline {
  background: #fff;
  border-color: var(--border);
  color: var(--navy-800);
}
.btn-outline:hover { background: var(--navy-100); }

.btn-danger {
  background: var(--red-100);
  color: var(--red-600);
}
.btn-danger:hover { background: #f6d5d1; }

.btn-sm { padding: 7px 13px; font-size: 13px; }
.btn-block { width: 100%; }

.btn-whatsapp {
  background: var(--whatsapp);
  color: #fff;
}
.btn-whatsapp:hover { background: var(--whatsapp-dark); }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--navy-900);
  margin-bottom: 6px;
}
.form-hint { font-size: 12.5px; color: var(--ink-400); margin-top: 5px; }
.form-error { font-size: 12.5px; color: var(--red-600); margin-top: 5px; font-weight: 500; }

.form-control, select.form-control, textarea.form-control {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--ink-900);
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:focus {
  outline: none;
  border-color: var(--emerald-600);
  box-shadow: 0 0 0 3px var(--emerald-100);
}
.form-control.is-invalid { border-color: var(--red-600); }
textarea.form-control { resize: vertical; min-height: 100px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.8px;
}
table.data-table th {
  text-align: left;
  padding: 12px 14px;
  background: var(--navy-100);
  color: var(--navy-800);
  font-weight: 600;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: .02em;
  white-space: nowrap;
}
table.data-table th:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
table.data-table th:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
table.data-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--ink-900);
}
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: #FAFBFC; }

/* ---------- Badge / Status ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-success { background: var(--emerald-100); color: var(--emerald-700); }
.badge-warning { background: var(--amber-100); color: #9C6B1F; }
.badge-danger  { background: var(--red-100); color: var(--red-600); }
.badge-neutral { background: var(--navy-100); color: var(--navy-800); }

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--ink-400);
}
.empty-state .empty-icon {
  font-size: 34px;
  margin-bottom: 10px;
}
.empty-state h3 { color: var(--navy-800); margin-bottom: 6px; }
.empty-state p { max-width: 380px; margin: 0 auto 16px; }

/* ---------- Alerts / Flash ---------- */
.alert {
  padding: 13px 16px;
  border-radius: var(--radius-md);
  font-size: 13.8px;
  margin-bottom: 18px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}
.alert-success { background: var(--emerald-100); color: var(--emerald-700); }
.alert-error   { background: var(--red-100); color: var(--red-600); }

/* ---------- Login Page ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--navy-900), var(--navy-800) 55%, var(--emerald-700));
  padding: 20px;
}
.auth-card {
  background: #fff;
  width: 100%;
  max-width: 400px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: 34px 30px;
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}
.auth-logo .logo-badge {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--emerald-600), var(--navy-800));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-family: 'Poppins', sans-serif; font-weight: 700;
}
.auth-foot {
  text-align: center;
  margin-top: 18px;
  font-size: 12.5px;
  color: var(--ink-400);
}

/* ---------- Marketplace Cards ---------- */
.product-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
}
.product-card .product-photo {
  aspect-ratio: 4 / 3;
  background: var(--navy-100) center/cover no-repeat;
  display: flex; align-items: center; justify-content: center;
  color: var(--navy-800);
  font-size: 28px;
}
.product-card .product-body { padding: 15px; flex: 1; display: flex; flex-direction: column; }
.product-card .product-price {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  color: var(--emerald-700);
  font-size: 17px;
  margin: 4px 0 10px;
}
.product-card .product-seller {
  font-size: 12.5px;
  color: var(--ink-400);
  margin-bottom: 12px;
}

/* ---------- Install Wizard ---------- */
.install-shell {
  min-height: 100vh;
  background: var(--surface);
  padding: 30px 16px 60px;
}
.install-card {
  max-width: 640px;
  margin: 0 auto;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 32px;
}
.steps-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 26px;
}
.steps-bar span {
  flex: 1;
  height: 5px;
  border-radius: 4px;
  background: var(--border);
}
.steps-bar span.done { background: var(--emerald-600); }

.req-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 13.8px;
}

/* ---------- Footer ---------- */
.app-footer {
  padding: 16px 24px 30px;
  font-size: 12.5px;
  color: var(--ink-400);
  text-align: center;
}

/* ---------- Utilities ---------- */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.text-muted { color: var(--ink-400); }
.text-center { text-align: center; }
.w-full { width: 100%; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-pop); }
  .main-content { margin-left: 0; }
  .topbar .menu-toggle { display: block; }
  .page-wrap { padding: 18px 16px 90px; }
  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(18,41,63,0.45);
    z-index: 35;
  }
  .sidebar-overlay.show { display: block; }
}

@media (max-width: 480px) {
  h1 { font-size: 21px; }
  .card { padding: 16px; }
  .page-wrap { padding: 14px 12px 90px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
