/* ============================================================
   sales.css — Sales Dashboard styles
   ============================================================ */

/* ── App layout ─────────────────────────────────────────── */
.sales-app {
  min-height: 100vh;
  background: #f1f5f9;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: #1e293b;
}

/* ── Top bar ─────────────────────────────────────────────── */
.sales-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.5rem;
  background: #1e293b;
  color: white;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 1rem;
}

.sales-topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sales-brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

#sales-restaurant-name {
  color: #94a3b8;
  font-size: 0.85rem;
  font-weight: 400;
}

.sales-topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sales-nav-link {
  color: #94a3b8;
  font-size: 0.82rem;
  text-decoration: none;
  padding: 0.25rem 0.6rem;
  border-radius: 5px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.sales-nav-link:hover {
  background: rgba(255, 255, 255, 0.12);
  color: white;
}

.sales-icon-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.2s;
  flex-shrink: 0;
}

.sales-icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.sales-icon-btn.spinning {
  animation: icon-spin 0.7s linear infinite;
}

@keyframes icon-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

#sales-last-updated {
  font-size: 0.73rem;
  color: #64748b;
  white-space: nowrap;
}

/* ── Filter bar ─────────────────────────────────────────── */
.sales-filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.7rem 1.5rem;
  background: white;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.sales-date-range-btns {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.sales-range-btn {
  padding: 0.3rem 0.85rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 20px;
  background: white;
  color: #475569;
  font-size: 0.79rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.sales-range-btn:hover {
  border-color: #6366f1;
  color: #6366f1;
}

.sales-range-btn.active {
  background: #6366f1;
  border-color: #6366f1;
  color: white;
}

.sales-custom-dates {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.sales-custom-dates.hidden { display: none; }

.sales-custom-dates input[type="date"] {
  padding: 0.28rem 0.5rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.79rem;
  color: #1e293b;
  background: white;
}

.sales-date-sep {
  color: #94a3b8;
  font-size: 0.85rem;
}

.sales-apply-btn {
  padding: 0.3rem 0.8rem;
  background: #6366f1;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.79rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.sales-apply-btn:hover { opacity: 0.88; }

.sales-filter-extras {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.sales-select {
  padding: 0.28rem 0.65rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.79rem;
  color: #475569;
  background: white;
  cursor: pointer;
}

/* ── Main content ───────────────────────────────────────── */
.sales-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ── KPI Grid ───────────────────────────────────────────── */
.sales-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1rem;
}

@media (max-width: 1280px) {
  .sales-kpi-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .sales-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

.sales-kpi-card {
  background: white;
  border-radius: 14px;
  padding: 1rem 1.1rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
  border-left: 4px solid #6366f1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.sales-kpi-card .kpi-value {
  font-size: 1.45rem;
  font-weight: 800;
  color: #1e293b;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.sales-kpi-card .kpi-label {
  font-size: 0.71rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sales-kpi-card .kpi-sub {
  font-size: 0.7rem;
  color: #94a3b8;
  margin-top: 0.2rem;
}

/* KPI colour variants */
.kpi-green  { border-color: #10b981; }
.kpi-indigo { border-color: #6366f1; }
.kpi-amber  { border-color: #f59e0b; }
.kpi-red    { border-color: #ef4444; }
.kpi-purple { border-color: #8b5cf6; }
.kpi-blue   { border-color: #3b82f6; }

/* ── Cards ──────────────────────────────────────────────── */
.sales-card {
  background: white;
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
}

.sales-card-full { width: 100%; }

.sales-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.sales-card-header h3 {
  font-size: 0.91rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
}

.sales-card-sub {
  font-size: 0.73rem;
  color: #94a3b8;
}

.sales-card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sales-action-btn {
  padding: 0.28rem 0.7rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 7px;
  background: white;
  color: #475569;
  font-size: 0.77rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.sales-action-btn:hover {
  border-color: #6366f1;
  color: #6366f1;
}

/* ── Two-column row ─────────────────────────────────────── */
.sales-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 900px) {
  .sales-two-col { grid-template-columns: 1fr; }
}

/* ── Activity Chart ─────────────────────────────────────── */
.sales-activity-chart {
  width: 100%;
  overflow: hidden;
}

.activity-bars-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
}

.activity-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 120px;
  min-width: 460px;
  padding: 0 2px;
}

.activity-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  position: relative;
  min-width: 0;
  cursor: pointer;
}

.activity-bar-col:hover .activity-bar-tip { opacity: 1; }

.activity-bar {
  width: 100%;
  max-width: 26px;
  background: #6366f1;
  border-radius: 3px 3px 0 0;
  transition: opacity 0.15s;
}

.activity-bar:hover { opacity: 0.78; }

.activity-bar.empty {
  background: #e2e8f0;
  min-height: 3px;
}

.activity-bar.peak { background: #4f46e5; }

.activity-bar-tip {
  position: absolute;
  bottom: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: white;
  font-size: 0.67rem;
  font-weight: 600;
  padding: 0.18rem 0.45rem;
  border-radius: 5px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
  z-index: 10;
}

.activity-bar-label {
  font-size: 0.63rem;
  color: #94a3b8;
  margin-top: 4px;
  text-align: center;
  white-space: nowrap;
}

/* ── Breakdown lists ────────────────────────────────────── */
.sales-breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.sales-bdown-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.sales-bdown-label {
  width: 96px;
  font-size: 0.79rem;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.sales-bdown-bar-wrap {
  flex: 1;
  background: #f1f5f9;
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
}

.sales-bdown-bar {
  height: 100%;
  background: #6366f1;
  border-radius: 4px;
  transition: width 0.45s ease;
  min-width: 2px;
}

.sales-bdown-count {
  font-size: 0.7rem;
  color: #94a3b8;
  min-width: 28px;
  text-align: right;
  flex-shrink: 0;
}

.sales-bdown-pct {
  font-size: 0.7rem;
  color: #94a3b8;
  min-width: 34px;
  text-align: right;
  flex-shrink: 0;
}

.sales-bdown-val {
  font-size: 0.82rem;
  font-weight: 700;
  color: #1e293b;
  white-space: nowrap;
  text-align: right;
  min-width: 68px;
  flex-shrink: 0;
}

/* ── Toggle group ───────────────────────────────────────── */
.sales-toggle-group {
  display: flex;
  gap: 0.25rem;
}

.sales-toggle-btn {
  padding: 0.22rem 0.65rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 6px;
  background: white;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  color: #64748b;
  transition: all 0.15s;
}

.sales-toggle-btn.active {
  background: #6366f1;
  border-color: #6366f1;
  color: white;
}

/* ── Top Items ──────────────────────────────────────────── */
.sales-top-items-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sales-item-row {
  display: grid;
  grid-template-columns: 22px 1fr 52px 160px 78px;
  align-items: center;
  gap: 0.55rem;
  padding: 0.3rem 0;
}

.sales-item-rank {
  font-size: 0.7rem;
  font-weight: 700;
  color: #94a3b8;
  text-align: center;
  flex-shrink: 0;
}

.sales-item-rank.gold   { color: #f59e0b; }
.sales-item-rank.silver { color: #94a3b8; }
.sales-item-rank.bronze { color: #b45309; }

.sales-item-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: #1e293b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sales-item-qty {
  font-size: 0.77rem;
  color: #64748b;
  text-align: right;
}

.sales-item-bar-wrap {
  background: #f1f5f9;
  border-radius: 4px;
  height: 7px;
  overflow: hidden;
}

.sales-item-bar {
  height: 100%;
  background: #6366f1;
  border-radius: 4px;
  transition: width 0.45s ease;
}

.sales-item-val {
  font-size: 0.82rem;
  font-weight: 700;
  color: #1e293b;
  text-align: right;
}

/* ── Category grid ──────────────────────────────────────── */
.sales-category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.75rem;
}

.sales-cat-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.sales-cat-name {
  font-size: 0.77rem;
  font-weight: 700;
  color: #475569;
  text-transform: capitalize;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sales-cat-revenue {
  font-size: 0.98rem;
  font-weight: 800;
  color: #1e293b;
}

.sales-cat-meta {
  font-size: 0.7rem;
  color: #94a3b8;
}

/* ── Orders table ───────────────────────────────────────── */
.sales-orders-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.sales-orders-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.sales-orders-table thead {
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 1;
}

.sales-orders-table th {
  padding: 0.6rem 0.85rem;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  border-bottom: 1.5px solid #e2e8f0;
  white-space: nowrap;
}

.sales-orders-table th.num { text-align: right; }

.sales-orders-table td {
  padding: 0.58rem 0.85rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  color: #334155;
}

.sales-orders-table tbody tr:last-child td { border-bottom: none; }

.sales-orders-table tbody tr.ord-row {
  cursor: pointer;
  transition: background 0.1s;
}

.sales-orders-table tbody tr.ord-row:hover { background: #faf9ff; }

/* detail expansion row */
.sales-orders-table tr.ord-detail td {
  background: #f8fafc;
  padding: 0.6rem 1.4rem 0.8rem;
  font-size: 0.78rem;
  color: #64748b;
  border-top: none;
}

.sales-orders-table tr.ord-detail.hidden { display: none; }

.ord-time-date { font-size: 0.68rem; color: #94a3b8; display: block; }

.ord-id {
  font-weight: 700;
  font-size: 0.77rem;
  color: #6366f1;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.ord-expand {
  display: inline-block;
  font-size: 0.63rem;
  color: #94a3b8;
  margin-left: 4px;
  transition: transform 0.2s;
}

.ord-row.open .ord-expand { transform: rotate(90deg); }

.ord-type-badge {
  display: inline-block;
  padding: 0.13rem 0.42rem;
  border-radius: 8px;
  font-size: 0.69rem;
  font-weight: 700;
  background: #ede9fe;
  color: #5b21b6;
  white-space: nowrap;
}

.pm-badge {
  display: inline-block;
  padding: 0.13rem 0.42rem;
  border-radius: 8px;
  font-size: 0.69rem;
  font-weight: 700;
  white-space: nowrap;
}

.pm-badge.cash   { background: #dcfce7; color: #166534; }
.pm-badge.card   { background: #dbeafe; color: #1e40af; }
.pm-badge.upi    { background: #ede9fe; color: #5b21b6; }
.pm-badge.wallet { background: #fef9c3; color: #854d0e; }
.pm-badge.credit { background: #fce7f3; color: #9d174d; }
.pm-badge:not(.cash):not(.card):not(.upi):not(.wallet):not(.credit) {
  background: #f1f5f9;
  color: #334155;
}

.td-num    { text-align: right; }
.td-total  { text-align: right; font-weight: 700; color: #1e293b; }
.td-disc   { text-align: right; color: #ef4444; font-weight: 600; }

.ord-detail-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin-bottom: 0.5rem;
}

.ord-detail-item {
  font-size: 0.79rem;
  color: #334155;
}

.ord-detail-meta {
  font-size: 0.74rem;
  color: #64748b;
  margin-top: 0.25rem;
  border-top: 1px solid #e2e8f0;
  padding-top: 0.35rem;
}

/* ── Empty state ────────────────────────────────────────── */
.sales-empty {
  text-align: center;
  color: #94a3b8;
  font-size: 0.84rem;
  padding: 2rem 0;
}

/* ── Spinner ─────────────────────────────────────────────── */
#sales-spinner {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

#sales-spinner.hidden { display: none; }

.sales-spinner-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  color: white;
  font-size: 0.9rem;
}

/* ── Print ──────────────────────────────────────────────── */
@media print {
  .sales-topbar,
  .sales-filter-bar,
  .sales-card-actions,
  .sales-action-btn,
  .sales-icon-btn,
  .sales-nav-link,
  .sales-toggle-group { display: none !important; }

  .sales-content { padding: 0; }

  .sales-card {
    box-shadow: none;
    border: 1px solid #e2e8f0;
    page-break-inside: avoid;
  }

  .sales-kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .sales-two-col  { grid-template-columns: 1fr 1fr; }
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 640px) {
  .sales-content  { padding: 0.75rem; }
  .sales-filter-bar { padding: 0.6rem 0.75rem; }
  .sales-topbar   { padding: 0.5rem 0.75rem; }
  .sales-filter-extras { margin-left: 0; }

  .sales-item-row {
    grid-template-columns: 20px 1fr 44px 100px 68px;
  }

  .sales-orders-table th:nth-child(4),
  .sales-orders-table td:nth-child(4) { display: none; } /* hide items col on mobile */
}

/* ── Maestro Insights ──────────────────────────────────── */
.sales-maestro-insights { padding: 0.25rem 0; }

.maestro-insights-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.maestro-insights-col-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.maestro-insight-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0;
  border-bottom: 1px solid #f3f4f6;
  gap: 0.5rem;
}

.maestro-insight-row:last-child { border-bottom: none; }

.maestro-insight-name {
  font-size: 0.85rem;
  color: #374151;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70%;
}

.maestro-insight-badge {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: #FF8400;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  min-width: 28px;
  text-align: center;
}

@media (max-width: 640px) {
  .maestro-insights-grid { grid-template-columns: 1fr; }
}

/* ── End-of-Day Summary ─────────────────────────────────── */
.sales-eod-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
.sales-eod-col-title {
  font-size: 0.76rem;
  font-weight: 800;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.7rem;
}
.sales-eod-group-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0.65rem 0 0.2rem;
}
.sales-eod-group-label.soldout-label { color: #dc2626; }
.sales-eod-group-label.going-label   { color: #ea580c; }
.sales-eod-group-label.ok-label      { color: #16a34a; }
.sales-eod-item-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.83rem;
}
.sales-eod-item-row:last-of-type { border-bottom: none; }
.sales-eod-item-name {
  flex: 1;
  font-weight: 500;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.sales-eod-rank {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 800;
  color: #94a3b8;
  width: 14px;
  text-align: center;
}
.sales-eod-badge {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  white-space: nowrap;
}
.sales-eod-badge.soldout { background: #fee2e2; color: #dc2626; }
.sales-eod-badge.going   { background: #fff7ed; color: #ea580c; }
.sales-eod-badge.ok      { background: #f0fdf4; color: #16a34a; }
.sales-eod-item-stats {
  flex-shrink: 0;
  font-size: 0.7rem;
  color: #94a3b8;
}
.sales-eod-suggest {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  color: #6366f1;
}
.sales-eod-suggest-note {
  font-size: 0.68rem;
  color: #6366f1;
  margin-top: 0.65rem;
  font-style: italic;
}
/* Monthly kpis */
.sales-eod-month-kpis {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
  flex-wrap: wrap;
}
.sales-eod-mkpi {
  flex: 1;
  min-width: 60px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.5rem 0.4rem;
  text-align: center;
}
.sales-eod-mkpi-val {
  font-size: 1rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1;
}
.sales-eod-mkpi-label {
  font-size: 0.62rem;
  color: #94a3b8;
  margin-top: 0.2rem;
}
.sales-eod-month-item {
  font-size: 0.78rem;
  color: #475569;
  padding: 0.28rem 0;
  border-bottom: 1px solid #f1f5f9;
}
.sales-eod-month-item strong { color: #0f172a; }
/* Mini bar chart */
.sales-eod-mini-chart-wrap { margin-top: 0.85rem; }
.sales-eod-mini-chart {
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
  height: 66px;
}
.sales-eod-mini-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.18rem;
}
.sales-eod-mini-bar {
  width: 100%;
  background: linear-gradient(180deg, #6366f1, #a5b4fc);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
}
.sales-eod-mini-label {
  font-size: 0.6rem;
  color: #94a3b8;
}
@media (max-width: 640px) {
  .sales-eod-grid { grid-template-columns: 1fr; }
}
