/* ===== Mon Chérie — estilos ===== */
:root {
  --bg: #fbf7f4;
  --surface: #ffffff;
  --border: #ecdfe2;
  --text: #3a2e30;
  --muted: #927e82;
  --rose: #c64f78;        /* acento principal */
  --rose-dark: #a63a60;
  --rose-soft: #fbe9ef;
  --ok: #2e9b6b;
  --danger: #d24b4b;
  --radius: 12px;
  --shadow: 0 10px 30px -16px rgba(120, 50, 70, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.55;
}

/* ---- Topbar ---- */
#topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.7rem 1.4rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}
.brand {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}
.brand span { color: var(--rose); }
.brand.big { font-size: 2rem; }
#topbar nav {
  display: flex;
  gap: 0.3rem;
  flex: 1;
}
#topbar nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
}
#topbar nav a:hover { background: var(--rose-soft); color: var(--rose-dark); }
#topbar nav a.active { background: var(--rose); color: #fff; }
.user { display: flex; align-items: center; gap: 0.7rem; }
#user-name { color: var(--muted); font-size: 0.9rem; }

/* ---- Layout ---- */
#view { max-width: 1080px; margin: 0 auto; padding: 1.6rem 1.4rem 4rem; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
}
.section-head h2, .detail-head h2 { margin: 0; font-size: 1.5rem; }
.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0.8rem 0 1.2rem; }
.loading { color: var(--muted); padding: 2rem 0; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0.6rem 0 0; }
.empty { color: var(--muted); text-align: center; padding: 1.4rem; }

/* ---- Botones ---- */
.btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.5rem 0.9rem;
  border-radius: 9px;
  font-weight: 600;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { border-color: var(--rose); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--rose); border-color: var(--rose); color: #fff; }
