/* Home widgets grid and minimal look */
.home-widgets-grid{ display:grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 1199.98px){ .home-widgets-grid{ grid-template-columns: repeat(3, 1fr);} }
@media (max-width: 991.98px){ .home-widgets-grid{ grid-template-columns: repeat(2, 1fr);} }
@media (max-width: 575.98px){ .home-widgets-grid{ grid-template-columns: 1fr; } }
.home-widget{ aspect-ratio: 1 / 1; display:flex; flex-direction:column; min-height:220px; border-radius: 10px; font-size: 0.7rem; }
/* Minimal look: lighter shadow and subtle border */
.home-widget.shadow-sm{ box-shadow: 0 8px 16px rgba(0,0,0,.03) !important; }
.home-widget.card{ border: 1px solid rgba(0,0,0,.06); }
.home-widget .card-body{ overflow:auto; }
.home-widget .card-header{ padding-top:.3rem; padding-bottom:.3rem; background:#fff; border-bottom:1px solid rgba(0,0,0,.06); color:#343a40; border-top-left-radius:10px; border-top-right-radius:10px; font-size: 0.8rem; }
.home-widget .card-header .btn{ border-radius: 6px; }
.home-widget .card-header strong{ font-weight:600; }
.home-widget .btn.btn-outline-secondary{ border-color: rgba(0,0,0,.15); color:#6c757d; }
.home-widget .btn.btn-outline-secondary:hover{ background:#f8f9fa; color:#495057; }
.home-widget .list-group{ overflow:auto; }
.home-widget .list-group-item{ border-color: rgba(0,0,0,.05); padding: .4rem .6rem; font-size: 0.7rem; }

/* Compact variant (opt-in per widget) */
.home-widget.compact{ font-size: 0.65rem; }
.home-widget.compact .card-header{ font-size: 0.75rem; padding-top:.25rem; padding-bottom:.25rem; }
.home-widget.compact .list-group-item{ font-size: 0.65rem; padding: .35rem .55rem; }
.home-widget .list-group-item-action:hover{ background:#f8f9fa; }
.dot{ display:inline-block; width:10px; height:10px; border-radius:50%; margin-right:6px; vertical-align:middle; }
.dot.green{ background:#28a745; }
.dot.orange{ background:#fd7e14; }
.dot.red{ background:#dc3545; }
/* Minimal & Modern Bootstrap Customization */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  src: url('../fonts/inter/Inter-Regular.woff2') format('woff2');
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  src: url('../fonts/inter/Inter-Medium.woff2') format('woff2');
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  src: url('../fonts/inter/Inter-SemiBold.woff2') format('woff2');
  font-display: swap;
}

:root { 
  --content-gutter-pinned: 8px;
  --content-gap-near-sidebar: 4px;        /* separación mínima entre borde del menú y contenido */
  --content-padding-left-near-sidebar: .5rem; /* padding izquierdo del área de trabajo */
  --sidebar-overlay-gutter: 12px;
  --sidebar-gutter: 16px;
  --sidebar-width: 250px;
  --color-primary: #006A89;
  --color-secondary: #6c757d;
  --color-bg: #f9fafb;
  --color-text: #1f2d3d;
  --font-base: 'Inter', sans-serif;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-base);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ===== Comportamiento del contenido con respecto al menú ===== */

/* Menú flotante oculto → contenido ocupa todo el ancho */
.sidebar.hidden ~ .main-content {
  margin-left: 0 !important;
  width: 100% !important;
  transition: margin-left 0.3s ease, width 0.3s ease;
}

.sidebar:not(.hidden) ~ .main-content { padding-left: var(--content-gap-near-sidebar) !important; }

/* Menú flotante visible → contenido se desplaza */
.sidebar:not(.pinned):not(.hidden) ~ .main-content {
  margin-left: var(--sidebar-width) !important;
  width: calc(100% - var(--sidebar-width)) !important;
  padding-left: var(--content-gap-near-sidebar) !important; /* Ajusta el valor según prefieras */
  padding-inline: var(--sidebar-overlay-gutter);
  transition: margin-left 0.3s ease, width 0.3s ease;
}

/* Menú anclado (fijo) → contenido muy próximo al menú */
.sidebar.pinned ~ .main-content,
body.menu-pinned .main-content {
  margin-left: 0 !important;         /* antes: var(--sidebar-width) */
  width: auto !important;             /* antes: calc(100% - var(--sidebar-width)) */
  padding-left: 8px !important; /* separador visual pequeño */
  transition: margin-left .3s ease, width .3s ease, padding-left .3s ease;
}

.sidebar:not(.hidden) ~ .main-content .page-body { padding-left: var(--content-padding-left-near-sidebar) !important; }

.sidebar:not(.hidden) ~ .main-content .container,
.sidebar:not(.hidden) ~ .main-content .container-fluid { padding-left: var(--content-padding-left-near-sidebar) !important; }

/* Layout */
header.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 50px;
  z-index: 1050;
}

.view-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.page-header {
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0.5rem;
}

.page-body {
  background-color: var(--color-bg);
  border: none;
  padding: 1rem;
  min-height: 700px;
  transition: all 0.2s ease;
  padding-top: 0.25rem !important;
}

.app-wrapper {
  display: flex;
  flex: 1;
  margin-top: 50px;
  overflow: hidden;
  height: calc(100vh - 50px);
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  min-height: calc(100vh - 50px);
  transition: margin-left 0.3s ease, width 0.3s ease;
}

/* Sidebar */
.sidebar {
  box-sizing: border-box;
  position: fixed;
  top: 50px;
  left: 0;
  z-index: 1040;
  width: var(--sidebar-width);
  height: calc(100vh - 50px);
  padding-inline: var(--sidebar-gutter);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
  background-color: #ccc;
  border-radius: 4px;
}

.sidebar.hidden {
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
  height: 100vh;
}

.sidebar.pinned {
  transform: none;
  position: static;
}

.sidebar.invisible-init {
  visibility: hidden;
  transition: none !important;
}

.sidebar.sidebar-animated {
  transition: transform 0.6s ease, opacity 0.6s ease;
}

.sidebar-section {
  font-size: 0.70rem;
  text-transform: uppercase;
  font-weight: 600;
  color: #6c757d;
  padding: 0.70rem 0.85rem 0.25rem;
  padding-left: 0;
  padding-right: 0;
  margin-top: 0.75rem;
  border-top: 1px solid #e5e7eb;
}

.sidebar-section:first-of-type {
  border-top: none;
  margin-top: 0;
}

/* Sidebar Nav */
.sidebar-nav a {
  display: flex;
  padding: 0.4rem 1rem;
  color: var(--color-text);
  align-items: left;
  border-radius: 0.4rem;
  gap: 0.5rem;
  font-size: 0.65rem;
  font-weight: 500;
  transition: background-color 0.2s;
  line-height: 1.2;
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

.sidebar-nav a:hover {
  background-color: #e9ecef;
  color: var(--color-primary);
  text-decoration: none;
}

.sidebar-nav a.active {
  background-color: var(--color-primary);
  color: white !important;
  font-weight: 600;
}

.sidebar-nav a svg,
.sidebar-nav a i {
  width: 1.2rem;
  height: 1.2rem;
  flex-shrink: 0;
}

.sidebar-nav .submenu.show {
  display: block;
}

.sidebar-nav .submenu {
  overflow: hidden;
  transition: max-height 0.3s ease;
  max-height: 0;
}

.sidebar-nav .submenu.show {
  max-height: 500px;
}

.submenu-icon {
  font-size: 0.8rem;
  transition: transform 0.2s ease;
}

.submenu a {
  font-size: 0.7rem;
  padding-left: 1.5rem;
}

/* Botón toggle */
.toggle-sidebar-btn {
  background: none;
  border: none;
  font-size: 0.75rem;
  cursor: pointer;
}

.toggle-sidebar-btn.pinned-active {
  color: var(--color-primary);
  transform: rotate(-45deg);
  transition: transform 0.2s ease, color 0.2s ease;
}

/* Spinner overlay */
.spinner-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
}

/* Transición suave entre vistas */
.view-transition {
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.view-transition.view-loaded {
  opacity: 1;
}

/* User avatar*/
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--color-primary);
  font-size: 0.8rem;
  text-transform: uppercase;
}

.dropdown-user {
  font-family: var(--font-base);
  font-size: 0.65rem;
}

.dropdown-item {
  font-family: var(--font-base);
  font-size: 0.65rem;
  padding: 0.4rem 1rem;
  line-height: 1.2;
}

.dropdown-item:hover {
  background-color: #f1f3f5;
  color: var(--color-primary);
}

/* Buttons */
.btn {
  border-radius: none;
  font-family: var(--font-base);
  font-size: 0.65rem;
  font-weight: 500;
  padding: 0.4rem 1rem;
  transition: all 0.2s ease-in-out;
}

.btn-primary {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-outline-primary {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-outline-primary:hover {
  background-color: var(--color-primary);
  color: white;
}

/* Login form */
.login-wrapper {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: url('../imgs/manchas.jpg') no-repeat center center;
  background-size: cover;
}

.login-wrapper::before {
  content: "";
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.4);
  z-index: 0;
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  padding: 2rem;
  border-radius: 1rem;
  background: white;
  box-shadow: 0 0.5rem 1.5rem rgba(0,0,0,0.1);
  backdrop-filter: blur(4px);
}

.login-logo {
  max-width: 100px;
  margin: 0 auto 1.5rem;
  display: block;
}

/* Form Controls */
.form-label {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 0.25rem;
}

.form-control {
  border: none;
  border-bottom: 2px solid #ced4da;
  border-radius: 0;
  font-size: 0.65rem;
  padding: 0.5rem 0.75rem;
  background-color: transparent;
  box-shadow: none;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: none;
}

.form-select {
  border: none;
  border-bottom: 2px solid #ced4da;
  border-radius: 0;
  font-size: 0.65rem;
  padding: 0.5rem 0.75rem;
  background-color: transparent;
  box-shadow: none;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-select:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: none;
}

.input-password-wrapper {
  position: relative;
}

.toggle-password {
  position: absolute;
  top: 50%;
  right: 0.75rem;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--color-secondary);
}

.form-control.pe-5 {
  padding-right: 2rem !important;
}

/* Table */
.data-wrapper {
  border: none;
  border-radius: none;
  padding: 1rem;
  background-color: transparent;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.table {
  font-size: 0.65rem;
  width: 100%;
  border-collapse: collapse;
}

.table thead th {
  background-color: #006A89;
  position: sticky;
  top: 0;
  z-index: 2;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.65rem;
  color: #fff;
  letter-spacing: 0.5px;
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid #e5e7eb;
}

.table tbody td {
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid #f1f3f5;
  vertical-align: middle;
}

.table tbody tr:hover {
  background-color: #f8f9fb;
  transition: background-color 0.2s ease;
}

#tablaPaginacion {
  margin-top: 0.5rem;
  font-size: 0.65rem;
}

#tablaPaginacion .btn {
  padding: 0.25rem 0.6rem;
  font-size: 0.65rem;
  border-radius: 0.375rem;
}

#tablaBuscar {
  max-width: 200px;
}

.table td:nth-child(4) {
  text-align: center;
}

.table td:nth-child(4)::after {
  content: attr(data-badge);
  display: inline-block;
  background-color: #fef3c7;
  color: #b45309;
  font-size: 0.55rem;
  padding: 0.1rem 0.4rem;
  border-radius: 0.3rem;
  margin-left: 0.25rem;
}

.table-responsive {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.drag-handle {
  cursor: move;
  user-select: none;
  font-size: 0.75rem;
  opacity: 0.5;
  position: absolute;
  left: 0.25rem;
  top: 50%;
  transform: translateY(-50%);
  padding-right: 0.25rem;
}

th.drag-over {
  background-color: #e9f3ff !important;
}

/* Modal */
.modal-content {
  border-radius: 1rem;
  box-shadow: 0 0.5rem 1.5rem rgba(0,0,0,0.1);
}

.modal-header {
  border-bottom: 1px solid #eaeaea;
}

#modalLoaderOverlay {
  position: fixed;
  z-index: 2000;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(255, 255, 255, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
}

/* Alerts */
.alert {
  border-radius: 0.5rem;
  font-size: 0.85rem;
}

/* Utility */
.text-muted {
  color: #6c757d !important;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Welcome Splash */
#welcomeSplash {
  transition: opacity 0.5s ease-in-out;
}

/* Footer fijo */
footer {
  flex-shrink: 0;
  text-align: center;
  font-size: 0.65rem;
  padding: 0.25rem;
  background: #fff;
  border-top: 1px solid #e5e7eb;
}

/* tarjetas equipos MES */
.equipos-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill,minmax(240px,1fr));
}
.equipo-card { border: 1px solid #e5e7eb; }
.equipo-card .status-dot {
  width:12px; height:12px; border-radius:50%; background:#adb5bd; margin-top:4px;
  box-shadow:0 0 0 2px #fff;
}
.status-dot.online { background:#28a745; }
.status-dot.offline { background:#dc3545; }
.equipo-card .badge { font-weight:500; }

/* Asistente IA */
.ai-chat-fab {
  position: fixed;
  bottom: 84px;
  right: 18px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: none;
  background: var(--color-primary);
  color: #fff;
  font-size: 1.4rem;
  box-shadow: 0 12px 24px rgba(0,0,0,0.15);
  z-index: 1090;
  display: grid;
  place-items: center;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.ai-chat-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 30px rgba(0,0,0,0.18);
}

.modal-ai-chat .modal-dialog {
  max-width: 420px;
  margin: 1rem;
}

.modal-ai-chat .modal-body {
  max-height: 70vh;
  overflow: hidden;
}

.modal-ai-chat .ai-chat-card {
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
}

.modal-ai-chat .ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  color: var(--color-primary);
}

.modal-ai-chat .ai-chat-log {
  border: 1px solid rgba(0,0,0,0.05);
  border-radius: 10px;
  padding: 10px;
  background: #f9fafb;
  height: 45vh;
  overflow-y: auto;
  font-size: 0.9rem;
  gap: 6px;
  display: flex;
  flex-direction: column;
}

.modal-ai-chat .ai-chat-msg strong { color: var(--color-primary); font-weight: 600; }

.modal-ai-chat .ai-chat-input-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
}

.modal-ai-chat #ai-chat-input {
  width: 100%;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
}

.modal-ai-chat .ai-chat-status {
  display: none;
  align-items: center;
  gap: 8px;
  color: #4b5563;
  font-size: 0.85rem;
  padding: 6px 4px;
}

.modal-ai-chat .ai-chat-status.active { display: inline-flex; }

.modal-ai-chat .ai-chat-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #d1d5db;
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: ai-spin 0.75s linear infinite;
}

