/* =============================================================
   style.css — Estilos del Registro de Pedidos
   Diseño 100% responsivo: mobile-first
   ============================================================= */

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

:root {
  --bg:       #1C2437;
  --panel:    #2a3550;
  --panel-2:  #364566;
  --primary:  #EA4227;
  --primary-2:#ff5a40;
  --success:  #10b981;
  --warning:  #f59e0b;
  --danger:   #ef4444;
  --text:     #EBDDBA;
  --muted:    #d6c9a9;
  --border:   #4a5a78;
}

html, body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- LOGIN ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border-radius: 16px;
  padding: 36px 28px;
  box-shadow: 0 20px 50px rgba(0,0,0,.4);
  border: 1px solid var(--border);
}

.login-card h1 {
  font-size: 1.6rem;
  margin-bottom: 6px;
  text-align: center;
}

.login-card .sub {
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
  margin-bottom: 26px;
}

/* ---------- CAMPOS ---------- */
.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: .85rem;
  margin-bottom: 6px;
  color: var(--muted);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.25);
}

.field textarea {
  min-height: 70px;
  resize: vertical;
}

/* ---------- BOTONES ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .05s, background .15s;
  width: 100%;
}

.btn:hover   { background: var(--primary-2); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(234, 66, 39, 0.3); }
.btn:active  { transform: translateY(0) scale(.98); box-shadow: none; }

.btn.btn-sm  { width: auto; padding: 8px 14px; font-size: .85rem; }
.btn.success { background: var(--success); }
.btn.success:hover { background: #059669; box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3); }
.btn.warning { background: var(--warning); color: #1f2937; }
.btn.warning:hover { background: #d97706; box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3); }
.btn.danger  { background: var(--danger); }
.btn.danger:hover { background: #dc2626; box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3); }
.btn.ghost   { background: transparent; border: 1px solid var(--border); }
.btn.ghost:hover { background: rgba(255,255,255,0.05); box-shadow: none; }

/* ---------- ALERTAS ---------- */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: .9rem;
  margin-bottom: 14px;
}

.alert.error {
  background: rgba(239,68,68,.15);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,.3);
}

.alert.ok {
  background: rgba(16,185,129,.15);
  color: #6ee7b7;
  border: 1px solid rgba(16,185,129,.3);
}

/* ---------- APP ---------- */
.app {
  display: none;
}

.app.visible {
  display: block;
}

/* ---------- TOPBAR ---------- */
header.topbar {
  background: rgba(30,41,59,.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
  gap: 10px;
}

header.topbar h2 {
  font-size: 1.1rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  color: var(--muted);
}

/* Interruptor Uiverse bauble by Pradeepsaranbishnoi */
.bauble_box .bauble_label { 
  background: #c22; /* Rojo para Desactivado (Por defecto) */
  background-position: 62px 5px; 
  background-repeat: no-repeat; 
  background-size: auto 5px; 
  border: 0; 
  border-radius: 50px; 
  box-shadow: inset 0 10px 20px rgba(0,0,0,.4), 0 -1px 0px rgba(0,0,0,.2), inset 0 -1px 0px #fff; 
  cursor: pointer; 
  display: inline-block; 
  font-size: 0; 
  height: 40px; 
  position: relative; 
  -webkit-transition: all 500ms ease; 
  transition: all 500ms ease; 
  width: 90px; 
} 

.bauble_box .bauble_label:before { 
  background-color: rgba(255,255,255,.2); 
  background-position: 0 0; 
  background-repeat: repeat; 
  background-size: 30% auto; 
  border-radius: 50%; 
  box-shadow: inset 0 -5px 25px #500, 0 10px 20px rgba(0,0,0,.4); /* Sombra roja */
  content: ''; 
  display: block; 
  height: 30px; 
  left: 5px; 
  position: absolute; 
  top: 6px; 
  -webkit-transition: all 500ms ease; 
  transition: all 500ms ease; 
  width: 30px; 
  z-index: 2; 
} 

.bauble_box input.bauble_input { 
  opacity: 0; 
  z-index: 0; 
} 

/* Checked (Activado) */ 
.bauble_box input.bauble_input:checked + .bauble_label { 
  background-color: #2c2; /* Verde para Activado */
} 

.bauble_box input.bauble_input:checked + .bauble_label:before { 
  background-position: 150% 0; 
  box-shadow: inset 0 -5px 25px #050, 0 10px 20px rgba(0,0,0,.4); /* Sombra verde */
  left: calc( 100% - 35px ); 
}

.user-info strong {
  color: var(--text);
}

/* ---------- CONTENEDOR ---------- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 22px 16px 60px;
}

/* ---------- SEARCH BAR ---------- */
.search-bar {
  position: relative;
  margin-bottom: 22px;
}
.search-bar .search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 1.2rem;
}
.search-bar input {
  width: 100%;
  padding: 14px 14px 14px 44px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  font-family: inherit;
}
.search-bar input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(234, 66, 39, 0.15);
}

