/* ═══════════════════════════════════════════════════════════
   VAQUERO Portal — Sistema de diseño compartido
   Importar en todos los módulos ANTES de estilos propios:
   <link rel="stylesheet" href="_styles.css" />
═══════════════════════════════════════════════════════════ */

/* ─── Google Fonts ─── */
@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@600;700&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

/* ─── Variables ─── */
:root {
  /* Colores */
  --bg:         #f0eeeb;
  --surface:    #ffffff;
  --surface-2:  #f6f5f3;
  --surface-3:  #edecea;
  --border:     rgba(0,0,0,0.09);
  --border-md:  rgba(0,0,0,0.14);
  --border-strong: rgba(0,0,0,0.20);

  /* Texto */
  --text:   #1a1a18;
  --text-2: #5a5956;
  --text-3: #9a9895;

  /* Tipografía */
  --font:      'DM Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;
  --font-brand:'Barlow Condensed', sans-serif;

  /* Radios */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Layout */
  --topbar-h:    52px;
  --topbar-h-m:  56px;
  --sidebar-w:   210px;
  --bottomnav-h: 66px;

  /* Status pills */
  --s-presup-bg:    #ddeeff; --s-presup-c:    #0a4a8c;
  --s-curso-bg:     #eae8fd; --s-curso-c:     #3a3199;
  --s-pago-bg:      #fdf0d8; --s-pago-c:      #6b3f05;
  --s-logistica-bg: #fdeae2; --s-logistica-c: #6e2e10;
  --s-entregado-bg: #e5f2d8; --s-entregado-c: #284e0a;
  --s-cancelado-bg: #eeece8; --s-cancelado-c: #44423f;

  /* Breakpoints (solo referencia) */
  /* mobile-first: < 768px mobile, >= 768px desktop */
}

/* ─── Reset ─── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html, body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button, input, select, textarea {
  font-family: var(--font);
}
a { text-decoration: none; color: inherit; }

/* ═══════════════════════════════════════════
   TIPOGRAFÍA
═══════════════════════════════════════════ */
.brand {
  font-family: var(--font-brand);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--text);
}

/* ═══════════════════════════════════════════
   LAYOUT — DESKTOP (>= 768px)
═══════════════════════════════════════════ */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Topbar desktop */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 0.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  gap: 16px;
}
.topbar .brand { font-size: 22px; }
.topbar-center {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.topbar-user {
  font-size: 13px;
  color: var(--text-2);
}

/* Sidebar desktop */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 0.5px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}
.sidebar-section { padding: 12px 10px 4px; }
.sidebar-label {
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  padding: 0 8px;
  margin-bottom: 4px;
}
.sidebar-footer {
  margin-top: auto;
  padding: 14px 18px;
  border-top: 0.5px solid var(--border);
}
.sidebar-footer .sf-label { font-size: 11px; color: var(--text-3); }
.sidebar-footer .sf-value {
  font-size: 18px;
  font-weight: 500;
  font-family: var(--font-mono);
  margin-top: 4px;
  color: var(--text);
}

/* Nav items (sidebar) */
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--text); font-weight: 500; }
.nav-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--text-2);
}

/* Main content area */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.content {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
}

/* ═══════════════════════════════════════════
   LAYOUT — MOBILE (< 768px)
═══════════════════════════════════════════ */
@media (max-width: 767px) {
  .app {
    height: 100dvh; /* dynamic viewport height para mobile */
  }

  /* Ocultar sidebar en mobile */
  .sidebar { display: none; }

  /* Topbar mobile */
  .topbar {
    height: var(--topbar-h-m);
    padding: 0 16px;
  }
  .topbar .brand { font-size: 20px; }
  .topbar-center { font-size: 15px; }

  /* Content con padding para bottom nav */
  .content {
    padding: 14px 14px calc(var(--bottomnav-h) + 14px);
  }

  /* Ocultar elementos solo-desktop */
  .desktop-only { display: none !important; }
}

@media (min-width: 768px) {
  /* Ocultar elementos solo-mobile */
  .mobile-only { display: none !important; }
}

