/* ══════════════════════════════════════════════════════════════════════
   India Chillies — Dashboard CSS  (professional trading terminal)
   ══════════════════════════════════════════════════════════════════════ */

/* ── Design tokens ───────────────────────────────────────────────────── */
:root {
  --bg:        #F0F4F8;
  --surface:   #FFFFFF;
  --border:    #E2E8F0;
  --border-2:  #CBD5E1;
  --text:      #0F172A;
  --text-2:    #475569;
  --muted:     #94A3B8;
  --orange:    #F97316;
  --orange-dk: #EA580C;
  --orange-bg: #FFF7ED;
  --green:     #22C55E;
  --red:       #EF4444;
  --blue:      #3B82F6;
  --radius:    12px;
  --radius-lg: 16px;
  --sh:        0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --sh-md:     0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.05);
  --sh-lg:     0 10px 30px rgba(0,0,0,.12), 0 4px 8px rgba(0,0,0,.06);
}

/* ── Reset / base ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--text); }
a { text-decoration: none; color: inherit; }
button { font-family: inherit; }

/* ── Loading overlay ─────────────────────────────────────────────────── */
#mmi-loading {
  position: fixed; inset: 0; z-index: 9999;
  background: linear-gradient(135deg, #FFF7ED 0%, #fff 50%, #FFFBEB 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; transition: opacity .3s;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid #FED7AA;
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Page wrapper ────────────────────────────────────────────────────── */
#mmi-app { min-height: 100vh; background: var(--bg); }

/* ═══════════════════════════════════════════════════════════════════════
   HEADER / NAV
   ═══════════════════════════════════════════════════════════════════════ */
.dash-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.dash-header-inner {
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; height: 56px; max-width: 100%;
}

/* Logo */
.dash-logo { display: flex; align-items: center; gap: 8px; flex-shrink: 0; cursor: pointer; }
.dash-logo-text {
  font-weight: 800; font-size: 14px; color: var(--text);
  letter-spacing: -.03em;
}
.dash-logo-text span { color: var(--orange); }
.dash-logo-badge {
  font-size: 9px; font-weight: 700; padding: 2px 7px;
  border-radius: 9999px; background: var(--orange-bg);
  color: var(--orange-dk); border: 1px solid #FED7AA;
  letter-spacing: .04em; text-transform: uppercase;
}

/* Market filter pills */
.market-filters { display: flex; gap: 6px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.market-filters::-webkit-scrollbar { display: none; }
.mkt-pill {
  font-size: 11px; font-weight: 700;
  padding: 5px 12px; border-radius: 9999px;
  border: 1.5px solid var(--mc, var(--border));
  background: transparent; color: var(--muted);
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.mkt-pill.active {
  background: var(--mc, var(--orange));
  border-color: var(--mc, var(--orange));
  color: #fff;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--mc, var(--orange)) 30%, transparent);
}
.mkt-pill:hover:not(.active) { border-color: var(--mc, var(--border)); color: var(--mc, var(--text)); }

/* User section */
.dash-user {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0; margin-left: auto;
}
.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 9999px; padding: 4px 12px 4px 4px; cursor: default;
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--orange), var(--orange-dk));
  color: #fff; font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-name {
  font-size: 12px; font-weight: 600; color: var(--text);
  max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dash-logout-btn {
  font-size: 11px; font-weight: 700; padding: 5px 12px;
  border-radius: 8px; border: 1.5px solid var(--border);
  background: transparent; color: var(--text-2); cursor: pointer;
  transition: all .15s;
}
.dash-logout-btn:hover { background: #FEF2F2; border-color: #FECACA; color: var(--red); }
.dash-logout-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ═══════════════════════════════════════════════════════════════════════
   KPI STRIP
   ═══════════════════════════════════════════════════════════════════════ */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
@media (max-width: 1024px) { .kpi-strip { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px)  { .kpi-strip { grid-template-columns: repeat(2, 1fr); padding: 12px; } }

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: all .18s;
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: var(--kpi-color, var(--orange));
  border-radius: 0;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--sh-md); border-color: var(--border-2); }

.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.kpi-icon {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.kpi-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.kpi-value {
  font-size: 22px; font-weight: 800; color: var(--text);
  font-variant-numeric: tabular-nums; line-height: 1.1;
  margin-bottom: 2px;
}
.kpi-sub { font-size: 11px; color: var(--muted); }

.badge-change {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 9999px;
}
.badge-up   { background: #D1FAE5; color: #065F46; }
.badge-down { background: #FEE2E2; color: #991B1B; }

/* ═══════════════════════════════════════════════════════════════════════
   MAIN DASHBOARD GRID
   ═══════════════════════════════════════════════════════════════════════ */
.dash-body { padding: 16px 20px 40px; max-width: 1600px; margin: 0 auto; }
@media (max-width: 640px) { .dash-body { padding: 12px 12px 32px; } }

.dash-row   { display: grid; gap: 16px; margin-bottom: 16px; }
.dash-row-1 { grid-template-columns: 1fr; }
.dash-row-2 { grid-template-columns: 1fr 1fr; }
.dash-row-2-3 { grid-template-columns: 2fr 1fr; }
.dash-row-1-2 { grid-template-columns: 1fr 2fr; }
@media (max-width: 1024px) { .dash-row-2, .dash-row-2-3, .dash-row-1-2 { grid-template-columns: 1fr; } }

/* ── Panel (card) ────────────────────────────────────────────────────── */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--sh);
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 0; gap: 12px;
  flex-wrap: wrap;
}
.panel-title {
  font-size: 13px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 6px;
}
.panel-title-icon { font-size: 14px; }
.panel-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.panel-body { padding: 12px 18px 18px; }
.panel-body-flush { padding: 0; }

/* ── Date tabs ───────────────────────────────────────────────────────── */
.date-tabs { display: flex; gap: 4px; }
.date-tab {
  font-size: 11px; font-weight: 600; padding: 4px 10px;
  border-radius: 8px; border: 1px solid transparent;
  background: transparent; color: var(--muted); cursor: pointer; transition: all .12s;
}
.date-tab.active { background: var(--orange-bg); color: var(--orange-dk); border-color: #FED7AA; }
.date-tab:hover:not(.active) { background: var(--bg); }

/* ── Variety pills ───────────────────────────────────────────────────── */
.variety-strip {
  display: flex; align-items: center; gap: 8px; padding: 10px 18px;
  border-top: 1px solid var(--border); flex-wrap: wrap;
}
.variety-search-wrap { position: relative; }
.variety-search {
  font-size: 12px; padding: 5px 28px 5px 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); outline: none;
  width: 140px; transition: all .15s;
}
.variety-search:focus { border-color: var(--orange); background: #fff; }
.variety-search-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  font-size: 14px; color: var(--muted); background: none; border: none; cursor: pointer;
  display: none;
}
#variety-pills { display: flex; flex-wrap: wrap; gap: 5px; flex: 1; }
.var-pill {
  font-size: 11px; font-weight: 600; padding: 3px 10px;
  border-radius: 9999px; border: 1px solid var(--border);
  background: transparent; color: var(--text-2); cursor: pointer; transition: all .12s;
  white-space: nowrap;
}
.var-pill.active { background: var(--orange); border-color: var(--orange); color: #fff; }
.var-pill:hover:not(.active) { border-color: var(--orange); color: var(--orange); }

/* Range toggle */
.range-toggle-wrap { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); white-space: nowrap; }
input[type="checkbox"] { accent-color: var(--orange); }

/* Trend legend */
#trend-legend { display: flex; flex-wrap: wrap; gap: 12px; padding: 0 18px 10px; }

/* ApexCharts container */
.apex-wrap { padding: 0 8px 8px; }

/* ── Rates table ─────────────────────────────────────────────────────── */
.rates-controls {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.rates-filter-select {
  font-size: 12px; padding: 5px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg); color: var(--text);
  outline: none; cursor: pointer;
}
.rates-filter-select:focus { border-color: var(--orange); }
.rates-table-wrap { overflow-x: auto; }
.rates-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.rates-table th {
  padding: 8px 12px; text-align: left;
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
  background: var(--bg); border-bottom: 1px solid var(--border);
  user-select: none;
}
.rates-table th:hover { color: var(--text); }
.rates-table td {
  padding: 9px 12px; border-bottom: 1px solid var(--border);
  color: var(--text);
}
.rates-table tbody tr:last-child td { border-bottom: none; }
.rates-table tbody tr:hover td { background: var(--bg); }

/* ── Movers list ─────────────────────────────────────────────────────── */
#movers-list { max-height: 340px; overflow-y: auto; }

/* ── Market comparison table ─────────────────────────────────────────── */
.mktcmp-table-wrap { overflow-x: auto; }
.mktcmp-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
}
.mktcmp-table th {
  padding: 8px 12px; text-align: right; font-size: 11px; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.mktcmp-table th:first-child { text-align: left; }
.mktcmp-table td {
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  text-align: right; font-variant-numeric: tabular-nums;
}
.mktcmp-table td:first-child { text-align: left; font-weight: 700; }
.mktcmp-table tbody tr:hover td { background: var(--bg); }

/* ── Insights ────────────────────────────────────────────────────────── */
.insights-grid { display: flex; flex-direction: column; gap: 10px; }
.insight-card {
  padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--border); border-left-width: 3px;
  background: var(--surface);
}

/* ── Weather ─────────────────────────────────────────────────────────── */
.weather-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }
@media (max-width: 1024px) { .weather-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 480px)  { .weather-grid { grid-template-columns: 1fr 1fr; } }
.weather-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; text-align: center;
}
.weather-city  { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.weather-temp  { font-size: 26px; font-weight: 800; color: var(--text); line-height: 1; }
.weather-desc  { font-size: 11px; color: var(--text-2); margin-top: 4px; }
.weather-forecast { display: flex; justify-content: center; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }

/* ── Sentiment calendar ──────────────────────────────────────────────── */
.cal-year      { margin-bottom: 16px; }
.cal-year-label { font-size: 12px; font-weight: 700; color: var(--text-2); margin-bottom: 6px; }
.cal-months    { display: flex; flex-wrap: wrap; gap: 8px; }
.cal-month     { }
.cal-month-label { font-size: 9px; font-weight: 600; color: var(--muted); text-align: center; margin-bottom: 3px; letter-spacing: .04em; }
.cal-days      { display: grid; grid-template-columns: repeat(7,10px); gap: 2px; }
.cal-day       { width: 10px; height: 10px; border-radius: 2px; cursor: help; }

/* ── Footer ──────────────────────────────────────────────────────────── */
.dash-footer {
  text-align: center; padding: 16px 20px;
  font-size: 11px; color: var(--muted); border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ── Modal ───────────────────────────────────────────────────────────── */
#kpi-modal {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(15,23,42,.5); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-box {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 28px; max-width: 480px; width: 100%;
  box-shadow: var(--sh-lg); position: relative;
  max-height: 80vh; overflow-y: auto;
}
.modal-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px; }
.modal-icon-wrap { font-size: 24px; line-height: 1; }
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none; font-size: 20px; cursor: pointer;
  color: var(--muted); transition: color .12s;
}
.modal-close:hover { color: var(--text); }
.modal-title   { font-size: 17px; font-weight: 800; color: var(--text); }
.modal-sub     { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── Scrollbar (thin) ────────────────────────────────────────────────── */
::-webkit-scrollbar        { width: 5px; height: 5px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: var(--border-2); border-radius: 9999px; }
