/* ============================================================
   Cafés Myway Dashboard — style.css  (tema claro profesional)
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --coffee-dark:  #3d2314;   /* sidebar fondo */
  --coffee:       #6f4e37;   /* acento principal */
  --coffee-hover: #5a3d2b;   /* acento hover */
  --coffee-light: #a07850;   /* acento secundario */
  --coffee-pale:  #f5ede4;   /* highlight suave */
  --bg:           #f1f5f9;   /* fondo página */
  --surface:      #ffffff;   /* tarjetas */
  --surface2:     #f8fafc;   /* tabla head, inputs */
  --border:       #e2e8f0;   /* bordes */
  --text:         #1e293b;   /* texto principal */
  --text-muted:   #64748b;   /* texto secundario */
  --sidebar-w:    240px;
  --radius:       10px;
  --shadow:       0 1px 3px rgba(0,0,0,0.07), 0 4px 12px rgba(0,0,0,0.05);
}

html, body { height: 100%; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ---- LAYOUT ---- */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--coffee-dark);
  border-right: none;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.logo-icon { font-size: 28px; }
.logo-name  { font-weight: 700; font-size: 15px; color: #fff; }
.logo-sub   { font-size: 11px; color: rgba(255,255,255,0.45); }

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,0.60);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: var(--coffee); color: #fff; }
.nav-icon { font-size: 16px; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sync-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: rgba(255,255,255,0.40);
}
.sync-status.stale { color: #fbbf24; }

.btn-sync {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.80);
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
  width: 100%;
}
.btn-sync:hover { background: var(--coffee); border-color: var(--coffee); color: #fff; }

.btn-logout {
  display: block;
  text-align: center;
  color: rgba(255,255,255,0.35);
  font-size: 12px;
  text-decoration: none;
  padding: 4px;
}
.btn-logout:hover { color: rgba(255,255,255,0.70); }

/* ---- MAIN ---- */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.page-header {
  padding: 24px 28px 0;
}
.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.page-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}
.page-body {
  padding: 20px 28px 40px;
  flex: 1;
}

/* ---- KPI GRID ---- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: var(--shadow);
  transition: border-color .2s, box-shadow .2s;
}
.kpi-card:hover { border-color: var(--coffee-light); box-shadow: 0 4px 16px rgba(111,78,55,0.12); }
.kpi-icon  { font-size: 22px; line-height: 1; }
.kpi-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.kpi-value { font-size: 20px; font-weight: 700; color: var(--text); margin-top: 2px; }
.kpi-sub   { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.kpi-change { font-size: 12px; margin-top: 4px; }
.kpi-change.up   { color: #16a34a; }
.kpi-change.down { color: #dc2626; }

/* ---- CHARTS ---- */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.chart-card.wide { grid-column: 1 / -1; }
.chart-header { margin-bottom: 12px; }
.chart-header h3 { font-size: 14px; font-weight: 600; color: var(--text); }

/* ---- BOTTOM GRID ---- */
.bottom-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

/* ---- TABLES ---- */
.table-wrapper { overflow-x: auto; }
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.table-card .chart-header { padding: 14px 16px 0; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead tr {
  background: var(--surface2);
  border-bottom: 2px solid var(--border);
}
.data-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
}
.data-table th a { color: var(--text-muted); text-decoration: none; }
.data-table th a:hover { color: var(--coffee); }
.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.data-table tbody tr:nth-child(even) { background: #fafbfc; }
.data-table tbody tr:hover { background: var(--coffee-pale); }
.data-table tbody tr:last-child td { border-bottom: none; }

.td-num   { text-align: right; font-variant-numeric: tabular-nums; }
.td-score { text-align: center; font-weight: 700; }
.bold     { font-weight: 700; }
.td-email { font-size: 12px; color: var(--text-muted); }
.td-name  { min-width: 140px; }
.td-sub   { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.td-products { max-width: 260px; }
.empty    { text-align: center; color: var(--text-muted); padding: 24px; }

/* ---- BADGE ---- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* ---- STOCK STATUS BADGES ---- */
.status-ok       { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.status-low      { background: #fef9c3; color: #a16207; border: 1px solid #fde047; }
.status-critical { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }

/* ---- FILTER BAR ---- */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.filter-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.filter-input, .filter-select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}
.filter-input:focus, .filter-select:focus {
  border-color: var(--coffee);
  box-shadow: 0 0 0 3px rgba(111,78,55,0.10);
}
.filter-input { min-width: 220px; }
.result-count { color: var(--text-muted); font-size: 13px; }

/* ---- SEGMENT PILLS ---- */
.segment-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.pill {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: all .15s;
}
.pill:hover { border-color: var(--coffee-light); color: var(--text); }
.pill.active {
  background: var(--coffee);
  border-color: var(--coffee);
  color: #fff;
}

/* ---- BUTTONS ---- */
.btn-primary {
  background: var(--coffee);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background .15s;
}
.btn-primary:hover { background: var(--coffee-hover); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: border-color .15s;
}
.btn-secondary:hover { border-color: var(--coffee-light); }

.btn-sm {
  background: var(--surface2);
  color: var(--coffee);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 5px;
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
  transition: all .15s;
}
.btn-sm:hover { background: var(--coffee-pale); border-color: var(--coffee-light); }

/* ---- FORM CARDS (stock / profit) ---- */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.form-card h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  align-items: end;
}
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-muted);
}
.form-input, .form-select, .form-textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
  transition: border-color .15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--coffee);
  box-shadow: 0 0 0 3px rgba(111,78,55,0.10);
  background: var(--surface);
}
.form-textarea { resize: vertical; min-height: 60px; }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ---- PROFIT FORM TABLE ---- */
.cost-table { width: 100%; border-collapse: collapse; }
.cost-table th {
  padding: 8px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}
