/* =============================================
   LOQUEBU — APP.CSS
   Variables, layout, componentes globales
   ============================================= */

:root {
  --bg:           #0f0a1e;
  --bg-card:      #1a1035;
  --bg-card-2:    #221545;
  --border:       #2d1f55;
  --border-light: #3d2d70;
  --primary:      #7c3aed;
  --primary-h:    #6d28d9;
  --primary-light:#a78bfa;
  --success:      #059669;
  --success-h:    #047857;
  --danger:       #dc2626;
  --text:         #f1f0ff;
  --text-2:       #c4b5fd;
  --text-3:       #7c6fa0;
  --sidebar-w:    220px;
  --radius:       10px;
  --shadow:       0 4px 24px rgba(0,0,0,0.4);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform 0.25s;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 18px;
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1px;
  padding: 4px 8px;
  border-radius: 6px;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.5px;
}

.nav-menu {
  list-style: none;
  padding: 12px 8px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-3);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: all 0.15s;
  user-select: none;
}

.nav-item:hover { background: var(--bg-card-2); color: var(--text-2); }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 700; }

.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
}
.sidebar-footer b { color: var(--primary-light); }

/* ---- MOBILE TOGGLE ---- */
.nav-toggle {
  display: none;
  position: fixed;
  top: 14px; left: 14px;
  z-index: 200;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 18px;
  cursor: pointer;
}

/* ---- MAIN CONTENT ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 0;
  min-height: 100vh;
}

/* ---- SCREENS ---- */
.screen { display: none; padding: 28px 24px; max-width: 960px; }
.screen.active { display: block; }

/* ---- SCREEN HEADER ---- */
.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.screen-header h1 {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.3px;
}

.header-badge {
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 1px;
}

/* ---- CARD ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card.pad-0 { padding: 0; }

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.card-subtitle {
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 20px;
}

/* ---- FIELDS ---- */
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.field-input, .mensaje-input {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}
.field-input:focus, .mensaje-input:focus {
  border-color: var(--primary);
}

.mensaje-input {
  min-height: 120px;
  resize: vertical;
  line-height: 1.6;
  font-size: 13px;
}

/* ---- FORM GRID ---- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}
.field-group { display: flex; flex-direction: column; }
.field-group.full { grid-column: 1 / -1; }

.form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.form-header h2 { font-size: 16px; font-weight: 700; }

.tipo-badge {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 4px 12px;
  border-radius: 20px;
  background: #064e3b;
  color: #6ee7b7;
}
.tipo-badge.nacional {
  background: #1e3a5f;
  color: #93c5fd;
}

.form-error {
  background: #450a0a;
  border: 1px solid var(--danger);
  border-radius: 6px;
  padding: 8px 12px;
  color: #fca5a5;
  font-size: 13px;
  margin-bottom: 12px;
}
.form-error.hidden { display: none; }

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: var(--success-h); }
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border-light);
}
.btn-ghost:hover { background: var(--bg-card-2); }
.btn-dark { background: #111; color: #fff; border: 1.5px solid #333; }
.btn-dark:hover { background: #000; }
.btn-full { width: 100%; margin-top: 10px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ---- SEARCH ---- */
.search-input {
  background: var(--bg-card-2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 8px 14px;
  outline: none;
  width: 220px;
  font-family: inherit;
  transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--primary); }

/* ---- TABLE ---- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }

.pedidos-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.pedidos-table th {
  background: var(--bg-card-2);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 14px;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.pedidos-table th:hover { color: var(--text-2); }
.pedidos-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.pedidos-table tr:last-child td { border-bottom: none; }
.pedidos-table tbody tr { cursor: pointer; transition: background 0.1s; }
.pedidos-table tbody tr:hover { background: var(--bg-card-2); }
.pedidos-table tbody tr.selected { background: #2d1b69; }
.pedidos-table tbody tr.nuevo { animation: flash 1s ease; }

@keyframes flash {
  0%,100% { background: transparent; }
  30% { background: #3d2d6e; }
}

.empty-row td {
  text-align: center;
  color: var(--text-3);
  padding: 40px;
  cursor: default;
}

.badge-tipo {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
}
.badge-local { background: #064e3b; color: #6ee7b7; }
.badge-nacional { background: #1e3a5f; color: #93c5fd; }

.btn-mini {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition: background 0.15s;
}
.btn-mini:hover { background: var(--primary-h); }

/* ---- PANEL DETALLE ---- */
.detalle-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.detalle-codigo {
  font-size: 18px;
  font-weight: 900;
  color: var(--primary-light);
  margin-right: 10px;
}
.detalle-tipo { font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 10px; }

.detalle-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.det-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 3px;
}
.det-val {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

/* ---- CONFIGURACION ---- */
.cfg-msg {
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 8px;
}
.cfg-msg.ok { background: #064e3b; color: #6ee7b7; border: 1px solid #059669; }
.cfg-msg.err { background: #450a0a; color: #fca5a5; border: 1px solid var(--danger); }
.cfg-msg.hidden { display: none; }

/* ---- MODAL OVERLAY ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 500;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px 40px;
}

.modal-container {
  width: 100%;
  max-width: 440px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.etiqueta-preview {
  display: flex;
  justify-content: center;
}

/* ---- TOAST ---- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1a1035;
  color: var(--text);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  z-index: 9999;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.ok { border-color: var(--success); color: #6ee7b7; }
.toast.err { border-color: var(--danger); color: #fca5a5; }

/* ---- MOBILE ---- */
@media (max-width: 680px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 30px rgba(0,0,0,0.5); }
  .nav-toggle { display: block; }
  .main-content { margin-left: 0; }
  .screen { padding: 60px 14px 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .field-group.full { grid-column: auto; }
  .detalle-grid { grid-template-columns: 1fr 1fr; }
  .screen-header { flex-direction: column; align-items: flex-start; }
  .search-input { width: 100%; }
}

/* ---- V2 ADDITIONS ---- */
.btn-danger {
  background: #7f1d1d;
  color: #fca5a5;
  border: 1px solid var(--danger);
}
.btn-danger:hover { background: #991b1b; }

/* Indicadores de campo en formulario nuevo pedido */
.field-input.detectado  { border-color: #059669; }
.field-input.faltante   { border-color: #d97706; }

/* Select en header */
.search-input option {
  background: var(--bg-card);
  color: var(--text);
}

/* Panel edición integrado */
#panel-edicion .form-header h2 { font-size: 15px; }
