/* =====================================================================
   PIZZABROSA — PANEL DE ADMINISTRACIÓN
   ===================================================================== */

:root {
  --char: #3e090a;
  --char-2: #240d09;
  --crema: #f7ecd3;
  --crema-dim: #d9c6a0;
  --tomato: #c1272d;
  --tomato-dark: #8a1c1a;
  --basil: #5c8a5a;
  --gold: #d9a544;
  --gold-light: #f0cd85;
  --line: rgba(247, 236, 211, 0.14);
  --panel: #2c0f0c;
  --panel-2: #38130f;
  --radius: 14px;
  --display: "Fraunces", serif;
  --body: "Inter", sans-serif;
  --mono: "JetBrains Mono", monospace;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

/* El atributo [hidden] debe ganar siempre: hay reglas con display:flex
   (.login-view, .app) que, por ser CSS de autor, pisaban el display:none
   del navegador y hacían que el panel y el login se vieran a la vez. */
[hidden] { display: none !important; }

html, body { max-width: 100%; overflow-x: hidden; }

body {
  margin: 0;
  font-family: var(--body);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(193, 39, 45, 0.25), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(217, 165, 68, 0.15), transparent 55%),
    var(--char-2);
  color: var(--crema);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
h1, h2, h3 { font-family: var(--display); margin: 0; font-weight: 700; }
p { margin: 0; }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------------- Banner de modo ---------------- */
.mode-banner {
  background: linear-gradient(90deg, rgba(217, 165, 68, 0.9), rgba(217, 165, 68, 0.7));
  color: var(--char-2);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  padding: 0.5rem 1rem;
}

/* ---------------- Botones ---------------- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.4rem;
  border-radius: 999px;
  border: 1px solid rgba(217, 165, 68, 0.4);
  background: linear-gradient(180deg, var(--tomato) 0%, var(--tomato-dark) 100%);
  color: var(--crema);
  font-weight: 700;
  font-size: 0.9rem;
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(193, 39, 45, 0.4); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--crema);
  font-size: 0.85rem;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s;
}
.ghost-btn:hover { border-color: var(--gold); background: rgba(217, 165, 68, 0.1); }
.ghost-btn.danger { border-color: rgba(193, 39, 45, 0.6); color: #ffb4ae; }
.ghost-btn.danger:hover { background: rgba(193, 39, 45, 0.2); }

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.4rem;
  border-radius: 999px;
  border: 1px solid rgba(193, 39, 45, 0.5);
  background: var(--tomato-dark);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
}
.btn-danger:hover { background: var(--tomato); }

/* =====================================================================
   LOGIN
   ===================================================================== */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.2rem;
}

.login-card {
  width: min(420px, 100%);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2.2rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.login-brand { text-align: center; margin-bottom: 1.6rem; }
.login-brand img {
  width: 74px; height: 74px; object-fit: contain; margin: 0 auto 0.8rem;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(217, 165, 68, 0.55), 0 0 22px rgba(217, 165, 68, 0.3);
}
.login-brand h1 { font-size: 1.7rem; color: var(--gold-light); }
.login-brand p { color: var(--crema-dim); font-size: 0.85rem; margin-top: 0.2rem; }

.login-card form { display: flex; flex-direction: column; gap: 0.35rem; }
.login-card label { font-size: 0.78rem; font-weight: 600; color: var(--crema-dim); margin-top: 0.6rem; }
.login-card input {
  width: 100%;
  padding: 0.8rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--crema);
  font-size: 0.95rem;
}
.login-card input:focus { border-color: var(--gold); outline: none; }
.login-card .btn-primary { margin-top: 1.3rem; }

.pass-field { position: relative; display: flex; }
.pass-field input { padding-right: 3rem; }
.pass-toggle {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  width: 2.2rem;
  height: 2.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--crema-dim);
  font-size: 1rem;
  line-height: 1;
}
.pass-toggle:hover { background: rgba(255, 255, 255, 0.08); color: var(--crema); }

.login-secure {
  margin-top: 1rem;
  text-align: center;
  font-size: 0.76rem;
  color: var(--crema-dim);
}

.login-error {
  margin-top: 0.8rem;
  color: #ffb4ae;
  background: rgba(193, 39, 45, 0.15);
  border: 1px solid rgba(193, 39, 45, 0.4);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  font-size: 0.83rem;
}

.login-hint {
  margin-top: 1.2rem;
  font-size: 0.78rem;
  color: var(--crema-dim);
  background: rgba(217, 165, 68, 0.1);
  border: 1px dashed rgba(217, 165, 68, 0.4);
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  line-height: 1.5;
}
.login-hint code { font-family: var(--mono); color: var(--gold-light); }

