/* ==========================================================================
   TUMSA - PLATAFORMA LOGÍSTICA & TRANSPORTE
   Identidad Oficial: tumsa.com.mx & Directrices de UX/UI uupm.cc
   Colores Corporativos: Azul Marino (#0F206C), Azul Noche (#0A1445), Cyan (#00A0DF)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400;1,600&display=swap');

:root {
  --tumsa-navy: #0F206C;
  --tumsa-navy-dark: #0A1445;
  --tumsa-navy-deep: #060D2E;
  --tumsa-cyan: #00A0DF;
  --tumsa-cyan-dark: #0077B6;
  --tumsa-cyan-light: #E0F2FE;
  --tumsa-cyan-stripe: #7DD3FC;
  --tumsa-cyan-stripe-bg: #BAE6FD;
  --tumsa-orange: #F97316;
  --tumsa-bg: #ECEEF2;
  --tumsa-card-bg: #FFFFFF;
  --tumsa-border: #E2E8F0;
  --tumsa-text-main: #0F172A;
  --tumsa-text-muted: #64748B;
  --tumsa-radius-card: 26px;
  --tumsa-shadow-card: 0 4px 20px -2px rgba(15, 32, 108, 0.05), 0 1px 3px rgba(0, 0, 0, 0.02);
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--tumsa-bg);
  color: var(--tumsa-text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Tarjetas Bento Idénticas a la Estructura de Referencia */
.tumsa-bento-card {
  background: var(--tumsa-card-bg);
  border-radius: var(--tumsa-radius-card);
  box-shadow: var(--tumsa-shadow-card);
  border: 1px solid rgba(226, 232, 240, 0.9);
  transition: all 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

.tumsa-bento-card:hover {
  box-shadow: 0 12px 30px -4px rgba(15, 32, 108, 0.08);
}

/* Barra Superior Flotante Tipo Cápsula (Idéntica a la Imagen) */
/* Control de Altura de Pantalla Completa y Viewport */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body.in-login {
  overflow-y: auto;
  min-height: 100vh;
}

body.in-dashboard {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

/* Barra Superior Flotante Tipo Cápsula (Sticky para acompañar navegación) */
.floating-nav-island {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #FFFFFF;
  border-radius: 9999px;
  box-shadow: 0 4px 20px -3px rgba(15, 32, 108, 0.08);
  border: 1px solid rgba(226, 232, 240, 0.9);
}

/* ==========================================================================
   ESTILO 1: BARRA LATERAL FLOTANTE TIPO CÁPSULA (ICONOS)
   ========================================================================== */
.floating-sidebar-island {
  position: fixed;
  left: 0.875rem;
  top: 0.875rem;
  bottom: 0.875rem;
  width: 4.25rem; /* 68px */
  border-radius: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 0.5rem;
  z-index: 40;
  background: linear-gradient(180deg, #0F206C 0%, #0A1445 52%, #060D2E 100%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 14px 38px -4px rgba(10, 20, 69, 0.48), 0 2px 10px rgba(0, 0, 0, 0.22);
  transition: all 240ms cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.floating-sidebar-island::-webkit-scrollbar {
  display: none;
}

.floating-sidebar-island .sidebar-btn-inactive {
  color: rgba(255, 255, 255, 0.75);
  background: transparent;
}
.floating-sidebar-island .sidebar-btn-inactive:hover {
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.16);
}
.floating-sidebar-island .sidebar-btn-active {
  background: #FFFFFF !important;
  color: #0F206C !important;
  box-shadow: 0 4px 14px -2px rgba(0, 0, 0, 0.3);
}
.floating-sidebar-island .sidebar-btn-logout {
  color: rgba(255, 255, 255, 0.72);
}
.floating-sidebar-island .sidebar-btn-logout:hover {
  color: #FCA5A5;
  background: rgba(239, 68, 68, 0.22);
}
.floating-sidebar-island .sidebar-divider-line {
  border-color: rgba(255, 255, 255, 0.16);
}
.floating-sidebar-island .sidebar-tooltip {
  background: #FFFFFF;
  color: #0F206C;
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: 0 8px 24px -2px rgba(0, 0, 0, 0.25);
}

/* ==========================================================================
   ESTILO 2: PANEL LATERAL COMPLETO CON BOTONES (DASHBOARD CLÁSICO)
   ========================================================================== */
.panel-sidebar-full {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 15.5rem; /* 248px */
  height: 100vh;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1rem 0.875rem;
  z-index: 40;
  background: linear-gradient(180deg, #0F206C 0%, #0A1445 52%, #060D2E 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 6px 0 28px -4px rgba(10, 20, 69, 0.35);
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  transition: all 240ms cubic-bezier(0.16, 1, 0.3, 1);
}
.panel-sidebar-full::-webkit-scrollbar {
  display: none;
}

.panel-sidebar-full .panel-nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.45rem 0.75rem;
  border-radius: 0.75rem;
  font-size: 0.75rem; /* 12px */
  font-weight: 600;
  transition: all 160ms ease;
  cursor: pointer;
  text-align: left;
}

.panel-sidebar-full .panel-nav-btn-inactive {
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
}
.panel-sidebar-full .panel-nav-btn-inactive:hover {
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.12);
  transform: translateX(2px);
}
.panel-sidebar-full .panel-nav-btn-active {
  background: #FFFFFF !important;
  color: #0F206C !important;
  font-weight: 700;
  box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.25);
}

/* Conmutación entre Estilo Barra Flotante y Estilo Panel Lateral */
body.sidebar-mode-floating #sidebarFloating {
  display: flex;
}
body.sidebar-mode-floating #sidebarPanel {
  display: none !important;
}
body.sidebar-mode-floating .tumsa-main-content {
  margin-left: 5.375rem;
  width: calc(100% - 5.375rem);
}

