/* =============================================================================
   CUSTOM CSS - PLANTILLA DJANGO
   Estilos personalizados del proyecto
   ============================================================================= */

.container {
  margin: 0 auto;
  max-width: 1280px;
  width: 90%;
}

@media only screen and (min-width: 601px) {
  .container { width: 85%; }
}

@media only screen and (min-width: 993px) {
  .container { width: 90%; }
}

/* Tabla con header uniforme */
table.responsive-table.striped thead th {
  background-color: #d0d0d0 !important;
  border-radius: 0px !important;
  border: none !important;
}

table.responsive-table.striped thead tr {
  border-spacing: 0;
  border-collapse: collapse;
  border-radius: 0px !important;
}

/* Labels de inputs uniformes */
.input-field label,
.input-field label.active {
  font-size: 1.2rem !important;
}

/* Sin animación en labels */
.input-field label {
  transition: none !important;
}

.input-field input:focus + label,
.input-field input:not(:placeholder-shown) + label,
.input-field input:valid + label {
  transform: translateY(-14px) scale(0.8) !important;
}

/* File input mejorado */
.file-path-wrapper {
  display: none !important;
}

.file-field .btn {
  position: relative;
  min-width: 250px;
  background-color: var(--primary, #003366);
  color: white;
  font-weight: 600;
  border-radius: 8px;
  padding: 0 20px;
  height: 42px;
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.file-field .btn:hover {
  background-color: var(--primary-medium, #004a99);
}

/* HTMX indicator */
.htmx-indicator {
  opacity: 0;
  transition: opacity 500ms ease-in;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

/* Mensajes Django */
#messages-queue {
  display: none;
}

/* Fondo general */
body {
  background-color: #f5f5f5 !important;
}

/* Tabs */
.tabs .indicator {
  background-color: var(--primary, #003366);
  height: 4px;
}

.tabs .tab a.active {
  background-color: var(--primary-light, #e8f0fb) !important;
}

/* ── Formularios: errores, obligatorios y ayudas ─────────────────────────── */
.errores-form {
  border-left: 4px solid #b3261e; background: #fdecea; color: #5f1410;
  padding: 12px 16px; border-radius: 6px; margin-bottom: 16px;
}
.errores-form ul { margin: 6px 0 0 18px; }
.errores-form li { list-style: disc; }
.errores-form a { color: #5f1410; text-decoration: underline; }
.error-campo, .errorlist { color: #b3261e; font-size: 0.8rem; display: block; margin-top: 2px; }
.errorlist { padding-left: 0; list-style: none; }
.con-error input, .con-error select, .con-error textarea { border-bottom-color: #b3261e !important; }
.obligatorio { color: #b3261e; }
.helper-text { font-size: 0.75rem; color: #78909C; }
.aviso-info {
  border-left: 4px solid #004a99; background: #e8f0fb; padding: 10px 14px; border-radius: 6px; margin: 8px 0 12px;
}
.aviso-alerta {
  border-left: 4px solid #e65100; background: #fff3e0; padding: 10px 14px; border-radius: 6px; margin: 8px 0 12px;
}

/* ── Acciones con motivo (devolver / observar / anular) ──────────────────── */
details.accion-motivo { display: inline-block; vertical-align: top; }
details.accion-motivo > summary { list-style: none; cursor: pointer; }
details.accion-motivo > summary::-webkit-details-marker { display: none; }
details.accion-motivo[open] > summary { opacity: .7; }
details.accion-motivo form {
  margin-top: 8px; padding: 12px; border: 1px solid #e0e0e0; border-radius: 6px; background: #fff;
  min-width: 300px; max-width: 480px;
}

/* ── Estados (chips) ─────────────────────────────────────────────────────── */
.estado { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 0.8rem; white-space: nowrap;
  background: #eceff1; color: #37474f; }
.estado-pendiente, .estado-borrador { background: #fff8e1; color: #7a5a00; }
.estado-observado, .estado-rechazado, .estado-rescindido { background: #fdecea; color: #8c1d18; }
.estado-factura_recibida, .estado-enviado, .estado-en_liquidacion, .estado-en_despacho, .estado-pendiente_resolucion { background: #e8f0fb; color: #003366; }
.estado-autorizado, .estado-aprobado, .estado-vigente, .estado-resuelto { background: #e8f5e9; color: #1b5e20; }
.estado-pagado, .estado-finalizado { background: #eceff1; color: #37474f; }

/* ── Listados ────────────────────────────────────────────────────────────── */
.atajos { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; }
.atajos a { padding: 4px 12px; border-radius: 16px; border: 1px solid #c5cae9; color: #003366; font-size: 0.85rem; }
.atajos a.activo { background: #003366; color: #fff; border-color: #003366; }
.num { text-align: right; white-space: nowrap; }
.barra-lote { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 8px 0; }

/* ── Formulario de personas ──────────────────────────────────────────────── */
.persona-form { max-width: 1040px; margin: 0 auto; padding-bottom: 72px; }
.pf-encabezado h4 { font-size: 1.6rem; font-weight: 600; color: #003366; margin: 0 0 4px; }
.pf-encabezado p { color: #607d8b; margin: 0 0 16px; font-size: 0.9rem; }
.pf-seccion { border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.08) !important; margin: 0 0 16px; }
.pf-seccion .card-content { padding: 20px 24px 8px; }
.pf-titulo {
  display: flex; align-items: center; gap: 10px; font-size: 1.05rem; font-weight: 600; color: #003366;
  margin: 0 0 16px; padding-bottom: 10px; border-bottom: 1px solid #eceff1;
}
.pf-titulo .material-icons { color: #C8A84B; font-size: 22px; }
.pf-seccion .row { margin-bottom: 0; }
.pf-seccion .input-field { margin-top: 0.6rem; margin-bottom: 1.1rem; }
.pf-ayuda { color: #607d8b; font-size: 0.88rem; margin: 0 0 14px; }
.pf-check { display: inline-flex; align-items: center; cursor: pointer; }
.pf-check input[type=checkbox] { position: static !important; opacity: 1 !important; pointer-events: auto !important;
  width: 18px; height: 18px; margin: 0 8px 0 0; accent-color: #003366; }
.pf-check span { color: #37474f; font-size: 0.95rem; padding-left: 0 !important; }
.pf-check span::before, .pf-check span::after { display: none !important; }
.persona-form .select2-container { margin-top: 6px; }

.pf-acciones {
  position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 16px; margin-top: 8px; background: rgba(255,255,255,.96); border-top: 1px solid #e0e0e0;
  border-radius: 10px 10px 0 0; box-shadow: 0 -2px 8px rgba(0,0,0,.06);
}

/* Documentación */
.doc-lista { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.doc-item {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 20px; align-items: center;
  border: 1px solid #e0e6ea; border-left: 4px solid #cfd8dc; border-radius: 8px; padding: 12px 16px; background: #fff;
}
.doc-item.doc-vigente { border-left-color: #2e7d32; }
.doc-item.doc-por_vencer { border-left-color: #ef6c00; }
.doc-item.doc-vencido, .doc-item.doc-falta, .doc-item.con-error { border-left-color: #b3261e; }
.doc-item.doc-elegido { border-left-color: #004a99; background: #f5f9ff; }
.doc-nombre { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-weight: 600; color: #263238; }
.doc-nombre .material-icons { color: #b3261e; font-size: 20px; }
.doc-chip { font-size: 0.7rem; font-weight: 500; padding: 1px 8px; border-radius: 10px; background: #eceff1; color: #455a64; }
.doc-chip-obl { background: #fdecea; color: #8c1d18; }
.doc-desc { margin: 4px 0 0; color: #78909c; font-size: 0.82rem; }
.doc-actual { margin: 6px 0 0; font-size: 0.82rem; color: #607d8b; }
.doc-actual a { color: #004a99; font-weight: 500; }
.doc-actual-falta { color: #b3261e; display: flex; align-items: center; gap: 4px; }
.doc-carga { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.doc-archivo {
  display: inline-flex; align-items: center; gap: 6px; max-width: 280px; cursor: pointer;
  border: 1px dashed #90a4ae; border-radius: 6px; padding: 8px 12px; color: #003366; font-size: 0.85rem; font-weight: 500;
  background: #fafcfd; transition: border-color .15s, background .15s;
}
.doc-archivo:hover, .doc-archivo:focus-within { border-color: #003366; background: #eef4fb; }
.doc-archivo input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.doc-archivo-texto { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-venc { display: flex; align-items: center; gap: 6px; }
.doc-venc label { font-size: 0.85rem; color: #455a64; white-space: nowrap; }
.doc-venc input.datepicker { width: 120px !important; height: 2.2rem !important; margin: 0 !important; text-align: center; }
.doc-quitar span { font-size: 0.85rem; }
.doc-error { grid-column: 1 / -1; margin: 0; }
@media only screen and (max-width: 700px) {
  .doc-item { grid-template-columns: 1fr; }
  .doc-carga { justify-content: flex-start; }
}

/* Estados de documentos */
.estado-doc-vigente { background: #e8f5e9; color: #1b5e20; }
.estado-doc-por_vencer { background: #fff3e0; color: #8a3c00; }
.estado-doc-vencido, .estado-doc-falta { background: #fdecea; color: #8c1d18; }

/* Checkbox con etiqueta y ayuda (plantilla _campo.html) */
.campo-check { margin: 0.4rem 0 1rem; }
.campo-check > label { display: inline-flex; align-items: center; cursor: pointer; }
.campo-check > label > span { color: #263238; font-size: 1rem; }
.campo-check .helper-text { display: block; margin: 2px 0 0 35px; }
.estado-baja { background: #fdecea; color: #8c1d18; }

/* Edición del plan de facturación */
.plan-monto { display: inline-flex; align-items: center; gap: 6px; }
.plan-monto input.plan-input { width: 150px !important; text-align: right; margin: 0 !important; height: 2.2rem !important; }
.plan-monto input.plan-cambiado { border-bottom: 2px solid #ef6c00 !important; background: #fff8e1; }

/* ── Formulario de personas: tipografía y campos más suaves ─────────────── */
.persona-form { --pf-texto: #37474f; --pf-etiqueta: #607d8b; --pf-linea: #cfd8dc; --pf-foco: #003366; }

/* Etiquetas fijas arriba del campo (sin la animación de Materialize) */
.persona-form .input-field > label,
.persona-form .input-field > label.active {
  position: static !important; transform: none !important; display: block;
  font-size: 0.78rem !important; font-weight: 500; letter-spacing: 0.02em;
  color: var(--pf-etiqueta) !important; margin-bottom: 2px;
}
.persona-form .input-field { display: flex; flex-direction: column; }
.persona-form .input-field > label { order: -1; }
.persona-form .input-field:focus-within > label { color: var(--pf-foco) !important; }

/* Campos de texto, fecha y desplegables con el mismo aspecto */
.persona-form .input-field input:not([type=checkbox]):not([type=file]),
.persona-form .input-field select.browser-default {
  height: 2.4rem !important; margin: 0 !important; padding: 0 2px !important;
  font-size: 0.95rem !important; font-weight: 400; color: var(--pf-texto) !important;
  background: transparent; border: none !important; border-bottom: 1px solid var(--pf-linea) !important;
  border-radius: 0; box-shadow: none !important; transition: border-color .15s, box-shadow .15s;
}
.persona-form .input-field input:focus:not([readonly]),
.persona-form .input-field select.browser-default:focus {
  outline: none; border-bottom: 1px solid var(--pf-foco) !important; box-shadow: 0 1px 0 0 var(--pf-foco) !important;
}
.persona-form .input-field input::placeholder { color: #b0bec5; font-weight: 300; }
.persona-form .input-field select.browser-default { cursor: pointer; }
.persona-form .input-field .helper-text { margin-top: 4px; min-height: 0; }
.persona-form .con-error input, .persona-form .con-error select { border-bottom-color: #b3261e !important; }

/* Select2 (título y actividad económica) */
.persona-form .select2-container { margin-top: 0; }
.persona-form .select2-container--default .select2-selection--single {
  height: 2.4rem; border: none; border-bottom: 1px solid var(--pf-linea); border-radius: 0; background: transparent;
}
.persona-form .select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 2.4rem; padding-left: 2px; color: var(--pf-texto); font-size: 0.95rem;
}
.persona-form .select2-container--default .select2-selection--single .select2-selection__arrow { height: 2.4rem; }
.persona-form .select2-container--focus .select2-selection--single,
.persona-form .select2-container--open .select2-selection--single {
  border-bottom-color: var(--pf-foco); box-shadow: 0 1px 0 0 var(--pf-foco);
}

/* Títulos y textos secundarios */
.persona-form .pf-check span { color: var(--pf-texto); font-size: 0.92rem; }
.persona-form .doc-nombre { color: var(--pf-texto); font-weight: 500; }
/* Que un texto largo (p. ej. la actividad económica) no ensanche la página en el celular */
.persona-form .input-field, .persona-form .input-field > * { min-width: 0; max-width: 100%; }
.persona-form .select2-container { width: 100% !important; }
.persona-form .select2-selection__rendered { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