/* ═══════════════════════════════════════════
   BOTTOM NAV (solo mobile)
═══════════════════════════════════════════ */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottomnav-h);
  background: var(--surface);
  border-top: 0.5px solid var(--border);
  display: none; /* solo visible en mobile */
  align-items: center;
  justify-content: space-around;
  padding-bottom: 8px;
  z-index: 100;
}
@media (max-width: 767px) {
  .bottom-nav { display: flex; }
}
.bn-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex: 1;
  cursor: pointer;
  padding: 6px 0;
}
.bn-icon { font-size: 20px; line-height: 1; }
.bn-label { font-size: 10px; color: var(--text-3); font-weight: 500; }
.bn-item.active .bn-label { color: var(--text); font-weight: 600; }
.bn-active-dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--text);
  margin-bottom: 1px;
}

/* ═══════════════════════════════════════════
   BOTONES
═══════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 500;
  transition: opacity 0.15s, background 0.12s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Primario */
.btn-primary {
  background: var(--text);
  color: var(--surface);
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) { opacity: 0.82; }

/* Secundario */
.btn-secondary {
  background: transparent;
  color: var(--text-2);
  border: 0.5px solid var(--border-md);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 13px;
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }

/* Danger */
.btn-danger {
  background: transparent;
  color: #a32d2d;
  border: 0.5px solid #e2a0a0;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 13px;
}
.btn-danger:hover:not(:disabled) { background: #fff0f0; }

/* Small */
.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

/* Pill (logout, filtros) */
.btn-pill {
  padding: 5px 14px;
  border-radius: var(--radius-xl);
  font-size: 12px;
  border: 0.5px solid var(--border-md);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.12s;
}
.btn-pill:hover { background: var(--surface-2); color: var(--text-2); }
.btn-pill.active {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}

/* FAB (floating action button, mobile) */
.fab {
  position: fixed;
  bottom: calc(var(--bottomnav-h) + 14px);
  right: 18px;
  width: 52px;
  height: 52px;
  background: var(--text);
  border-radius: 50%;
  border: none;
  color: white;
  font-size: 24px;
  display: none; /* solo mobile */
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 99;
  transition: opacity 0.15s;
}
.fab:hover { opacity: 0.85; }
@media (max-width: 767px) {
  .fab { display: flex; }
}

/* ═══════════════════════════════════════════
   FORMULARIOS
═══════════════════════════════════════════ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.form-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
}
.form-group input,
.form-group select,
.form-group textarea {
  padding: 0 12px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 0.5px solid var(--border-md);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.12s;
}
.form-group textarea {
  height: auto;
  min-height: 80px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.5;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--text);
}
/* Mobile: inputs más grandes */
@media (max-width: 767px) {
  .form-group input,
  .form-group select {
    height: 48px;
    font-size: 15px;
  }
}

/* Grid de form */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-full { grid-column: 1 / -1; }
@media (max-width: 767px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-full { grid-column: 1; }
}

/* ═══════════════════════════════════════════
   CARDS
═══════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
}

/* Card de módulo (home) */
.module-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.12s;
  display: block;
  color: var(--text);
}
.module-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  border-color: var(--border-md);
  transform: translateY(-1px);
}
.module-card .mc-icon { font-size: 22px; line-height: 1; margin-bottom: 12px; }
.module-card .mc-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.module-card .mc-desc {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.5;
}

