/* =====================================
   TRAILERS CSS AISLADO - THX (CORREGIDO)
===================================== */

/* =========================
   LAYOUT
========================= */
.thx-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 22px;
  align-items: start;
}

.thx-main {
  min-width: 0;
}

.thx-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* =========================
   HEADER
========================= */
.thx-header {
  margin-bottom: 20px;
}

.thx-header h2 {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
  color: #111827;
}

/* =========================
   FILTROS
========================= */
.thx-filters-box {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 20px;
}

.thx-filters-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  align-items: end;
}

.thx-field {
  display: flex;
  flex-direction: column;
}

.thx-field label {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 6px;
}

.thx-field input,
.thx-field select {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font-size: 14px;
  background: white;
  box-sizing: border-box;
}

.thx-field input:focus,
.thx-field select:focus {
  outline: none;
  border-color: #2f56a6;
  box-shadow: 0 0 0 3px rgba(47,86,166,0.12);
}

/* =========================
   BOTONES
========================= */
.thx-btn {
  border: none;
  border-radius: 10px;
  height: 44px;
  padding: 0 18px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: 0.2s ease;
}

.thx-btn:hover {
  transform: translateY(-1px);
}

.thx-btn-primary {
  background: #2f56a6;
  color: white;
}

.thx-btn-primary:hover {
  background: #24468a;
}

.thx-btn-danger {
  background: #ea4335;
  color: white;
}

.thx-btn-danger:hover {
  background: #cf3528;
}

.thx-btn-light {
  background: #eef2f7;
  color: #111827;
}

.thx-btn-light:hover {
  background: #dde5ef;
}

.thx-btn-full {
  width: 100%;
}

.thx-filter-action {
  display: flex;
  align-items: end;
}

/* =========================
   TABLA
========================= */
.thx-table-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 16px;
}

.thx-table-scroll {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.thx-table-scroll::-webkit-scrollbar {
  height: 10px;
}

.thx-table-scroll::-webkit-scrollbar-thumb {
  background: #c7ced8;
  border-radius: 20px;
}

.thx-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
}

.thx-table th {
  background: #f3f4f6;
  color: #111827;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  padding: 12px 14px;
  white-space: nowrap;
}

.thx-table td {
  font-size: 14px;
  padding: 12px 14px;
  border-bottom: 1px solid #f1f1f1;
  white-space: nowrap;
}

.thx-table tbody tr:hover {
  background: #fafafa;
}

/* =========================
   BADGES
========================= */
.badge-activo {
  background: #e7f6ea;
  color: #1e8e3e;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge-inactivo {
  background: #fdeaea;
  color: #c62828;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

/* =========================
   ALERTAS
========================= */
.thx-alert-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 18px;
  min-height: 420px;
}

.thx-alert-card h3 {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 700;
  color: #111827;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* resumen superior */
.thx-alert-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

/* IMPORTANTE:
   si usas el HTML corregido con button + span interno
*/
.thx-alert-summary {
  border: none;
  border-radius: 12px;
  padding: 12px 10px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: 0.2s ease;
  text-align: center;
  line-height: 1.2;
}

.thx-alert-summary:hover {
  transform: translateY(-1px);
}

.thx-alert-summary-danger {
  background: #f9e0df;
  color: #df2c1d;
}

.thx-alert-summary-warn {
  background: #f8efc9;
  color: #b88900;
}

.thx-alert-summary span {
  color: inherit;
  font: inherit;
}

/* fallback si sigues usando id en button */
#countVencidos {
  background: #f9e0df;
  color: #df2c1d;
}

#countProximos {
  background: #f8efc9;
  color: #b88900;
}

/* lista */
.thx-alert-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 430px;
  overflow-y: auto;
  padding-right: 4px;
}

.thx-alert-list::-webkit-scrollbar {
  width: 8px;
}

.thx-alert-list::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 20px;
}

/* items generados por JS */
.thx-alert-list .alerta-item,
.thx-alert-list > div {
  background: #f6e8e8;
  border-left: 4px solid #e03122;
  border-radius: 10px;
  padding: 14px 16px;
  line-height: 1.35;
}

.thx-alert-list .alerta-titulo {
  display: block;
  font-size: 16px;
  font-weight: 800;
  color: #111827;
  margin-bottom: 6px;
}

.thx-alert-list .alerta-tipo,
.thx-alert-list .alerta-concepto {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 2px;
}

.thx-alert-list .alerta-fecha,
.thx-alert-list small {
  display: block;
  font-size: 13px;
  color: #4b5563;
  font-weight: 600;
}

/* próximas */
.thx-alert-list .proximo {
  background: #fff8e6;
  border-left-color: #f59e0b;
}

/* =========================
   MODAL
========================= */
.thx-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
}

.hidden {
  display: none !important;
}

.thx-modal-box {
  background: white;
  width: min(92vw, 460px);
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.18);
}

.thx-modal-box h3 {
  margin: 0 0 18px;
  font-size: 24px;
  color: #111827;
}

.thx-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.thx-modal-actions {
  grid-column: span 2;
  display: flex;
  justify-content: stretch;
  margin-top: 8px;
}

.thx-modal-actions .thx-btn {
  width: 100%;
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 1100px) {
  .thx-layout {
    grid-template-columns: 1fr;
  }

  .thx-sidebar {
    order: 2;
  }

  .thx-main {
    order: 1;
  }
}

