/**
 * Tracert System EAS - Capa de Diseño Moderno & Adaptabilidad Responsiva
 * Diseñado según ISO 9241 (Ergonomía) y WCAG 2.1 AA (Accesibilidad)
 * Optimizado para Smartphones (320px+), Tablets, POS Táctiles y Desktop
 */

:root {
  --tracert-bg: #0f172a;
  --tracert-card: #1e293b;
  --tracert-card-hover: #24344d;
  --tracert-border: rgba(255, 255, 255, 0.08);
  --tracert-primary: #3b82f6;
  --tracert-primary-hover: #2563eb;
  --tracert-success: #10b981;
  --tracert-warning: #f59e0b;
  --tracert-danger: #ef4444;
  --tracert-text: #f8fafc;
  --tracert-muted: #94a3b8;
}

/* ==========================================================================
   1. MEJORAS DE RESPONSIVIDAD Y LAYOUT GLOBAL
   ========================================================================== */
html, body {
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Evitar desbordamiento horizontal en dispositivos móviles */
body:not(.login-page) {
  background-color: #ecf0f5;
}

body:not(.login-page) .wrapper {
  width: 100% !important;
  min-height: 100vh;
  position: relative;
}

.wrapper, .content-wrapper, .main-footer {
  overflow-x: hidden;
}

/* Ajuste del contenedor de contenido */
.content {
  padding: 15px;
  min-height: calc(100vh - 105px);
}

@media (max-width: 767px) {
  .content {
    padding: 10px 8px;
  }
  
  .content-header {
    padding: 10px 10px 5px 10px;
  }
  
  .content-header > h1 {
    font-size: 20px;
  }
}

/* ==========================================================================
   2. CABEZOTE / HEADER RESPONSIVO
   ========================================================================== */
.main-header .logo {
  display: flex !important;
  align-items: center;
  justify-content: center;
  height: 50px;
  line-height: 50px;
  padding: 0 10px;
  overflow: hidden;
  transition: width 0.3s ease-in-out;
}

.main-header .logo img {
  max-height: 44px;
  width: auto;
  object-fit: contain;
}

@media (max-width: 767px) {
  .main-header .logo {
    width: 100% !important;
    float: none !important;
    text-align: center;
  }

  .main-header .navbar {
    margin: 0 !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .main-header .sidebar-toggle {
    padding: 14px 16px;
    font-size: 16px;
  }
}

/* ==========================================================================
   3. PANTALLA DE LOGIN RESPONSIVA & MODERNA
   ========================================================================== */
body.login-page {
  background: radial-gradient(circle at 50% 30%, #1e293b 0%, #0f172a 100%) !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
  padding: 15px;
}

.login-box {
  width: 100% !important;
  max-width: 400px !important;
  margin: 0 auto !important;
}

.login-box-body {
  background: rgba(30, 41, 59, 0.95) !important;
  color: var(--tracert-text) !important;
  border-radius: 16px;
  border: 1px solid var(--tracert-border);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
  padding: 25px 25px 30px 25px !important;
}

.login-box-body .login-box-msg {
  color: var(--tracert-muted) !important;
  font-size: 14px;
  padding-bottom: 20px;
}

.login-box-body .form-control {
  background: #0f172a !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  color: #ffffff !important;
  border-radius: 8px;
  height: 46px;
  font-size: 15px;
}

.login-box-body .form-control:focus {
  border-color: var(--tracert-primary) !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25) !important;
}

.login-box-body .btn-primary {
  background-color: var(--tracert-primary) !important;
  border-color: var(--tracert-primary) !important;
  border-radius: 8px;
  height: 46px;
  font-weight: 600;
  font-size: 15px;
  transition: all 0.2s ease;
}

.login-box-body .btn-primary:hover {
  background-color: var(--tracert-primary-hover) !important;
  transform: translateY(-1px);
}

/* ==========================================================================
   4. TABLAS DATATABLE 100% RESPONSIVAS
   ========================================================================== */
.table-responsive {
  border: none !important;
  margin-bottom: 0;
}

/* Mejoras táctiles para DataTables */
.table > thead > tr > th {
  background: #f1f5f9;
  color: #1e293b;
  font-weight: 600;
  font-size: 13px;
  border-bottom: 2px solid #cbd5e1;
  white-space: nowrap;
}

.table > tbody > tr > td {
  vertical-align: middle !important;
  font-size: 13.5px;
}

/* Scroll suave en tablas móviles */
@media (max-width: 767px) {
  div.dataTables_wrapper div.dataTables_length,
  div.dataTables_wrapper div.dataTables_filter,
  div.dataTables_wrapper div.dataTables_info,
  div.dataTables_wrapper div.dataTables_paginate {
    text-align: center !important;
    margin-top: 10px;
  }

  .dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 0.3em 0.6em !important;
    font-size: 12px;
  }

  /* Ajuste de botones en tablas */
  .table td .btn-group {
    display: flex;
    gap: 4px;
  }
}

/* ==========================================================================
   5. TARJETAS & CAJAS (SMALL-BOX) EN MÓVILES
   ========================================================================== */
.box {
  border-radius: 12px;
  border-top: 3px solid var(--tracert-primary);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

.small-box {
  border-radius: 12px !important;
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.small-box:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.12);
}

@media (max-width: 767px) {
  .small-box .inner h3 {
    font-size: 26px;
  }
  .small-box .icon {
    display: none; /* Ocultar ícono en móviles para ganar legibilidad de texto */
  }
}

/* ==========================================================================
   6. MICRO-INTERACCIONES & ESTADOS DE CARGA
   ========================================================================== */
.btn:active {
  transform: scale(0.98);
}

.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.75;
}

.btn-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: calc(50% - 8px);
  right: 12px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: tracert-spin 0.6s linear infinite;
}

@keyframes tracert-spin {
  to { transform: rotate(360deg); }
}

/* Accesibilidad y foco (WCAG 2.1) */
a:focus, button:focus, input:focus, select:focus {
  outline: 2px solid var(--tracert-primary) !important;
  outline-offset: 2px;
}
