/* ============================================================
   Diseñístico — Sistema interno
   Rediseño alineado a la marca de www.disenistico.com:
   Poppins, azul carbón #223441, rosa #cc3366, dorado #f5c45d,
   fondos crema cálidos y botones píldora.
   ============================================================ */

@font-face {
  font-family: 'Poppins';
  src: url('/fonts/poppins-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Poppins';
  src: url('/fonts/poppins-500.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Poppins';
  src: url('/fonts/poppins-600.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'Poppins';
  src: url('/fonts/poppins-700.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #f6f3ee;            /* crema cálido de fondo */
  --card: #ffffff;
  --ink: #223441;           /* azul carbón de la marca */
  --muted: #69727d;         /* gris del sitio */
  --line: #e7e1d8;
  --accent: #223441;        /* acción principal: azul carbón */
  --accent-dark: #16232c;
  --rosa: #cc3366;          /* rosa de marca (acentos, activo) */
  --dorado: #f5c45d;
  --ok: #4c7a4c;
  --warn: #b8862f;
  --danger: #b3453f;
  --radius: 14px;
  --sombra: 0 1px 3px rgba(34, 52, 65, 0.07), 0 4px 14px rgba(34, 52, 65, 0.05);
  /* Color de acento por módulo — cada sección se identifica con un color
     propio en la navegación y sus tarjetas, definido por body.pagina-*. */
  --mod: var(--rosa);
}

body.pagina-inicio, body.pagina-tasks { --mod: #cc3366; }        /* rosa marca */
body.pagina-clientes { --mod: #ed624d; }                          /* coral */
body.pagina-ordenes, body.pagina-dashboard-comercial { --mod: #c0902c; } /* dorado oscuro */
body.pagina-proyectos { --mod: #223441; }                         /* azul carbón */
body.pagina-inventario, body.pagina-bazar { --mod: #4c7a4c; }     /* verde salvia */
body.pagina-contabilidad, body.pagina-documentos { --mod: #3a6ea5; } /* azul medio */
body.pagina-mercadeo { --mod: #5a54c8; }                          /* índigo */
body.pagina-dashboard { --mod: #223441; }
body.pagina-sistema, body.pagina-usuarios { --mod: #69727d; }     /* gris */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--rosa); }

h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 19px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }

/* ---------- Barra superior (marca oscura + menú) ---------- */

.topbar {
  background: var(--ink);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 58px;
  box-shadow: 0 2px 10px rgba(22, 35, 44, 0.25);
}

.topbar .brand {
  font-weight: 600;
  font-size: 17px;
  color: #fff;
  text-decoration: none;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  padding: 8px 0;
}

.brand-logo { height: 26px; display: block; }

/* Botón hamburguesa — visible solo en pantallas angostas */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 26px;
  line-height: 1;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: 8px;
}
.menu-toggle:active { background: rgba(255,255,255,0.12); }

.topbar nav {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 13.5px;
  flex: 1;
  justify-content: center;
}

.topbar nav a {
  text-decoration: none;
  color: rgba(255, 255, 255, 0.82);
  padding: 8px 9px;
  border-radius: 999px;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.topbar nav a:hover { color: #fff; background: rgba(255,255,255,0.10); }

.topbar nav a.active {
  color: #fff;
  font-weight: 600;
  background: var(--rosa);
}

.topbar .user-tag {
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.topbar .user-tag a { color: rgba(255,255,255,0.9); text-decoration: none; }
.topbar .user-tag a:hover { color: #fff; text-decoration: underline; }
.topbar .user-tag .btn-secondary {
  border-color: rgba(255,255,255,0.45);
  color: #fff !important;
}
.topbar .user-tag .btn-secondary:hover,
.topbar .user-tag .btn-secondary:focus-visible {
  background: rgba(255,255,255,0.15);
  border-color: #fff;
}

/* Menú móvil: colapsado por defecto, se abre con el botón hamburguesa.
   El nombre de usuario y "Salir" también viven dentro del menú abierto,
   para que la barra ocupe una sola fila. */
@media (max-width: 920px) {
  .menu-toggle { display: block; margin-left: auto; }
  .topbar { flex-wrap: wrap; }
  .topbar nav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    padding: 6px 0 4px;
    gap: 2px;
  }
  .topbar nav.abierto { display: flex; }
  .topbar nav a {
    padding: 13px 14px;
    font-size: 15px;
    border-radius: 10px;
  }
  .topbar .user-tag { display: none; }
  .topbar nav.abierto ~ .user-tag {
    display: flex;
    width: 100%;
    justify-content: space-between;
    padding: 10px 14px 14px;
    border-top: 1px solid rgba(255,255,255,0.15);
  }
  .hero-logo { display: none; }
}

/* ---------- Héroe de bienvenida ---------- */

.hero {
  background: linear-gradient(135deg, #2c4356 0%, var(--ink) 55%, #16232c 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 24px 22px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: space-between;
  box-shadow: var(--sombra);
}

.hero h1 { color: #fff; margin: 0; }
.hero p { color: rgba(255,255,255,0.8); margin: 4px 0 0; }
.hero-logo { height: 40px; opacity: 0.95; }

/* ---------- Tarjetas ---------- */

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 3px solid var(--mod);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--sombra);
}

h1, h2, h3 { margin-top: 0; }

.section-title {
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--muted);
  margin: 20px 0 8px;
  border-left: 3px solid var(--mod);
  padding-left: 8px;
}

/* Secciones colapsables (ver public/app.js) */
.card-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.card-toggle h1, .card-toggle h2, .card-toggle h3 { margin: 0; }
.card-toggle-flecha {
  color: var(--muted);
  font-size: 13px;
  flex-shrink: 0;
  user-select: none;
}
.card-colapsada > *:not(.card-toggle) { display: none !important; }
.card-colapsada { padding-bottom: 14px; }

.subseccion {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px 12px 10px;
  margin: 12px 0;
  background: #fbf9f6;
}
.subseccion > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  padding: 8px 0;
  color: var(--mod);
}
.subseccion-contenido { padding-top: 2px; }

/* ---------- Wizard por pasos ---------- */

.stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0 14px;
  flex-wrap: wrap;
}
.stepper-paso {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--muted);
}
.stepper-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ece7df;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.stepper-paso.stepper-completo .stepper-num { background: var(--ok); color: #fff; }
.stepper-paso.stepper-activo { background: var(--card); border: 1px solid var(--mod); color: var(--mod); font-weight: 600; }
.stepper-paso.stepper-activo .stepper-num { background: var(--mod); color: #fff; }
.stepper-paso.stepper-bloqueado { cursor: not-allowed; opacity: 0.5; }
.stepper-linea { flex: 1; min-width: 16px; height: 1px; background: var(--line); }
.stepper-label { white-space: nowrap; }
@media (max-width: 480px) {
  .stepper-linea { display: none; }
  .stepper-label { display: none; }
}

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(22, 35, 44, 0.6);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
  z-index: 1000;
}
.modal-caja {
  width: 100%;
  max-width: 520px;
  margin: 0;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

/* ---------- Buscador desplegable ---------- */

.buscador-resultados {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-top: 4px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 6px 18px rgba(34,52,65,0.12);
}
.buscador-item {
  padding: 10px 12px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.buscador-item:last-child { border-bottom: none; }
.buscador-item:hover { background: #faf8f4; }

/* ---------- Calendario (Inicio) ---------- */

.calendario-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.calendario-dia-header {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  padding-bottom: 4px;
}
.calendario-celda {
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  font-size: 11px;
  background: #fff;
}
.calendario-vacia { border: none; background: transparent; }
.calendario-hoy { border-color: var(--mod); background: #fdf4e4; }
.calendario-num { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.calendario-hoy .calendario-num { color: var(--mod); }
.calendario-chip {
  display: block;
  background: var(--mod);
  color: #fff !important;
  border-radius: 4px;
  padding: 1px 4px;
  margin-bottom: 2px;
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
}
.calendario-chip-completo { background: var(--ok); }
@media (max-width: 560px) {
  .calendario-celda { min-height: 46px; font-size: 10px; }
  .calendario-dia-header { font-size: 9px; }
}

/* ---------- Botones (píldora, como el sitio) ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff !important;
  border: none;
  padding: 11px 20px;
  min-height: 44px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
  transition: background 0.15s ease, color 0.15s ease, transform 0.05s ease;
}

.btn:hover, .btn:focus-visible { background: var(--accent-dark); color: #fff !important; }
.btn:active { background: var(--accent-dark); transform: scale(0.98); }

.btn-secondary {
  background: transparent;
  color: var(--accent) !important;
  border: 1.5px solid var(--accent);
}

.btn-secondary:hover, .btn-secondary:focus-visible {
  background: var(--accent);
  color: #fff !important;
}
.btn-secondary:active { background: var(--accent-dark); color: #fff !important; }

.btn-small { padding: 7px 14px; font-size: 13px; min-height: 36px; }

button:not(.btn):not(.btn-secondary) {
  font-family: inherit;
  cursor: pointer;
}

/* ---------- Formularios ---------- */

form label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin: 12px 0 4px;
}

input, select, textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 16px; /* evita el zoom automático de iOS al enfocar */
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--rosa);
  box-shadow: 0 0 0 3px rgba(204, 51, 102, 0.12);
}

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

.error-box {
  background: #fbe9e7;
  color: var(--danger);
  padding: 11px 13px;
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 14px;
}

.ok-box {
  background: #e8f2e8;
  color: #2e6b34;
  padding: 11px 13px;
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 14px;
}

/* ---------- Tablas ---------- */

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; }
tbody tr:hover { background: #faf8f4; }

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-pendiente { background: #ece7df; color: #6b655c; }
.badge-en-progreso { background: #fdf1dc; color: var(--warn); }
.badge-completada { background: #e6f0e6; color: var(--ok); }
.badge-atrasada { background: #fbe9e7; color: var(--danger); }

.badge-contacto-inicial { background: #ece7df; color: #6b655c; }
.badge-recopilando-datos { background: #eaf1f8; color: #3a6ea5; }
.badge-cotizacion-pendiente { background: #fdf1dc; color: var(--warn); }
.badge-cotizacion-enviada { background: #eaf1f8; color: #3a6ea5; }
.badge-ganado { background: #e6f0e6; color: var(--ok); }
.badge-perdido-seguimiento { background: #fbe9e7; color: var(--danger); }

.pill-atraso {
  display: inline-block;
  background: #fbe9e7;
  color: var(--danger);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 4px;
}

/* ---------- Galerías / fotos ---------- */

.photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.photo-grid img {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}

/* ---------- Filtros / listas ---------- */

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.filters select { width: auto; min-width: 140px; }

.task-row { text-decoration: none; color: inherit; display: block; }
.task-row:hover { background: #faf8f4; }

/* ---------- Estadísticas ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.stat-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
  box-shadow: var(--sombra);
}
.stat-box .num { font-size: 27px; font-weight: 700; color: var(--mod); }
.stat-box .label { font-size: 12px; color: var(--muted); }

.bar-track {
  background: #ece7df;
  border-radius: 6px;
  height: 10px;
  width: 100%;
  overflow: hidden;
}
.bar-fill { background: var(--mod); height: 100%; }

/* ---------- Login ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: linear-gradient(160deg, #2c4356 0%, #223441 55%, #16232c 100%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  border-top: 4px solid var(--rosa);
  padding: 26px 24px;
}
.login-logo { width: 200px; max-width: 70%; display: block; margin: 4px auto 2px; }
.login-card h1 { text-align: center; }
.login-sub { text-align: center; color: var(--muted); font-size: 14px; margin-top: -4px; }

/* ---------- Comentarios ---------- */

.comments { margin-top: 10px; }
.comment { border-top: 1px solid var(--line); padding: 8px 0; font-size: 14px; }
.comment .meta { color: var(--muted); font-size: 12px; }

/* ---------- Tablas en móvil: cada fila se vuelve tarjeta ---------- */

@media (max-width: 560px) {
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tr { border-bottom: 1px solid var(--line); padding: 10px 0; }
  td { border: none; padding: 4px 0; }
  td::before {
    content: attr(data-label);
    display: inline-block;
    width: 110px;
    color: var(--muted);
    font-size: 12px;
  }
  h1 { font-size: 23px; }
}
