/* ═══════════════════════════════════════════════
   SANTIAGO REFEIÇÕES — VERCEL-INSPIRED DESIGN
   ═══════════════════════════════════════════════ */

:root {
  --bg: #ffffff;
  --text: #171717;
  --text-secondary: #4d4d4d;
  --text-muted: #666666;
  --border: #ebebeb;
  --surface-subtle: #fafafa;
  --accent: #0a72ef;
  --accent-hover: #005bcf;
  --danger: #ff5b4f;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow-border: 0px 0px 0px 1px rgba(0,0,0,0.08);
  --shadow-card: 0px 0px 0px 1px rgba(0,0,0,0.08), 0px 2px 2px rgba(0,0,0,0.04), 0px 8px 8px -8px rgba(0,0,0,0.04);
  --font-sans: 'Segoe UI', -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  --sidebar-width: 240px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  display: flex;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── SIDEBAR ─────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
}

.sidebar-logo {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.5px;
  padding: 0 12px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.sidebar-logo span {
  color: var(--accent);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.15s ease;
  border: none;
  background: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
}

.sidebar-link:hover {
  background: var(--surface-subtle);
  color: var(--text);
}

.sidebar-link.active {
  background: var(--surface-subtle);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-border);
}

.sidebar-link .icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  opacity: 0.8;
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  padding: 12px;
}

/* ─── MAIN ────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 32px 40px;
  max-width: calc(100vw - var(--sidebar-width));
}

.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--text);
}

.page-header p {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ─── CARDS ───────────────────────────────── */
.card {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 24px;
  margin-bottom: 24px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

/* ─── CARDS DE MÉTRICAS ───────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.metric-card {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 20px;
  transition: box-shadow 0.2s ease;
}

.metric-card:hover {
  box-shadow: 0px 0px 0px 1px rgba(0,0,0,0.12), 0px 4px 8px rgba(0,0,0,0.06);
}

.metric-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 4px;
}

.metric-value {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -1px;
  color: var(--text);
}

.metric-value.accent {
  color: var(--accent);
}

.metric-value.success {
  color: var(--success);
}

/* ─── TABELAS ─────────────────────────────── */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 500;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

tbody tr:hover {
  background: var(--surface-subtle);
}

tbody tr:last-child td {
  border-bottom: none;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-subtle);
  color: var(--text-secondary);
}

.tag-success {
  background: #dcfce7;
  color: #166534;
}

.tag-danger {
  background: #fee2e2;
  color: #991b1b;
}

.tag-warning {
  background: #fef3c7;
  color: #92400e;
}

.tag-info {
  background: #dbeafe;
  color: #1e40af;
}

/* ─── BOTÕES ──────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  line-height: 1.4;
  box-shadow: var(--shadow-border);
  background: var(--bg);
  color: var(--text);
}

.btn:hover {
  background: var(--surface-subtle);
}

.btn-primary {
  background: var(--text);
  color: var(--bg);
  box-shadow: none;
}

.btn-primary:hover {
  background: #000;
}

.btn-accent {
  background: var(--accent);
  color: white;
  box-shadow: none;
}

.btn-accent:hover {
  background: var(--accent-hover);
}

.btn-danger {
  background: var(--danger);
  color: white;
  box-shadow: none;
}

.btn-danger:hover {
  background: #e04a3f;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-icon {
  padding: 6px;
  min-width: 32px;
  justify-content: center;
}

/* ─── FORMULÁRIOS ─────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-border);
  outline: none;
  transition: box-shadow 0.15s ease;
}

.form-control:focus {
  box-shadow: 0px 0px 0px 2px var(--accent);
}

.form-control::placeholder {
  color: #808080;
}

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

textarea.form-control {
  min-height: 80px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: flex-end;
}

/* ─── TOGGLE (ativo/inativo) ──────────────── */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}

.toggle-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* ─── MODAL ───────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 32px;
  position: relative;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-header h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  line-height: 1;
  border-radius: 4px;
}

.modal-close:hover {
  color: var(--text);
  background: var(--surface-subtle);
}

/* ─── TOAST / NOTIFICAÇÃO ─────────────────── */
.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  background: var(--text);
  color: var(--bg);
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  z-index: 2000;
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 12px;
}

.toast.success {
  background: var(--success);
  color: white;
}

.toast.error {
  background: var(--danger);
  color: white;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ─── ITENS DE SAÍDA DINÂMICOS ────────────── */
.item-linha {
  display: grid;
  grid-template-columns: 1fr 80px 100px 40px;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
  padding: 8px;
  background: var(--surface-subtle);
  border-radius: var(--radius-sm);
}

.item-linha .item-prato select {
  width: 100%;
}

.item-linha .item-qtd input {
  width: 80px;
  text-align: center;
}

.item-linha .item-valor {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.item-linha .item-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 18px;
  padding: 4px;
}

.item-linha .item-remove:hover {
  color: var(--danger);
}

#total-saida {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}

/* ─── CHECKBOX SWITCH ─────────────────────── */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #ccc;
  transition: .2s;
  border-radius: 20px;
}

.switch .slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background: white;
  transition: .2s;
  border-radius: 50%;
}

.switch input:checked + .slider {
  background: var(--accent);
}

.switch input:checked + .slider:before {
  transform: translateX(16px);
}

/* ─── BADGE STATUS ────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-ativo { background: #dcfce7; color: #166534; }
.badge-inativo { background: #fee2e2; color: #991b1b; }

/* ─── FILTROS ─────────────────────────────── */
.filtros-bar {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.filtros-bar .form-group {
  margin-bottom: 0;
  min-width: 160px;
}

/* ─── RESPONSIVO ──────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    min-height: auto;
    position: relative;
    padding: 16px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .sidebar-link { font-size: 13px; padding: 6px 10px; }
  .main-content {
    margin-left: 0;
    padding: 20px;
    max-width: 100%;
  }
  .form-row, .form-row-3 {
    grid-template-columns: 1fr;
  }
  .metrics-grid {
    grid-template-columns: 1fr 1fr;
  }
  .filtros-bar {
    flex-direction: column;
  }
  .filtros-bar .form-group {
    min-width: 100%;
  }
}

/* ─── SCROLLBAR ───────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d4d4d4; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a3a3a3; }

/* ─── EMPTY STATE ─────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 20px;
}

/* ─── DETALHE MODAL ───────────────────────── */
.detalhe-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.detalhe-item label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 4px;
}

.detalhe-item span {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

/* ─── FLUXO FINANCEIRO ────────────────────── */
.fluxo-card-principal {
  border-top: 4px solid var(--accent);
}

.fluxo-total-dia {
  text-align: center;
  padding: 28px 0 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.fluxo-total-valor {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: -2px;
  color: var(--text);
  line-height: 1.1;
}

.fluxo-total-label {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 400;
}

.fluxo-detalhes {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.fluxo-linha {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fluxo-linha-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fluxo-linha-icone {
  font-size: 18px;
  width: 28px;
  text-align: center;
}

.fluxo-linha-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
}

.fluxo-linha-pct {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 40px;
  text-align: right;
}

.fluxo-linha-valor {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  min-width: 100px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.fluxo-linha-bar {
  width: 100%;
  height: 8px;
  background: var(--surface-subtle);
  border-radius: 99px;
  overflow: hidden;
}

.fluxo-linha-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.6s ease;
}

.fluxo-vazio {
  text-align: center;
  padding: 24px 0;
  color: var(--text-muted);
  font-size: 14px;
}