@media (max-width: 768px) {
  .thx-header h2 {
    font-size: 28px;
  }

  .thx-filters-grid {
    grid-template-columns: 1fr;
  }

  .thx-filter-action {
    display: block;
  }

  .thx-btn {
    width: 100%;
  }

  .thx-alert-actions {
    grid-template-columns: 1fr;
  }

  .thx-form-grid {
    grid-template-columns: 1fr;
  }

  .thx-modal-actions {
    grid-column: span 1;
    flex-direction: column-reverse;
  }

  .thx-table {
    min-width: 720px;
  }

  .thx-alert-card {
    min-height: auto;
  }
}

@media (max-width: 480px) {
  .thx-header h2 {
    font-size: 24px;
  }

  .thx-filters-box,
  .thx-table-card,
  .thx-alert-card,
  .thx-modal-box {
    padding: 14px;
  }
}

/* =====================================
   TRAILER INLINE EDIT ONLY
   Solo cuando aparece input/select
===================================== */

.thx-table td input,
.thx-table td select{
  width:100%;
  height:36px;
  padding:0 12px;
  border:1px solid #d1d5db;
  border-radius:8px;
  background:#fff;
  font-size:13px;
  color:#111827;
  box-sizing:border-box;
  transition:.2s ease;
}

/* focus bonito */
.thx-table td input:focus,
.thx-table td select:focus{
  outline:none;
  border-color:#2f56a6;
  box-shadow:0 0 0 3px rgba(47,86,166,.12);
}

/* fechas */
.thx-table td input[type="date"]{
  min-width:145px;
}

/* selects */
.thx-table td select{
  min-width:120px;
}

/* =====================================
   AJUSTE COMPACTO TRAILER
   AGREGAR AL FINAL
===================================== */

/* layout general */
.thx-layout{
  gap:16px !important;
}

/* header */
.thx-header{
  margin-bottom:14px !important;
}

.thx-header h2{
  font-size:28px !important;
}

/* botones */
.thx-btn{
  height:34px !important;
  padding:0 14px !important;
  font-size:12px !important;
  border-radius:9px !important;
}

/* =========================
   FILTROS EN UNA FILA
========================= */
.thx-filters-box{
  padding:14px !important;
  margin-bottom:14px !important;
}

.thx-filters-grid{
  grid-template-columns:
    1.2fr   /* placa */
    1.2fr   /* propietario */
    .95fr   /* estado */
    .85fr   /* limpiar */
    !important;

  gap:8px !important;
}

.thx-field label{
  font-size:11px !important;
  margin-bottom:4px !important;
}

.thx-field input,
.thx-field select{
  height:34px !important;
  font-size:12px !important;
  padding:0 10px !important;
  border-radius:9px !important;
}

.thx-filter-action .thx-btn{
  width:100% !important;
}

/* =========================
   TABLA MÁS COMPACTA
========================= */
.thx-table-card{
  padding:12px !important;
}

.thx-table th{
  font-size:12px !important;
  padding:10px 12px !important;
}

.thx-table td{
  font-size:12px !important;
  padding:10px 12px !important;
}

/* =========================
   ALERTAS MÁS PEQUEÑAS
========================= */
.thx-alert-card{
  padding:14px !important;
  min-height:380px !important;
}

.thx-alert-card h3{
  font-size:18px !important;
  margin-bottom:12px !important;
}

.thx-alert-actions{
  gap:8px !important;
  margin-bottom:12px !important;
}

.thx-alert-summary{
  padding:10px !important;
  font-size:12px !important;
}

.thx-alert-list .alerta-item,
.thx-alert-list > div{
  padding:10px 12px !important;
}

.thx-alert-list .alerta-titulo{
  font-size:14px !important;
}

.thx-alert-list .alerta-fecha{
  font-size:11px !important;
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width:1400px){

  .thx-filters-grid{
    grid-template-columns:repeat(2,1fr) !important;
  }
}

@media (max-width:768px){

  .thx-filters-grid{
    grid-template-columns:1fr !important;
  }

  .thx-btn{
    width:100% !important;
  }

  .thx-layout{
    grid-template-columns:1fr !important;
  }
}

/* =====================================
   TRAILER - INPUTS INLINE MÁS PEQUEÑOS
   AGREGAR AL FINAL
===================================== */

.thx-table td input,
.thx-table td select{
  height:30px !important;
  min-height:30px !important;
  padding:0 8px !important;
  font-size:12px !important;
  border-radius:8px !important;
  max-width:100% !important;
}

/* ancho específico por columna */
.thx-table td input[type="text"]{
  width:120px !important;
}

.thx-table td input[type="date"]{
  width:130px !important;
}

.thx-table td select{
  width:180px !important;
}

/* celda edición más limpia */
.thx-table td{
  vertical-align:middle !important;
}

/* =====================================
   ESPACIADO IGUAL A CLIENTES
===================================== */

.thx-layout{
  padding:14px !important;
}

/* =====================================
   TRAILER - ALERTAS MISMO TAMAÑO CONDUCTORES
===================================== */

/* layout exacto */
.thx-layout{
  grid-template-columns:minmax(0,1fr) 290px !important;
  gap:16px !important;
}

/* card alertas */
.thx-alert-card{
  padding:14px !important;
  min-height:360px !important;
}

/* titulo alertas */
.thx-alert-card h3{
  font-size:16px !important;
  margin-bottom:12px !important;
}

/* resumen superior */
.thx-alert-actions{
  gap:8px !important;
  margin-bottom:12px !important;
}

.thx-alert-summary{
  padding:10px !important;
  font-size:12px !important;
}

/* lista */
.thx-alert-list{
  max-height:340px !important;
}

/* items */
.thx-alert-list .alerta-item,
.thx-alert-list > div{
  padding:10px 12px !important;
}

/* texto */
.thx-alert-list .alerta-titulo{
  font-size:13px !important;
}

.thx-alert-list .alerta-fecha,
.thx-alert-list small{
  font-size:11px !important;
}