body.sidebar-mode-panel #sidebarFloating {
  display: none !important;
}
body.sidebar-mode-panel #sidebarPanel {
  display: flex;
}
body.sidebar-mode-panel .tumsa-main-content {
  margin-left: 15.5rem;
  width: calc(100% - 15.5rem);
}

/* Contenedor principal a todo lo ancho con scroll vertical fluido */
.tumsa-main-content {
  height: 100vh;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.5rem 0.875rem 1.5rem 0.875rem;
  scroll-behavior: smooth;
}

/* Scrollbar corporativa TUMSA estilizada */
.tumsa-main-content::-webkit-scrollbar,
#bentoDashboardGrid::-webkit-scrollbar,
.overflow-y-auto::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.tumsa-main-content::-webkit-scrollbar-track,
#bentoDashboardGrid::-webkit-scrollbar-track,
.overflow-y-auto::-webkit-scrollbar-track {
  background: rgba(241, 245, 249, 0.6);
  border-radius: 9999px;
}

.tumsa-main-content::-webkit-scrollbar-thumb,
#bentoDashboardGrid::-webkit-scrollbar-thumb,
.overflow-y-auto::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 9999px;
  transition: background 0.2s;
}

.tumsa-main-content::-webkit-scrollbar-thumb:hover,
#bentoDashboardGrid::-webkit-scrollbar-thumb:hover,
.overflow-y-auto::-webkit-scrollbar-thumb:hover {
  background: #0F206C;
}

.tumsa-main-content,
#bentoDashboardGrid,
.overflow-y-auto {
  scrollbar-width: thin;
  scrollbar-color: #CBD5E1 rgba(241, 245, 249, 0.6);
}

/* Contenedor Bento adaptable */
#bentoDashboardGrid {
  flex: 1;
  width: 100%;
  min-height: 0;
}

@media (max-width: 1024px) {
  html, body, body.in-dashboard {
    height: auto;
    overflow-y: auto;
  }
  #appScreen {
    height: auto;
    overflow-y: auto;
  }
  .floating-sidebar-island,
  .panel-sidebar-full {
    transform: translateX(-150%);
    transition: transform 250ms ease;
  }
  .floating-sidebar-island.open,
  .panel-sidebar-full.open {
    transform: translateX(0);
  }
  body.sidebar-mode-floating .tumsa-main-content,
  body.sidebar-mode-panel .tumsa-main-content {
    margin-left: 0;
    width: 100%;
    height: auto;
    min-height: 100vh;
    overflow-y: visible;
    padding-bottom: 2rem;
  }
  #bentoDashboardGrid {
    overflow-y: visible;
  }
}

/* Botón circular con flecha de acción (Idéntico a la Imagen) */
.arrow-circle-btn {
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  border: 1px solid #E2E8F0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748B;
  background: #FFFFFF;
  transition: all 180ms ease;
  cursor: pointer;
  flex-shrink: 0;
}
.arrow-circle-btn:hover {
  background: #F8FAFC;
  color: var(--tumsa-navy);
  border-color: var(--tumsa-cyan);
  transform: scale(1.08);
}

/* Gráfica de Barras Rayadas - Paleta Cyan TUMSA */
.chart-bar-striped {
  background: repeating-linear-gradient(
    45deg,
    #7DD3FC,
    #7DD3FC 4.5px,
    #BAE6FD 4.5px,
    #BAE6FD 9px
  );
  border-radius: 9999px;
  transition: all 250ms ease;
  width: 100%;
}

.chart-bar-striped:hover {
  filter: brightness(0.95);
  transform: scaleY(1.03);
  transform-origin: bottom;
}

.chart-bar-active {
  background: linear-gradient(180deg, #00A0DF 0%, #0F206C 100%);
  border-radius: 9999px;
  box-shadow: 0 8px 20px -4px rgba(0, 160, 223, 0.45);
  transition: all 250ms ease;
  width: 100%;
}

.chart-bar-active:hover {
  transform: scaleY(1.02);
  transform-origin: bottom;
}

/* Scrollbar refinado */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94A3B8;
}

/* Focus and touch */
*:focus-visible {
  outline: 2px solid var(--tumsa-cyan) !important;
  outline-offset: 2px !important;
}

button, input, a, select {
  cursor: pointer;
}

/* Smooth Fade In */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   TUMSA CENTROAMÉRICA - ESTADOS Y COMPONENTES ESPECÍFICOS
   ========================================================================== */
.badge-status-en-ruta {
  background-color: #FEF3C7;
  color: #B45309;
  border: 1px solid #FDE68A;
}
.badge-status-liquidacion {
  background-color: #EFF6FF;
  color: #1D4ED8;
  border: 1px solid #BFDBFE;
}
.badge-status-cerrado {
  background-color: #ECFDF5;
  color: #047857;
  border: 1px solid #A7F3D0;
}
.badge-status-alerta {
  background-color: #FFF1F2;
  color: #BE123C;
  border: 1px solid #FECDD3;
}
.badge-bitacora-salida {
  background-color: #FEF2F2;
  color: #DC2626;
  border: 1.5px solid #F87171;
  font-weight: 800;
}
.badge-bitacora-retorno {
  background-color: #F8FAFC;
  color: #475569;
  border: 1px solid #CBD5E1;
  font-weight: 700;
}

/* Visor PDF Embebido y Split View */
.pdf-viewer-canvas {
  background: #1E293B;
  border-radius: 16px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
}

/* Filas de Cascada Waterfall de Rentabilidad */
.waterfall-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  font-size: 0.75rem;
  transition: background-color 150ms ease;
}
.waterfall-card-row:hover {
  background-color: rgba(15, 32, 108, 0.04);
}
.animate-fadeIn {
  animation: fadeIn 220ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