.btn.primary:hover { background: var(--rose-dark); border-color: var(--rose-dark); }
.btn.danger { color: var(--danger); border-color: #ecc8c8; }
.btn.danger:hover { background: #fbeaea; border-color: var(--danger); }
.btn.small { padding: 0.3rem 0.6rem; font-size: 0.85rem; }
.btn.full { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: default; }

/* ---- Paneles / formularios ---- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1.4rem;
  box-shadow: var(--shadow);
}
.panel h3 { margin: 0 0 0.9rem; font-size: 1.1rem; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.8rem 1rem;
}
label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
label.full { grid-column: 1 / -1; }
input, select, textarea {
  font: inherit;
  color: var(--text);
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--rose-soft); border-color: var(--rose); }
.form-actions { display: flex; gap: 0.6rem; margin-top: 1rem; }

/* ---- Tablas ---- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 0.6rem 0.9rem; text-align: left; border-bottom: 1px solid var(--border); }
table.data th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); background: #fdf6f8; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { text-align: right; white-space: nowrap; display: flex; gap: 0.4rem; justify-content: flex-end; }
.strong { font-weight: 700; }
.inline-num { width: 90px; text-align: right; display: inline-block; }

/* ---- Detalle de receta ---- */
.detail-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.4rem; align-items: start; }
.add-item { display: flex; gap: 0.5rem; margin-bottom: 0.9rem; flex-wrap: wrap; }
.add-item select { flex: 1; min-width: 140px; }
.add-item input { width: 120px; }
.escandallo-box dl.kv { display: grid; grid-template-columns: 1fr auto; gap: 0.35rem 1rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.kv dd.big { font-size: 1.3rem; color: var(--rose-dark); }

@media (max-width: 760px) {
  .detail-grid { grid-template-columns: 1fr; }
}

/* ---- Login ---- */
#login-root {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: radial-gradient(60% 60% at 50% 20%, var(--rose-soft), var(--bg));
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 2rem;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-card .sub { color: var(--muted); margin: 0.2rem 0 1.4rem; }
.login-card form { display: flex; flex-direction: column; gap: 0.9rem; text-align: left; }
.login-card .err { color: var(--danger); font-size: 0.85rem; margin: 0; text-align: center; }

/* ---- Toasts ---- */
#toasts { position: fixed; bottom: 1.2rem; right: 1.2rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 100; }
.toast {
  background: #2c2326;
  color: #fff;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  max-width: 360px;
  box-shadow: 0 12px 28px -10px rgba(0,0,0,0.4);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.ok { border-left: 4px solid var(--ok); }
.toast.error { border-left: 4px solid var(--danger); }

/* ---- Fase 2: pestañas, dashboard, pedidos ---- */
.head-actions { display: flex; gap: 0.6rem; }

/* Pestañas (Base de datos) */
.tabs { display: flex; gap: 0.3rem; border-bottom: 1px solid var(--border); margin-bottom: 1.4rem; flex-wrap: wrap; }
.tab {
  font: inherit; cursor: pointer; border: 0; background: none; color: var(--muted);
  padding: 0.6rem 0.9rem; border-bottom: 2px solid transparent; font-weight: 600;
}
.tab:hover { color: var(--rose-dark); }
.tab.active { color: var(--rose-dark); border-bottom-color: var(--rose); }

/* Cards del dashboard */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.6rem; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 0.2rem;
}
.card-label { color: var(--muted); font-size: 0.82rem; }
.card-value { font-size: 1.7rem; font-weight: 800; color: var(--rose-dark); font-variant-numeric: tabular-nums; }
.card-sub { color: var(--muted); font-size: 0.78rem; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; align-items: start; }
@media (max-width: 760px) { .dash-grid { grid-template-columns: 1fr; } }
.warn { color: var(--danger); font-weight: 700; }

/* Badges de estado / cobro */
.badge {
  display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 0.15rem 0.55rem;
  border-radius: 999px; border: 1px solid transparent; white-space: nowrap;
}
.estado-pendiente  { background: #fff4e0; color: #9a6a00; border-color: #f0d9a8; }
.estado-confirmado { background: #e6f0ff; color: #2c5bb8; border-color: #c3d8f5; }
.estado-entregado  { background: #e7f7ee; color: #1f7a4d; border-color: #bfe6cf; }
.estado-cancelado  { background: #f1eef0; color: #897f84; border-color: #ddd5d8; }
.estado-hecha      { background: #e7f7ee; color: #1f7a4d; border-color: #bfe6cf; }
.estado-cancelada  { background: #f1eef0; color: #897f84; border-color: #ddd5d8; }
.cobro-impago  { background: #fdeaea; color: #b23b3b; border-color: #f0c8c8; }
.cobro-parcial { background: #fff4e0; color: #9a6a00; border-color: #f0d9a8; }
.cobro-cobrado { background: #e7f7ee; color: #1f7a4d; border-color: #bfe6cf; }

/* Compra multi-línea */
.sub-h { margin: 1.2rem 0 0.6rem; font-size: 0.95rem; color: var(--muted); }
.linea { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.linea select { flex: 1; min-width: 150px; }
.linea input { width: 130px; }
.compra-total { margin: 0.8rem 0; font-size: 1.05rem; }
.compra-total strong { color: var(--rose-dark); }

/* Acciones de estado del pedido */
.estado-actions { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 0.5rem; }
.estado-botones { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ---- Motor de búsqueda ---- */
.toolbar { margin-bottom: 1rem; }
.buscador { display: flex; gap: 0.5rem; }
.buscador-input {
  flex: 1;
  min-width: 160px;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font: inherit;
}
.buscador-input:focus { outline: 2px solid var(--rose-soft); border-color: var(--rose); }
.buscador-input.filtro { width: 100%; }

/* línea de compra: nombre del insumo elegido (en vez de un select) */
.linea-nombre { flex: 1; min-width: 150px; display: flex; align-items: center; font-weight: 600; }

/* Modal / ventana emergente */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44, 35, 38, 0.45);
  display: grid;
  place-items: center;
  padding: 1.5rem;
  z-index: 200;
}
.modal {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 460px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.2rem 0.6rem; }
.modal-head h3 { margin: 0; font-size: 1.1rem; }
.modal-close { border: 0; background: none; font-size: 1.1rem; cursor: pointer; color: var(--muted); }
.modal-close:hover { color: var(--text); }
.modal-search { margin: 0 1.2rem 0.6rem; padding: 0.5rem 0.7rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; }
.modal-search:focus { outline: 2px solid var(--rose-soft); border-color: var(--rose); }
.modal-list { list-style: none; margin: 0; padding: 0 0.6rem 0.8rem; overflow-y: auto; }
.modal-item { padding: 0.6rem 0.7rem; border-radius: 8px; cursor: pointer; }
.modal-item:hover { background: var(--rose-soft); }
.modal-empty { padding: 0.8rem 0.7rem; color: var(--muted); text-align: center; }

/* Tag de categoría e info secundaria */
.badge.cat-badge { background: var(--rose-soft); color: var(--rose-dark); border-color: #f0d9e2; }
.muted { color: var(--muted); font-size: 0.85em; }

/* Banner de factibilidad del pedido */
.banner {
  padding: 0.7rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.92rem;
  font-weight: 600;
}
.banner.ok { background: #e7f7ee; color: #1f7a4d; border: 1px solid #bfe6cf; }
.banner.warn { background: #fdeaea; color: #b23b3b; border: 1px solid #f0c8c8; }