.modal-ai-chat .ai-chat-log { margin-bottom: 6px; }

.modal-ai-chat .ai-chat-plan {
  display: none;
  border: 1px dashed rgba(0,0,0,0.1);
  border-radius: 10px;
  padding: 10px;
  background: #f8fafc;
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.modal-ai-chat .ai-chat-plan.show { display: block; }

.modal-ai-chat .ai-plan-header { font-weight: 600; color: var(--color-primary); margin-bottom: 4px; }
.modal-ai-chat .ai-plan-meta { color: #4b5563; margin-bottom: 4px; }
.modal-ai-chat .ai-plan-fields { color: #374151; margin-bottom: 8px; }
.modal-ai-chat .ai-plan-missing { color: #b91c1c; font-weight: 600; margin-bottom: 8px; }
.modal-ai-chat .ai-plan-actions { display: flex; gap: 8px; }
.modal-ai-chat .ai-plan-actions button {
  border: none;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.85rem;
  background: var(--color-primary);
  color: #fff;
}
.modal-ai-chat .ai-plan-actions button:last-child { background: #9ca3af; }

.modal-ai-chat #ai-chat-send,
.modal-ai-chat #ai-chat-send,
.modal-ai-chat #ai-chat-mic {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.9rem;
  background: var(--color-primary);
  color: #fff;
  min-width: 68px;
}

.modal-ai-chat #ai-chat-mic { min-width: 46px; }

.modal-ai-chat .rag-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: #4b5563;
}

@keyframes ai-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}