/* Card de orden (mobile list) */
.order-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.12s;
}
.order-card:active { border-color: var(--border-md); }
.order-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.order-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.order-supplier { font-size: 14px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.order-num { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.order-meta { font-size: 11px; color: var(--text-3); }
.order-amount {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

/* ═══════════════════════════════════════════
   MÉTRICAS (strip de 4 cards)
═══════════════════════════════════════════ */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
@media (max-width: 767px) {
  .metrics {
    grid-template-columns: repeat(2, 1fr);
  }
}
.metric {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.metric-label {
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 5px;
}
.metric-value {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}
.metric-value.mono { font-family: var(--font-mono); font-size: 15px; }
.metric-sub { font-size: 10px; color: var(--text-3); margin-top: 4px; }

/* ═══════════════════════════════════════════
   TABLA (desktop)
═══════════════════════════════════════════ */
.table-wrap {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
th {
  padding: 9px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  background: var(--surface-2);
  border-bottom: 0.5px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
}
td {
  padding: 11px 14px;
  border-bottom: 0.5px solid var(--border);
  font-size: 13px;
  color: var(--text-2);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); cursor: pointer; }
.td-primary { color: var(--text); font-weight: 600; font-size: 13px; }
.td-secondary { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.td-amount {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text);
}

/* ═══════════════════════════════════════════
   FILTROS (barra de filtros)
═══════════════════════════════════════════ */
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  align-items: center;
}
.search-input {
  margin-left: auto;
  padding: 6px 14px;
  border-radius: var(--radius-xl);
  border: 0.5px solid var(--border-md);
  background: var(--surface);
  font-size: 12px;
  color: var(--text);
  outline: none;
  width: 200px;
  font-family: var(--font);
  transition: border-color 0.12s;
}
.search-input:focus { border-color: var(--text); }
@media (max-width: 767px) {
  .search-input { width: 100%; margin-left: 0; }
}

/* ═══════════════════════════════════════════
   STATUS PILLS
═══════════════════════════════════════════ */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.pill-presup    { background: var(--s-presup-bg);    color: var(--s-presup-c); }
.pill-curso     { background: var(--s-curso-bg);     color: var(--s-curso-c); }
.pill-pago      { background: var(--s-pago-bg);      color: var(--s-pago-c); }
.pill-logistica { background: var(--s-logistica-bg); color: var(--s-logistica-c); }
.pill-entregado { background: var(--s-entregado-bg); color: var(--s-entregado-c); }
.pill-cancelado { background: var(--s-cancelado-bg); color: var(--s-cancelado-c); }

/* ═══════════════════════════════════════════
   AVATAR
═══════════════════════════════════════════ */
.avatar {
  width: 30px;
  height: 30px;
  background: var(--surface-3);
  border-radius: 50%;
  border: 0.5px solid var(--border-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════
   MODAL
═══════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border);
  width: 100%;
  max-width: 520px;
  max-height: 92dvh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.14);
}
@media (max-width: 767px) {
  /* Modal como sheet desde abajo en mobile */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    max-width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 92dvh;
    padding: 20px 20px 32px;
  }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-header h3 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 0.5px solid var(--border);
}
@media (max-width: 767px) {
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; height: 48px; justify-content: center; }
}

/* ═══════════════════════════════════════════
   PANEL LATERAL DE DETALLE
═══════════════════════════════════════════ */
.detail-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 380px;
  background: var(--surface);
  border-left: 0.5px solid var(--border);
  overflow-y: auto;
  z-index: 200;
  padding: 20px;
  transform: translateX(100%);
  transition: transform 0.22s cubic-bezier(0.4,0,0.2,1);
  box-shadow: -4px 0 24px rgba(0,0,0,0.07);
}
.detail-panel.open { transform: translateX(0); }
@media (max-width: 767px) {
  /* En mobile, el panel cubre toda la pantalla */
  .detail-panel {
    width: 100%;
    border-left: none;
  }
}
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}
.detail-section { margin-bottom: 18px; }
.detail-section-label {
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 0.5px solid var(--border);
  font-size: 13px;
}
.detail-row:last-child { border-bottom: none; }
.detail-key { color: var(--text-2); }

/* ═══════════════════════════════════════════
   TOAST
═══════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--surface);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  opacity: 0;
  transition: all 0.2s;
  pointer-events: none;
  z-index: 1000;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (max-width: 767px) {
  .toast { bottom: calc(var(--bottomnav-h) + 14px); }
}

/* ═══════════════════════════════════════════
   BOTÓN CERRAR (×)
═══════════════════════════════════════════ */
.btn-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-2);
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.12s;
}
.btn-close:hover { background: var(--surface-2); }

/* ═══════════════════════════════════════════
   EMPTY STATE
═══════════════════════════════════════════ */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.6;
}

/* ═══════════════════════════════════════════
   TIMELINE (historial de estados)
═══════════════════════════════════════════ */
.timeline { display: flex; flex-direction: column; gap: 12px; }
.tl-item { display: flex; gap: 10px; }
.tl-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}
.tl-title { font-size: 12px; font-weight: 500; }
.tl-date  { font-size: 11px; color: var(--text-3); }

/* ═══════════════════════════════════════════
   UTILIDADES
═══════════════════════════════════════════ */
.mono { font-family: var(--font-mono); }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.mt-auto { margin-top: auto; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.flex   { display: flex; }
.flex-col { flex-direction: column; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