.back-link {
  display: block;
  text-align: center;
  margin-top: 1.4rem;
  font-size: 0.82rem;
  color: var(--crema-dim);
}
.back-link:hover { color: var(--gold); }

/* =====================================================================
   LAYOUT
   ===================================================================== */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1.4rem;
  background: rgba(36, 13, 9, 0.96);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(10px);
}
.topbar-brand { display: flex; align-items: center; gap: 0.7rem; }
.topbar-brand img {
  width: 42px; height: 42px; object-fit: contain; border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(217, 165, 68, 0.5);
}
.topbar-brand strong { display: block; font-family: var(--display); font-size: 1.05rem; color: var(--gold-light); }
.topbar-brand span { font-size: 0.72rem; color: var(--crema-dim); }

.topbar-actions { display: flex; align-items: center; gap: 0.6rem; }
.user-email { font-size: 0.78rem; color: var(--crema-dim); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.layout { flex: 1; display: flex; align-items: flex-start; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  padding: 1.2rem 0.9rem;
  position: sticky;
  top: 63px;
  height: calc(100vh - 63px);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  border-right: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.12);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  text-align: left;
  padding: 0.7rem 0.85rem;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--crema-dim);
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: var(--crema); }
.nav-item.activo {
  background: linear-gradient(90deg, rgba(193, 39, 45, 0.35), rgba(193, 39, 45, 0.05));
  border-color: rgba(217, 165, 68, 0.35);
  color: var(--crema);
}
.ni-ico { font-size: 1.05rem; }
.sidebar-foot { margin-top: auto; padding-top: 1rem; }
.mode-tag {
  display: block;
  font-size: 0.68rem;
  font-family: var(--mono);
  color: var(--gold-light);
  background: rgba(217, 165, 68, 0.12);
  border: 1px solid rgba(217, 165, 68, 0.3);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  text-align: center;
  line-height: 1.35;
}

.content { flex: 1; padding: 1.6rem; max-width: 1200px; min-width: 0; }
.view { animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.3rem;
}
.view-head h2 { font-size: 1.7rem; color: var(--gold-light); }
.view-head p { color: var(--crema-dim); font-size: 0.86rem; margin-top: 0.2rem; max-width: 60ch; }

/* ---------------- Filtros ---------------- */
.filters { display: flex; flex-direction: column; gap: 0.8rem; margin-bottom: 1.2rem; }
.filters input[type="search"] {
  width: 100%;
  max-width: 420px;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--crema);
  font-size: 0.9rem;
}
.filters input:focus { border-color: var(--gold); outline: none; }
.cat-filters { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.chip {
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--crema-dim);
  font-size: 0.8rem;
  font-weight: 600;
}
.chip:hover { border-color: var(--gold); color: var(--crema); }
.chip.activo { background: var(--tomato); border-color: rgba(217, 165, 68, 0.5); color: #fff; }

/* ---------------- Cards productos ---------------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.pcard {
  display: flex;
  gap: 0.9rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
  transition: border-color 0.15s, transform 0.15s;
}
.pcard:hover { border-color: rgba(217, 165, 68, 0.5); transform: translateY(-2px); }
.pcard.inactivo { opacity: 0.55; }

.pcard-img {
  width: 78px; height: 78px; flex-shrink: 0;
  border-radius: 10px; overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
}
.pcard-img img { width: 100%; height: 100%; object-fit: cover; }

.pcard-body { flex: 1; min-width: 0; }
.pcard-cat {
  display: inline-block;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--gold-light);
  background: rgba(217, 165, 68, 0.14);
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  margin-bottom: 0.35rem;
}
.pcard-nombre { font-weight: 700; font-size: 0.98rem; color: var(--crema); }
.pcard-desc {
  font-size: 0.76rem; color: var(--crema-dim); margin-top: 0.15rem;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}
.pcard-precio { font-family: var(--mono); font-size: 0.9rem; color: var(--gold-light); margin-top: 0.35rem; }
.pcard-precio small { color: var(--crema-dim); font-size: 0.72rem; }
.pcard-actions { display: flex; flex-direction: column; gap: 0.35rem; align-items: stretch; min-width: 78px; }

.icon-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--crema);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  font-size: 0.74rem;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}
.icon-btn:hover { border-color: var(--gold); background: rgba(217, 165, 68, 0.12); }
.icon-btn.del:hover { border-color: var(--tomato); background: rgba(193, 39, 45, 0.25); color: #ffb4ae; }

.empty { text-align: center; color: var(--crema-dim); padding: 2.5rem 1rem; font-style: italic; }

/* ---------------- Config form ---------------- */
.config-form { display: flex; flex-direction: column; gap: 1.3rem; max-width: 760px; }
fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin: 0;
  background: rgba(0, 0, 0, 0.12);
}
legend {
  font-family: var(--display);
  font-weight: 700;
  color: var(--gold-light);
  padding: 0 0.5rem;
  font-size: 1rem;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.9rem; }

