/* =========================================================
   MJ EXPRESS DELIVERY - BASE.CSS
   Estilo global unificado
   Paleta: azul + naranja + blanco suave
   ========================================================= */

/* =========================
   VARIABLES GLOBALES
   ========================= */
:root {
  --primary: #2f6fed;
  --primary-hover: #1f5adb;
  --primary-soft: #eaf1ff;

  --accent: #f28c28;
  --accent-hover: #de7412;
  --accent-soft: #fff2e7;

  --success: #16a34a;
  --success-soft: #eaf8ef;

  --danger: #dc2626;
  --danger-soft: #feecec;

  --warning: #f59e0b;
  --warning-soft: #fff7e6;

  --info: #0ea5e9;
  --info-soft: #e8f7ff;

  --bg: #f4f7fb;
  --bg-gradient: linear-gradient(180deg, #f8fbff 0%, #eef4fb 100%);
  --surface: #ffffff;
  --surface-soft: #f9fbfd;
  --surface-muted: #f1f5f9;

  --text: #1f2a37;
  --text-soft: #667085;
  --text-faint: #94a3b8;

  --border: #d9e2ec;
  --border-strong: #c7d3e0;

  --shadow-xs: 0 2px 8px rgba(31, 42, 55, 0.04);
  --shadow-sm: 0 6px 18px rgba(31, 42, 55, 0.06);
  --shadow-md: 0 12px 28px rgba(47, 111, 237, 0.10);
  --shadow-lg: 0 18px 38px rgba(31, 42, 55, 0.12);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;

  --transition-fast: 0.18s ease;
  --transition-normal: 0.25s ease;

  --max-width: 1200px;

  --topbar-height: 74px;
}

/* =========================
   RESET
   ========================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg-gradient);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* =========================
   ELEMENTOS BASE
   ========================= */
img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-hover);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

input,
select,
textarea {
  outline: none;
}

/* =========================
   SCROLLBAR
   ========================= */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #edf2f7;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb {
  background: #c7d3e0;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #aebfd2;
}

/* =========================
   LAYOUT GENERAL
   ========================= */
.app-shell,
.page-shell {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 20px;
}

.page-section {
  margin-bottom: 24px;
}

.content-grid {
  display: grid;
  gap: 20px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

/* =========================
   TOPBAR / HEADER
   ========================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(217, 226, 236, 0.9);
  box-shadow: var(--shadow-xs);
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 6px;
}

.brand-text h1,
.brand-text h2,
.brand-text h3,
.page-title {
  margin: 0;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-title {
  font-size: clamp(1.25rem, 2vw, 1.9rem);
}

.page-subtitle,
.section-subtitle,
.muted-text {
  margin: 4px 0 0;
  color: var(--text-soft);
  font-size: 0.96rem;
}

/* =========================
   BOTON VOLVER
   ========================= */
.back-btn,
.back-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  font-weight: 600;
  transition: all var(--transition-fast);
}

.back-btn:hover,
.back-button:hover {
  background: var(--primary-soft);
  border-color: #bfd1ff;
  transform: translateY(-1px);
}

/* =========================
   TARJETAS / BLOQUES
   ========================= */
.card,
.panel,
.section-card,
.surface-card {
  background: var(--surface);
  border: 1px solid rgba(217, 226, 236, 0.9);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}

.card-soft {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  padding: 18px;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.card-title,
.section-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text);
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

/* =========================
   BOTONES
   ========================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 12px 18px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
  white-space: nowrap;
  border: 1px solid transparent;
  box-shadow: var(--shadow-xs);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #4c83f1);
  color: #fff;
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-hover), #386de0);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), #f7a14f);
  color: #fff;
}

.btn-accent:hover {
  background: linear-gradient(135deg, var(--accent-hover), #ef8f34);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--surface-soft);
  border-color: var(--border-strong);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: #bfd1ff;
}

.btn-outline:hover {
  background: var(--primary-soft);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #ef4444);
  color: #fff;
}

.btn-danger:hover {
  filter: brightness(0.98);
}

.btn-success {
  background: linear-gradient(135deg, var(--success), #22c55e);
  color: #fff;
}

.btn-sm {
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 0.88rem;
}

.btn-lg {
  min-height: 52px;
  padding: 14px 22px;
  font-size: 1rem;
}

/* =========================
   FORMULARIOS
   ========================= */
.form-layout,
.form-grid {
  display: grid;
  gap: 18px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.form-group,
.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label,
label {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
}

.form-hint,
.field-hint {
  font-size: 0.82rem;
  color: var(--text-soft);
}

.input,
.select,
.textarea,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  transition: all var(--transition-fast);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.02);
}

textarea,
.textarea {
  min-height: 120px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

.input:focus,
.select:focus,
.textarea:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: #8ab0ff;
  box-shadow: 0 0 0 4px rgba(47, 111, 237, 0.12);
  background: #fff;
}

/* =========================
   INPUTS ESPECIALES
   ========================= */
.search-box {
  position: relative;
}

.search-box input {
  padding-left: 42px;
}

.search-box .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
}

.input-readonly {
  background: var(--surface-muted);
  color: var(--text-soft);
}