/* ---------- GRID ---------- */
.grid {
  display: grid;
  gap: 22px;
  grid-template-columns: 1fr;
}

/* ---------- TARJETAS ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
}

.card h3 {
  font-size: 1.1rem;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- CHECKBOX ENVÍO ---------- */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: var(--panel-2);
  border-radius: 8px;
  cursor: pointer;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* ---------- CAMPOS DE ENVÍO ---------- */
.envio-fields {
  display: none;
}

.envio-fields.visible {
  display: block;
}

/* ---------- TOTAL ---------- */
.total-box {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  color: white;
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.total-box .label {
  font-size: .85rem;
  opacity: .9;
}

.total-box .amount {
  font-size: 1.7rem;
  font-weight: 700;
}

.total-box .count {
  font-size: .8rem;
  opacity: .85;
  margin-top: 2px;
}

/* ---------- PEDIDO ---------- */
.order {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.order:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  border-color: rgba(234, 66, 39, 0.4);
}

.order-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.order-title {
  font-weight: 600;
  font-size: 1.02rem;
}

.order-price {
  color: var(--primary-2);
  font-weight: 700;
  font-size: 1.05rem;
  white-space: nowrap;
}

.order-meta {
  font-size: .82rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.order-desc {
  font-size: .9rem;
  color: #cbd5e1;
  margin-bottom: 8px;
  line-height: 1.4;
}

.order-envio {
  font-size: .82rem;
  background: rgba(99,102,241,.1);
  border-left: 3px solid var(--primary);
  padding: 8px 10px;
  border-radius: 4px;
  margin-bottom: 8px;
  color: #c7d2fe;
}

.order-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.order.dragging {
  opacity: 0.5;
  border: 2px dashed var(--primary);
}

.order.drag-over {
  border-top: 3px solid var(--primary);
}

/* ---------- BADGES ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.badge.pendiente {
  background: rgba(245,158,11,.2);
  color: #fbbf24;
}

.badge.entregado {
  background: rgba(16,185,129,.2);
  color: #34d399;
}

/* ---------- VACÍO ---------- */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  font-style: italic;
}

/* ---------- FILA 2 COLUMNAS ---------- */
.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ---------- TOAST ---------- */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 12px 18px;
  border-radius: 8px;
  color: var(--text);
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 1000;
  max-width: 90%;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

.toast.error { border-color: var(--danger); color: #fca5a5; }
.toast.ok    { border-color: var(--success); color: #6ee7b7; }

/* ==================== MODAL ==================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.85);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  padding: 16px;
  margin: 0;
  box-sizing: border-box;
}

.modal-overlay.show {
  display: flex;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 16px 16px 0 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.modal-header .btn {
  width: auto;
  padding: 6px 10px;
  line-height: 1;
  font-size: 1.2rem;
}

.modal-body {
  padding: 20px;
}

.modal-detail {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.modal-detail:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.modal-detail label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal-detail .value {
  font-size: 1rem;
  color: var(--text);
  line-height: 1.5;
  word-break: break-word;
}

/* ==================== RESPONSIVE ==================== */
/* Móvil chico */
@media (max-width: 480px) {
  .modal {
    max-height: 90vh;
    border-radius: 12px;
  }
  
  .modal-header {
    padding: 14px 16px;
  }
  
  .modal-header h3 {
    font-size: 1rem;
  }
  
  .modal-body {
    padding: 16px;
  }
}

/* Tablet / Escritorio */
@media (min-width: 900px) {
  .grid {
    grid-template-columns: 1fr 1.2fr;
  }
}

/* Móvil chico */
@media (max-width: 480px) {
  .row-2 {
    grid-template-columns: 1fr;
  }

  header.topbar {
    padding: 12px 14px;
  }

  .login-card {
    padding: 24px 18px;
    border-radius: 12px;
  }

  .login-card h1 {
    font-size: 1.3rem;
  }

  .total-box {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
  }

  .total-box > div:last-child {
    text-align: left !important;
  }

  .order-head {
    flex-direction: column;
  }

  .btn {
    padding: 10px 14px;
    font-size: .95rem;
  }
}

/* Tabla de Historial Mensual */
.stats-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}
.stats-table th {
  text-align: left;
  padding: 12px 8px;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
}
.stats-table td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 1.05rem;
}
.stats-table tbody tr:hover td {
  background: var(--bg-body);
}

/* Dropdown Menu */
.menu-container {
  position: relative;
}
.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}
.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 0;
  min-width: 220px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  z-index: 1000;
  display: none;
  flex-direction: column;
}
.dropdown-menu.show {
  display: flex;
}
.dropdown-header {
  padding: 8px 16px;
  font-size: 0.95rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.dropdown-header strong {
  color: var(--text);
}
.dropdown-item {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.95rem;
  color: var(--text);
}
.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
.dropdown-item-btn {
  width: 100%;
  text-align: left;
  justify-content: flex-start;
  border-radius: 0;
  padding: 10px 16px;
  gap: 8px;
  font-size: 0.95rem;
}
.dropdown-item-btn:hover {
  background: var(--panel-2);
}