/* Paleta */
:root {
  --red: #B92117;
  --ustard: #D4AC0D;
  --orange: #D35400;
  --white: #FFFFFF;
  --text: #1f2937;
  --muted: #6b7280;
  --bg: #f8fafc;
  --card: #ffffff;
  --shadow: 0 10px 25px rgba(0, 0, 0, .08);
  --radius: 16px;
}

/* Base */
* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, #fff 0%, var(--bg) 100%);
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ===== Topbar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(90deg, var(--red), var(--orange));
  color: var(--white);
  box-shadow: var(--shadow);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
}

.logo {
  font-size: 22px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.actions form {
  margin: 0;
}

.btn {
  border: 1px solid #e5e7eb;
  background: #fff;
  color: var(--text);
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background-color .12s ease, border-color .12s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(0, 0, 0, .12);
}

.btn.ghost {
  background: transparent;
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, .6);
  border-radius: 999px;
  padding: 8px 12px;
}

.btn.ghost:hover {
  background: rgba(255, 255, 255, .15);
}

.btn.primary {
  background: linear-gradient(90deg, var(--red), var(--orange));
  color: #fff;
  border-color: transparent;
}

.btn.danger {
  background: #fff5f5;
  color: #b91c1c;
  border-color: #fecaca;
}

.btn.back {
  background-color: var(--card);
}

.menu-toggle {
  display: none;
}

/* Media Query para móvil */
@media (max-width: 720px) {
  .topbar-inner {
    flex-wrap: wrap;
  }
  .actions {
    display: none;
    flex-direction: column;
    width: 100%;
    margin-left: 0;
    align-items: flex-start;
    padding: 10px 0;
  }
  .actions.show {
    display: flex;
  }
  .btn.ghost {
    width: 100%;
    justify-content: center;
    border: none;
    padding: 12px;
    border-radius: 0;
  }
  .btn.ghost.danger {
    background-color: #d90f00;
  }
  .menu-toggle {
    display: block;
  }
}

/* Título */
h1 {
  text-align: center;
  margin: 24px 0 12px;
}

/* Filtros */
.search-form {
  background: #fff;
  border: 1px solid #eef2f7;
  box-shadow: var(--shadow);
  border-radius: 12px;
  padding: 12px;
  margin: 16px 0 22px;
}

.search-form form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

.search-form input[type="text"],
.search-form select {
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
}

.search-form button {
  padding: 10px 18px;
}

/* Tarjetas */
.historial-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  margin-bottom: 40px;
}

.caja-pedido {
  background-color: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.caja-pedido h3 {
  margin: 0 0 10px 0;
  color: var(--orange);
  font-size: 1.25rem;
}

.caja-pedido p {
  margin: 5px 0;
}

.estado-display {
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: bold;
  color: #fff;
}

.estado-RESERVADO {
  background-color: #fca5a5;
  color: #7f1d1d;
}

.estado-COMPLETADO {
  background-color: #a7f3d0;
  color: #065f46;
}

.estado-CANCELADO {
  background-color: #d1d5db;
  color: #374151;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 15px;
}

/* Modales */
.modal {
  display: none;
  position: fixed;
  z-index: 200;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
  background-color: var(--card);
  margin: 15% auto;
  padding: 20px;
  border: 1px solid #888;
  width: 90%;
  max-width: 400px;
  border-radius: var(--radius);
  position: relative;
  box-shadow: var(--shadow);
}

.close-button {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  border: none;
  background: transparent;
  cursor: pointer;
  position: absolute;
  top: 10px;
  right: 15px;
}

.close-button:hover,
.close-button:focus {
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.modal h2 {
  color: var(--red);
  margin-top: 0;
}

.modal form {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 20px;
}

.modal label {
  font-weight: bold;
  margin-top: 5px;
}

.modal input,
.modal select {
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 8px;
}

.modal button {
  align-self: flex-start;
}

#statusMessage, #anticipoMessage {
  margin-top: 15px;
  font-weight: bold;
}