/* =========================
   CHECKBOX / RADIO
   ========================= */
.checkbox-row,
.radio-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

/* =========================
   TABLAS
   ========================= */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.table th,
.table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid #edf2f7;
  vertical-align: middle;
}

.table th {
  background: linear-gradient(180deg, #f8fbff 0%, #eef4fb 100%);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
}

.table td {
  color: var(--text-soft);
  font-size: 0.93rem;
}

.table tbody tr {
  transition: background var(--transition-fast);
}

.table tbody tr:hover {
  background: #f8fbff;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* =========================
   BADGES / ESTADOS
   ========================= */
.badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}

.badge-primary {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: #cfe0ff;
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-color: #ffd7b2;
}

.badge-success {
  background: var(--success-soft);
  color: var(--success);
  border-color: #bce9c8;
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #f6c7c7;
}

.badge-warning {
  background: var(--warning-soft);
  color: #b7791f;
  border-color: #fde7b0;
}

.badge-info {
  background: var(--info-soft);
  color: var(--info);
  border-color: #c5ebff;
}

/* =========================
   ESTADO VACÍO
   ========================= */
.empty-state {
  text-align: center;
  padding: 30px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #fbfdff 0%, #f6fafe 100%);
  color: var(--text-soft);
}

.empty-state h3 {
  margin: 0 0 8px;
  color: var(--text);
}

.empty-state p {
  margin: 0;
}

/* =========================
   STATS / RESUMEN
   ========================= */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-xs);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-soft);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}

.stat-note {
  margin-top: 8px;
  font-size: 0.84rem;
  color: var(--text-soft);
}

/* =========================
   MODALES
   ========================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid #edf2f7;
}

.modal-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px 20px;
}

/* =========================
   ALERTAS
   ========================= */
.alert {
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-size: 0.92rem;
  font-weight: 600;
}

.alert-info {
  background: var(--info-soft);
  color: #0369a1;
  border-color: #bfe7ff;
}

.alert-success {
  background: var(--success-soft);
  color: #166534;
  border-color: #bde7c9;
}

.alert-warning {
  background: var(--warning-soft);
  color: #9a6700;
  border-color: #f7e2a2;
}

.alert-danger {
  background: var(--danger-soft);
  color: #b91c1c;
  border-color: #f5c2c2;
}

/* =========================
   AVATAR / PERFIL
   ========================= */
.avatar,
.avatar-circle {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-muted);
  border: 3px solid #fff;
  box-shadow: var(--shadow-sm);
}

.avatar-sm {
  width: 42px;
  height: 42px;
}

.avatar-lg {
  width: 110px;
  height: 110px;
}

/* =========================
   LISTAS
   ========================= */
.list-clean {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid #edf2f7;
}

.list-row:last-child {
  border-bottom: none;
}

/* =========================
   DIVISORES
   ========================= */
.divider {
  height: 1px;
  width: 100%;
  background: linear-gradient(90deg, transparent, #d9e2ec, transparent);
  margin: 18px 0;
}

/* =========================
   MAPA / BLOQUES VISUALES
   ========================= */
.map-shell,
.map-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #edf2f7;
  background: #fbfdff;
}

/* =========================
   UTILIDADES
   ========================= */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-soft {
  color: var(--text-soft);
}

.text-primary {
  color: var(--primary);
}

.text-accent {
  color: var(--accent);
}

.bg-primary-soft {
  background: var(--primary-soft);
}

.bg-accent-soft {
  background: var(--accent-soft);
}

.hidden {
  display: none !important;
}

.w-100 {
  width: 100%;
}

.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }

.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }

.p-0 { padding: 0; }

/* =========================
   RESPONSIVE
   ========================= */
@media (max-width: 992px) {
  .grid-3 {
    grid-template-columns: 1fr 1fr;
  }

  .form-grid-2,
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  :root {
    --topbar-height: auto;
  }

  .app-shell,
  .page-shell {
    padding: 16px;
  }

  .topbar {
    position: relative;
    height: auto;
    flex-direction: column;
    align-items: stretch;
    padding: 14px 16px;
  }

  .topbar-left,
  .topbar-right,
  .brand-block,
  .section-title-row,
  .card-header {
    width: 100%;
  }

  .topbar-right,
  .section-title-row,
  .card-header {
    flex-direction: column;
    align-items: stretch;
  }

  .grid-3 {
    grid-template-columns: 1fr;
  }

  .btn {
    width: 100%;
  }

  .modal {
    max-width: 100%;
    border-radius: 22px;
  }

  .table {
    min-width: 640px;
  }
}

@media (max-width: 480px) {
  .app-shell,
  .page-shell {
    padding: 14px;
  }

  .card,
  .panel,
  .section-card,
  .surface-card {
    padding: 16px;
    border-radius: 18px;
  }

  .page-title {
    font-size: 1.15rem;
  }

  .page-subtitle,
  .section-subtitle {
    font-size: 0.9rem;
  }

  .input,
  .select,
  .textarea,
  input,
  select,
  textarea {
    min-height: 46px;
    padding: 11px 13px;
  }
}