.field { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.8rem; }
.field:first-child { margin-top: 0; }
.field label { font-size: 0.76rem; font-weight: 600; color: var(--crema-dim); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--crema);
  font-size: 0.9rem;
  font-family: var(--body);
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--gold); outline: none; }
.field select option { background: var(--panel-2); }

.dias-grid { display: flex; flex-wrap: wrap; gap: 0.6rem 1.1rem; }
.dias-grid label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--crema); }
.dias-grid input { width: 17px; height: 17px; accent-color: var(--tomato); }

.config-actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.save-msg { font-size: 0.82rem; color: var(--basil); font-weight: 600; }
.save-msg.error { color: #ffb4ae; }

.danger-zone {
  margin-top: 1.6rem;
  max-width: 760px;
  border: 1px dashed rgba(193, 39, 45, 0.5);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  background: rgba(193, 39, 45, 0.08);
}
.danger-zone h3 { color: #ffb4ae; font-size: 1rem; margin-bottom: 0.3rem; }
.danger-zone p { font-size: 0.82rem; color: var(--crema-dim); margin-bottom: 0.8rem; }

/* =====================================================================
   MODAL
   ===================================================================== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(8, 4, 3, 0.7);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 100;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }

.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  width: min(620px, 94vw);
  max-height: 92vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid rgba(217, 165, 68, 0.3);
  border-radius: 18px;
  box-shadow: var(--shadow);
  z-index: 101;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.modal-sm { width: min(400px, 92vw); }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 1.3rem;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0;
  background: var(--panel);
  border-radius: 18px 18px 0 0;
  z-index: 2;
}
.modal-head h3 { color: var(--gold-light); font-size: 1.2rem; }
.modal-close {
  background: none; border: none; color: var(--crema-dim);
  font-size: 1.1rem; width: 34px; height: 34px; border-radius: 8px;
}
.modal-close:hover { background: rgba(255, 255, 255, 0.08); color: var(--crema); }

.modal-body { padding: 1.3rem; }
.modal-body .field:first-child { margin-top: 0; }

.image-row { display: flex; gap: 0.6rem; align-items: stretch; }
.image-row input { flex: 1; }
.upload-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0 1rem;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--crema);
  font-size: 0.84rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.upload-btn:hover { border-color: var(--gold); }

.image-preview { margin-top: 0.6rem; width: 130px; height: 130px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.image-preview img { width: 100%; height: 100%; object-fit: cover; }

.switch { display: flex; align-items: center; gap: 0.6rem; margin-top: 1rem; font-size: 0.88rem; cursor: pointer; }
.switch input { width: 40px; height: 22px; accent-color: var(--basil); }

.modal-error {
  margin-top: 1rem; color: #ffb4ae;
  background: rgba(193, 39, 45, 0.15);
  border: 1px solid rgba(193, 39, 45, 0.4);
  border-radius: 8px; padding: 0.6rem 0.8rem; font-size: 0.83rem;
}

.modal-actions { display: flex; justify-content: flex-end; gap: 0.7rem; margin-top: 1.4rem; }

.confirm-body h3 { color: #ffb4ae; margin-bottom: 0.5rem; }
.confirm-body p { color: var(--crema-dim); font-size: 0.88rem; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translate(-50%, 20px);
  background: var(--char);
  color: var(--crema);
  border: 1px solid rgba(217, 165, 68, 0.4);
  padding: 0.7rem 1.2rem;
  border-radius: 999px;
  font-size: 0.86rem;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(193, 39, 45, 0.6); }

/* =====================================================================
   RESPONSIVE
   ===================================================================== */
@media (max-width: 860px) {
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 0.6rem;
    gap: 0.4rem;
  }
  .nav-item { white-space: nowrap; width: auto; }
  .sidebar-foot { margin: 0 0 0 auto; padding: 0; display: flex; align-items: center; }
  .layout { flex-direction: column; }
  .content { width: 100%; padding: 1.1rem; }
}

@media (max-width: 600px) {
  .topbar { padding: 0.6rem 0.9rem; flex-wrap: wrap; }
  .topbar-brand span { display: none; }
  .user-email { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .view-head { align-items: stretch; }
  .view-head .btn-primary { width: 100%; }
  .cards { grid-template-columns: 1fr; }
  .pcard-actions { flex-direction: row; min-width: 0; align-self: flex-start; }
  .modal { border-radius: 14px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions button { width: 100%; }
  .image-row { flex-direction: column; }
  .upload-btn { justify-content: center; padding: 0.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
