/* =============================================
   MASALA CRM — Spice-themed Design System
   Palette: Deep saffron, warm turmeric, cream
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@400;600;700;800&family=Noto+Sans:wght@400;500;600&display=swap');

:root {
  --saffron:     #E8821A;
  --saffron-dk:  #C46A0A;
  --turmeric:    #F5C842;
  --chili:       #D93025;
  --cream:       #FDF6EC;
  --cream-dk:    #F5E9D4;
  --green:       #2E7D4F;
  --green-lt:    #E8F5EE;
  --sidebar-bg:  #1C0F05;
  --sidebar-txt: #F5C842;
  --text:        #2D1A00;
  --text-lt:     #6B4C2A;
  --border:      #E8D5B5;
  --white:       #FFFFFF;
  --shadow:      0 2px 12px rgba(232,130,26,0.12);
  --radius:      10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Noto Sans', sans-serif;
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
}

/* ---- LAYOUT ---- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  color: var(--sidebar-txt);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 22px 20px 16px;
  border-bottom: 1px solid #3a2010;
}
.sidebar-logo h1 {
  font-family: 'Baloo 2', cursive;
  font-size: 18px;
  font-weight: 800;
  color: var(--turmeric);
  line-height: 1.2;
}
.sidebar-logo small {
  font-size: 11px;
  color: #a07050;
  display: block;
  margin-top: 2px;
}

.sidebar nav { flex: 1; padding: 10px 0; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  color: #c8a87a;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover,
.sidebar nav a.active {
  background: #2d1a08;
  color: var(--turmeric);
  border-left-color: var(--saffron);
}
.sidebar nav .nav-section {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: #5a3a20;
  padding: 16px 20px 6px;
  text-transform: uppercase;
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid #3a2010;
  font-size: 12px;
  color: #7a5030;
}
.sidebar-footer a { color: var(--chili); text-decoration: none; }

.main-wrap {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--white);
  border-bottom: 2px solid var(--cream-dk);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title {
  font-family: 'Baloo 2', cursive;
  font-size: 20px;
  font-weight: 700;
  color: var(--saffron-dk);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-lt);
}
.topbar-right .user-badge {
  background: var(--cream-dk);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
  font-weight: 600;
  color: var(--saffron-dk);
}

.page-content { padding: 28px; flex: 1; }

/* ---- STAT CARDS ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--saffron);
}
.stat-card.green::before { background: var(--green); }
.stat-card.chili::before { background: var(--chili); }
.stat-card.turmeric::before { background: var(--turmeric); }

.stat-card .label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-lt);
  margin-bottom: 8px;
}
.stat-card .value {
  font-family: 'Baloo 2', cursive;
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.stat-card .sub {
  font-size: 12px;
  color: var(--text-lt);
  margin-top: 4px;
}
.stat-card .icon {
  position: absolute;
  right: 16px; top: 16px;
  font-size: 28px;
  opacity: 0.15;
}

/* ---- CARD / PANEL ---- */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h2 {
  font-family: 'Baloo 2', cursive;
  font-size: 17px;
  font-weight: 700;
  color: var(--saffron-dk);
}
.card-body { padding: 20px; }

/* ---- TABLE ---- */
.tbl-wrap { overflow-x: auto; }
table.crm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.crm-table thead tr {
  background: var(--sidebar-bg);
  color: var(--turmeric);
}
.crm-table thead th {
  padding: 11px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  white-space: nowrap;
}
.crm-table tbody tr { border-bottom: 1px solid var(--border); }
.crm-table tbody tr:hover { background: var(--cream); }
.crm-table tbody td { padding: 10px 14px; color: var(--text); }
.crm-table tbody tr:last-child { border-bottom: none; }

/* ---- BADGES ---- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.badge-green  { background: var(--green-lt); color: var(--green); }
.badge-orange { background: #FFF3E0; color: var(--saffron-dk); }
.badge-red    { background: #FDECEA; color: var(--chili); }
.badge-grey   { background: #F0F0F0; color: #666; }
.badge-yellow { background: #FFFDE7; color: #B8860B; }

/* ---- FORMS ---- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-lt);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.form-group input,
.form-group select,
.form-group textarea {
  border: 1.5px solid var(--border);
  border-radius: 7px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: 'Noto Sans', sans-serif;
  color: var(--text);
  background: var(--white);
  transition: border 0.15s;
  outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--saffron);
  box-shadow: 0 0 0 3px rgba(232,130,26,0.12);
}

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: filter 0.15s, transform 0.1s;
}
.btn:hover { filter: brightness(0.92); }
.btn:active { transform: scale(0.97); }
.btn-primary  { background: var(--saffron); color: #fff; }
.btn-success  { background: var(--green); color: #fff; }
.btn-danger   { background: var(--chili); color: #fff; }
.btn-outline  { background: transparent; border: 1.5px solid var(--saffron); color: var(--saffron-dk); }
.btn-sm       { padding: 5px 12px; font-size: 12px; }
.btn-dark     { background: var(--sidebar-bg); color: var(--turmeric); }

/* ---- ALERTS ---- */
.alert {
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 18px;
  border-left: 4px solid;
}
.alert-success { background: var(--green-lt); border-color: var(--green); color: var(--green); }
.alert-error   { background: #FDECEA; border-color: var(--chili); color: var(--chili); }
.alert-warning { background: #FFFDE7; border-color: var(--turmeric); color: #7A6000; }

/* ---- LOW STOCK HIGHLIGHT ---- */
.stock-critical { color: var(--chili); font-weight: 700; }
.stock-low      { color: var(--saffron); font-weight: 600; }
.stock-ok       { color: var(--green); }

/* ---- PAGE HEADER ---- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.page-header h1 {
  font-family: 'Baloo 2', cursive;
  font-size: 24px;
  font-weight: 800;
  color: var(--saffron-dk);
}
.page-header p {
  font-size: 13px;
  color: var(--text-lt);
  margin-top: 2px;
}

/* ---- SEARCH BAR ---- */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.search-bar input, .search-bar select {
  border: 1.5px solid var(--border);
  border-radius: 7px;
  padding: 8px 13px;
  font-size: 14px;
  font-family: 'Noto Sans', sans-serif;
  outline: none;
  background: var(--white);
}
.search-bar input:focus, .search-bar select:focus {
  border-color: var(--saffron);
}

/* ---- PAGINATION ---- */
.pagination {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 16px;
}
.pagination a {
  padding: 6px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s;
}
.pagination a:hover, .pagination a.active {
  background: var(--saffron);
  color: #fff;
  border-color: var(--saffron);
}

/* ---- DIVIDER ---- */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .sidebar { width: 200px; }
  .main-wrap { margin-left: 200px; }
  .page-content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .sidebar { display: none; }
  .main-wrap { margin-left: 0; }
}