.cost-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.cost-table tr:last-child td { border-bottom: none; }
.cost-table .cat-label { font-weight: 500; color: var(--text); font-size: 13px; }
.cost-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 5px;
  font-size: 13px;
  width: 120px;
  outline: none;
  text-align: right;
}
.cost-input:focus { border-color: var(--coffee); background: var(--surface); }
.note-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 5px;
  font-size: 12px;
  width: 100%;
  outline: none;
}
.note-input:focus { border-color: var(--coffee); }

/* ---- PAGINATION ---- */
.pagination {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-top: 16px;
}
.page-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  transition: all .15s;
}
.page-btn.active { background: var(--coffee); color: #fff; border-color: var(--coffee); }
.page-btn:hover:not(.active) { border-color: var(--coffee-light); color: var(--text); }

/* ---- SYNC OVERLAY ---- */
.sync-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.sync-overlay.hidden { display: none; }
.sync-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  text-align: center;
  min-width: 280px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.sync-spinner {
  font-size: 48px;
  animation: spin 2s linear infinite;
  display: block;
  margin-bottom: 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.sync-sub { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

/* ---- ALERT BANNER ---- */
.alert-banner {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-warning { background: #fef9c3; border: 1px solid #fde047; color: #92400e; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.alert-success { background: #dcfce7; border: 1px solid #86efac; color: #15803d; }

/* ---- DETAIL PAGE ---- */
.detail-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 14px;
  align-items: start;
}
.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow);
}
.detail-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--coffee);
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}
.detail-name  { font-size: 18px; font-weight: 700; }
.detail-email { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.detail-meta  { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.rfm-badge {
  margin: 16px 0;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid;
}
.rfm-badge-label { font-size: 15px; font-weight: 700; }
.rfm-badge-desc  { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.rfm-scores {
  display: flex;
  justify-content: center;
  gap: 20px;
}
.score-item  { text-align: center; }
.score-num   { font-size: 28px; font-weight: 800; }
.score-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; }

.detail-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  align-content: start;
}
.mini-kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  box-shadow: var(--shadow);
}
.mini-kpi-val   { font-size: 18px; font-weight: 700; }
.mini-kpi-label { font-size: 11px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; }

.product-row { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.product-name { font-size: 12px; }
.product-qty  { font-size: 11px; color: var(--text-muted); }

/* ---- LOGIN ---- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}
.login-logo  { font-size: 52px; margin-bottom: 8px; }
.login-title { font-size: 22px; font-weight: 700; color: var(--text); }
.login-sub   { color: var(--text-muted); font-size: 13px; margin-top: 4px; margin-bottom: 28px; }
.login-error {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #b91c1c;
  padding: 10px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  text-align: center;
  transition: border-color .15s;
}
.login-input:focus { border-color: var(--coffee); box-shadow: 0 0 0 3px rgba(111,78,55,0.10); }
.login-btn {
  background: var(--coffee);
  color: #fff;
  border: none;
  padding: 12px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.login-btn:hover { background: var(--coffee-hover); }

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  .sidebar  { display: none; }
  .charts-grid, .bottom-grid { grid-template-columns: 1fr; }
  .chart-card.wide { grid-column: auto; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
