/* =========================================================
   TSGJ UI — Estilos Unificados
   Autor: Klisman + ChatGPT
   ========================================================= */

/* -------------------- Variables de Tema -------------------- */
:root{
  --primary:        #007BFF;
  --primary-dark:   #0056b3;
  --text:           #333;
  --muted:          #5f6b7a;
  --bg:             #f7f8fb;
  --white:          #ffffff;
  --card-border:    #e9eef5;
  --line:           #eef2f7;
  --table-border:   #e0e0e0;
  --thead-bg:       #d6e6ff;
  --shadow-soft:    0 6px 20px rgba(0,0,0,.05);
  --radius-sm:      6px;
  --radius-md:      8px;
  --radius-lg:      14px;
  --radius-xl:      16px;
}

/* ==================== BASE / GENERALES ==================== */
*{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 20px;
}
.container h2{
  text-align: center;
  color: var(--text);
  margin-bottom: 20px;
}

/* ==================== LAYOUT DE PÁGINA ==================== */
.page-header{
  padding: 1.75rem 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  text-align: center;
}
.page-header h2{
  margin: 0;
  font-weight: 700;
  letter-spacing: .2px;
  color: #0b1e3a;
}
.page-subtitle{ font-size: .9rem; color: var(--muted); }
.page-actions{
  padding: 1rem 1.25rem;
  display: flex; gap: .5rem; flex-wrap: wrap;
  align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.left-actions, .right-actions{ display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.badge-toggle{ font-size: .85rem; }
.view-wrap{ padding: 1rem 1.25rem 1.5rem; }

/* ==================== BOTONES (UNIFICADOS) ==================== */
/* Grupo de acciones centrado por defecto */
.button-borders{
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

/* Primario sólido (mantiene tu .button-name) */
.button-name{
  padding: 10px 20px;
  font-size: 16px;
  background: var(--white);
  border: 2px solid var(--primary);
  color: var(--primary);
  border-radius: var(--radius-sm);
  transition: all .3s ease;
  cursor: pointer;
}
.button-name:hover{ background: var(--primary); color: #fff; }

/* Variante suave/secondary (para “Actualizar”, etc.) */
.btn-soft{
  border: 1px solid #dbe4f0;
  background: #f4f7fc;
  color: var(--primary);
  padding: .5rem .9rem;
  border-radius: 10px;
  font-weight: 600;
  transition: background .2s ease;
}
.btn-soft:hover{ background: #e9f1ff; }

/* Conmutador de vistas (usa botones tipo .btn dentro de .switch-group) */
.switch-group .btn{
  border: 1px solid #dbe4f0;
  background: #fff;
  color: #334155;
  font-weight: 600;
  padding: .5rem .9rem;
  border-radius: 10px;
}
.switch-group .btn.active{
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 0 2px rgba(13,110,253,.15) inset;
}

/* Botón alternar tarjetas (móvil) */
#toggleViewBtn{
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
#toggleViewBtn:hover{ background: var(--primary-dark); }

/* ==================== TABLAS (BASE + DATATABLES) ==================== */
.table-wrapper{ overflow-x: auto; max-width: 100%; }
@media (min-width: 768px){
  .table-wrapper{ overflow-x: visible !important; }
}

/* Wrapper específico (lo conservamos por compatibilidad) */
#tablaRutas_wrapper{ overflow-x: auto; width: 100%; }

/* Tabla base */
table{
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  box-shadow: 0 0 10px rgba(0,0,0,.05);
  border-radius: var(--radius-md);
  font-size: 13px;
}
thead th{
  background: var(--thead-bg);
  color: #000;
  font-weight: bold;
  text-align: center;
  padding: 10px;
}
th, td{
  padding: 12px 10px;
  text-align: center;
  border: 1px solid var(--table-border);
}
tbody tr:nth-child(even){ background: #f3f3f3; }
td.text-start{ text-align: left !important; }

/* Alineación numérica específica para tus tablas */
table.dataTable thead th{ white-space: nowrap; }
#tablaAbastecimientos td:nth-child(6),
#tablaAbastecimientos td:nth-child(7),
#tablaAbastecimientos td:nth-child(8),
#tablaAbastecimientosGaloneras td.num{
  text-align: right; white-space: nowrap;
}

/* DataTables: botonera coherente con el tema */
.dt-buttons{ margin: .5rem 0 .75rem .25rem !important; }
.dt-buttons .dt-button{
  border: 1px solid #dbe4f0 !important;
  background: #fff !important;
  color: #334155 !important;
  border-radius: 10px !important;
  padding: .4rem .7rem !important;
  font-weight: 600 !important;
  transition: background .2s ease !important;
}
.dt-buttons .dt-button:hover{
  background: #f7faff !important;
  color: var(--primary) !important;
}

/* Si prefieres los botones azules “clásicos”, descomenta:
.dt-button{
  background: var(--primary) !important;
  color: #fff !important;
  border: none !important;
  border-radius: 5px !important;
  padding: 6px 14px !important;
  margin: 2px !important;
  font-size: 14px !important;
}
.dt-button:hover{ background: var(--primary-dark) !important; }
*/

/* Mejoras de contenido en celdas DataTable */
table.dataTable td{
  white-space: normal !important;
  word-break: break-word;
  vertical-align: top;
}

/* ==================== ÍCONOS EN OPCIONES ==================== */
td a i{
  color: var(--primary);
  margin: 0 5px;
  font-size: 18px;
  transition: transform .2s ease;
}
td a i:hover{ transform: scale(1.2); }

/* ==================== TARJETAS MÓVILES ==================== */
#tarjetasResponsive.d-none{ display: none !important; }
#tarjetasResponsive:empty{ display: none; height: auto; min-height: 0; }

.card{ border-radius: var(--radius-lg); }           /* tarjetas Bootstrap genéricas */
.card .card-title{ font-weight: 700; }

.card-driver{
  background: #fff;
  border: 1px solid #ddd;
  border-radius: var(--radius-md);
  padding: 15px;
  margin-bottom: 15px;
  box-shadow: 0 2px 4px rgba(0,0,0,.05);
}
.card-driver h5{ margin-bottom: 10px; color: var(--primary); font-size: 18px; }
.card-driver p{ margin: 4px 0; font-size: 15px; color: #444; }
.card-driver .btn-group{ margin-top: 10px; display: flex; gap: 8px; }
.card-driver .btn-driver{
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  gap: 5px; padding: 6px 10px; font-size: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--primary);
  background: #fff; color: var(--primary);
  text-align: center; text-decoration: none;
  transition: all .3s ease;
}
.card-driver .btn-driver:hover{ background: var(--primary); color: #fff; }
.card-driver .btn-driver i{ margin-right: 5px; font-size: 16px; vertical-align: middle; }

/* ==================== ESTADOS / UTILIDADES ==================== */
.pagination-controls{ display: flex; justify-content: center; gap: 10px; margin-top: 15px; }
.fila-inactiva{ background: #ffe6e6 !important; }
.card-inactiva{ background: #ffe6e6; border: 1px solid #dc3545; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px){
  .button-borders{ flex-direction: column; align-items: center; }
  th, td{ font-size: 14px; padding: 8px; }
}
