/* ===========================================================
   style.css — Shahana Vegetables Design System
   Palette: leaf green / tomato terracotta / turmeric / cream paper
   Type: Poppins (display) + Inter (body/data) + Noto Sans Malayalam
   =========================================================== */

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

:root {
  /* ---- Brand palette (light mode) ---- */
  --leaf-900: #1B4023;
  --leaf-700: #2F6B3C;
  --leaf-600: #3C8049;
  --leaf-100: #E3F0E4;
  --leaf-50:  #F1F8F1;

  --tomato-600: #B83D24;
  --tomato-500: #D1492C;
  --tomato-100: #FBE4DC;

  --turmeric-500: #CF8B1F;
  --turmeric-400: #E2A33B;
  --turmeric-100: #FBF0DA;

  --cream-50: #FAF7F0;
  --cream-100: #F3EEE2;
  --paper: #FFFFFF;

  --ink-900: #1E1C17;
  --ink-700: #4A463D;
  --ink-500: #79746A;
  --ink-300: #B6B0A2;
  --ink-200: #DEDACE;
  --ink-100: #ECE9DF;

  /* ---- Semantic tokens (mapped per-theme) ---- */
  --bg: var(--cream-50);
  --surface: var(--paper);
  --surface-2: var(--cream-100);
  --text: var(--ink-900);
  --text-muted: var(--ink-500);
  --border: var(--ink-200);
  --primary: var(--leaf-700);
  --primary-hover: var(--leaf-900);
  --primary-contrast: #FFFFFF;
  --primary-tint: var(--leaf-100);
  --danger: var(--tomato-500);
  --danger-tint: var(--tomato-100);
  --warning: var(--turmeric-400);
  --warning-tint: var(--turmeric-100);
  --focus-ring: #5FA8D3;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(30, 28, 23, 0.06), 0 1px 1px rgba(30, 28, 23, 0.04);
  --shadow-md: 0 4px 12px rgba(30, 28, 23, 0.08), 0 2px 4px rgba(30, 28, 23, 0.04);
  --shadow-lg: 0 12px 32px rgba(30, 28, 23, 0.14);

  --font-display: 'Poppins', 'Noto Sans Malayalam', system-ui, sans-serif;
  --font-body: 'Inter', 'Noto Sans Malayalam', system-ui, sans-serif;

  --header-h: 64px;
  --sidebar-w: 240px;
}

/* ---- Dark theme ---- */
[data-theme="dark"] {
  --bg: #121A15;
  --surface: #1B261F;
  --surface-2: #223027;
  --text: #EFEDE6;
  --text-muted: #A8A398;
  --border: #2D3A32;
  --primary: #4F9B5E;
  --primary-hover: #66B374;
  --primary-contrast: #0E1510;
  --primary-tint: #1E3024;
  --danger: #E2654A;
  --danger-tint: #3A211B;
  --warning: #E2A33B;
  --warning-tint: #3A2E16;
  --focus-ring: #6FB8E6;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.45);
}

/* ---- Reset & base ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0 0 0.5em;
  color: var(--text);
  letter-spacing: -0.01em;
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }
p { margin: 0 0 1em; }

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

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .logo-mark {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--primary-contrast);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 1rem;
  flex-shrink: 0;
}
.sidebar-brand .brand-text { font-family: var(--font-display); font-weight: 600; font-size: 0.95rem; line-height: 1.25; }
.sidebar-brand .brand-text small { display: block; font-weight: 400; color: var(--text-muted); font-size: 0.72rem; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.89rem;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-nav a:hover { background: var(--surface-2); color: var(--text); }
.sidebar-nav a.active { background: var(--primary-tint); color: var(--primary); font-weight: 600; }

.sidebar-footer { padding: 14px 16px; border-top: 1px solid var(--border); }

.main-area {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
  gap: 16px;
}
.topbar-title { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.menu-toggle {
  display: none;
  background: none; border: none; color: var(--text);
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  align-items: center; justify-content: center;
}
.menu-toggle:hover { background: var(--surface-2); }

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

/* ---- Toggle controls (theme + language) ---- */
.icon-btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  transition: background-color 0.15s ease;
}
.icon-btn:hover { background: var(--primary-tint); color: var(--primary); }
.icon-btn svg { width: 18px; height: 18px; }

.lang-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-size: 0.78rem;
  font-weight: 600;
}
.lang-toggle button {
  padding: 8px 11px;
  background: var(--surface-2);
  border: none;
  color: var(--text-muted);
}
.lang-toggle button.active { background: var(--primary); color: var(--primary-contrast); }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }

/* ---- Stat tiles ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.stat-tile .stat-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; margin-bottom: 6px; }
.stat-tile .stat-value { font-family: var(--font-display); font-size: 1.55rem; font-weight: 700; }
.stat-tile.accent-leaf .stat-value { color: var(--primary); }
.stat-tile.accent-tomato .stat-value { color: var(--danger); }
.stat-tile.accent-turmeric .stat-value { color: var(--warning); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.88rem;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: var(--primary-contrast); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--tomato-600); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---- Forms ---- */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 0.83rem; font-weight: 600;
  margin-bottom: 6px; color: var(--text);
}
.field .hint { font-size: 0.76rem; color: var(--text-muted); margin-top: 5px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

input[type="text"], input[type="search"], input[type="tel"], input[type="number"],
input[type="password"], input[type="email"], input[type="date"], select, textarea {
  width: 100%;
  padding: 10px 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
}
textarea { resize: vertical; min-height: 80px; }
input::placeholder, textarea::placeholder { color: var(--ink-300); }
[data-theme="dark"] input::placeholder, [data-theme="dark"] textarea::placeholder { color: var(--text-muted); }

input:focus, select:focus, textarea:focus { border-color: var(--primary); }

.radio-group, .checkbox-group { display: flex; gap: 16px; flex-wrap: wrap; }
.radio-pill {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem; font-weight: 500;
  cursor: pointer;
}
.radio-pill input { width: auto; accent-color: var(--primary); }
.radio-pill:has(input:checked) { border-color: var(--primary); background: var(--primary-tint); color: var(--primary); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
thead th {
  text-align: left;
  padding: 11px 16px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
}
.badge-leaf { background: var(--primary-tint); color: var(--primary); }
.badge-tomato { background: var(--danger-tint); color: var(--danger); }
.badge-turmeric { background: var(--warning-tint); color: var(--turmeric-600, var(--warning)); }
.badge-muted { background: var(--surface-2); color: var(--text-muted); }

/* ---- Alerts / flash messages ---- */
.alert {
  padding: 13px 16px;
  border-radius: var(--radius-md);
  font-size: 0.87rem;
  margin-bottom: 18px;
  display: flex; align-items: flex-start; gap: 10px;
  border: 1px solid transparent;
}
.alert-success { background: var(--primary-tint); color: var(--leaf-900); border-color: var(--leaf-600); }
[data-theme="dark"] .alert-success { color: var(--primary); }
.alert-error { background: var(--danger-tint); color: var(--tomato-600); border-color: var(--tomato-500); }
[data-theme="dark"] .alert-error { color: var(--danger); }
.alert-warning { background: var(--warning-tint); color: var(--turmeric-600, #8a5d12); border-color: var(--turmeric-400); }

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 18, 14, 0.5);
  display: none; align-items: center; justify-content: center;
  padding: 20px; z-index: 100;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-body { padding: 22px; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---- Login pages ---- */
.auth-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--leaf-900) 0%, var(--leaf-700) 55%, var(--leaf-600) 100%);
  padding: 20px;
}
[data-theme="dark"] .auth-screen { background: linear-gradient(160deg, #0E1510 0%, #1B261F 100%); }
.auth-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 400px;
  padding: 32px 30px;
}
.auth-logo {
  width: 56px; height: 56px; border-radius: var(--radius-md);
  background: var(--primary); color: var(--primary-contrast);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 1.4rem;
  margin: 0 auto 16px;
}
.auth-card h1 { text-align: center; font-size: 1.3rem; }
.auth-subtitle { text-align: center; color: var(--text-muted); font-size: 0.85rem; margin-bottom: 24px; }
.auth-footer-link { text-align: center; margin-top: 18px; font-size: 0.83rem; color: var(--text-muted); }

/* ---- Receipt / invoice (signature element) ---- */
.receipt {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  max-width: 420px;
  margin: 0 auto;
  position: relative;
  box-shadow: var(--shadow-md);
}
.receipt::before {
  content: "";
  display: block;
  height: 10px;
  background-image: radial-gradient(circle at 8px 0, transparent 6px, var(--bg) 6.5px);
  background-size: 16px 10px;
  background-repeat: repeat-x;
  margin-bottom: -1px;
}
.receipt-inner { padding: 22px 22px 10px; }
.receipt-shop-name { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; text-align: center; color: var(--primary); }
.receipt-shop-meta { text-align: center; font-size: 0.76rem; color: var(--text-muted); line-height: 1.5; margin-bottom: 14px; }
.receipt-divider { border-top: 1px dashed var(--border); margin: 12px 0; }
.receipt-meta-row { display: flex; justify-content: space-between; font-size: 0.8rem; margin-bottom: 4px; }
.receipt-meta-row span:first-child { color: var(--text-muted); }
.receipt-items table { font-size: 0.82rem; }
.receipt-items thead th { background: transparent; padding: 6px 4px; border-bottom: 1px dashed var(--border); }
.receipt-items tbody td { padding: 7px 4px; border-bottom: none; }
.receipt-total-row { display: flex; justify-content: space-between; font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; padding: 12px 0 4px; border-top: 1px dashed var(--border); margin-top: 6px; }
.receipt-footnote { text-align: center; font-size: 0.74rem; color: var(--text-muted); padding: 6px 0 20px; }

.stamp-badge {
  position: absolute;
  top: 18px; right: 18px;
  border: 2px solid var(--danger);
  color: var(--danger);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 4px;
  transform: rotate(8deg);
  text-transform: uppercase;
}
.stamp-badge.paid { border-color: var(--primary); color: var(--primary); transform: rotate(-6deg); }

/* ---- Utility ---- */
.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(--text-muted); }
.text-sm { font-size: 0.83rem; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 14px; opacity: 0.5; }

/* ---- Responsive ---- */
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .menu-toggle { display: flex; }
  .field-row { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 35; }
  .sidebar-overlay.open { display: block; }
}
@media (max-width: 600px) {
  .topbar { padding: 0 14px; }
  .topbar-title { font-size: 0.92rem; }
  .auth-card { padding: 26px 20px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  thead th, tbody td { padding: 9px 10px; }
}
