/* ============================================================
   Registros Manditur — Improvements v2
   ============================================================ */

/* ── FIX MÓVIL: Evitar desbordamiento horizontal ─────────────── */
html,
body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* El sidebar ya está fuera del flujo (position: fixed),
   pero su sombra puede causar scroll. Lo cortamos: */
body {
  position: relative;
}

/* Aseguramos que el main-content nunca supere el viewport */
.main-content {
  max-width: 100%;
  min-width: 0;
}

/* Evitar que tablas o imágenes anchas desborden */
.page-content img,
.page-content table {
  max-width: 100%;
}

/* Formularios y cards sin padding lateral excesivo en mobile */
@media (max-width: 480px) {
  .page-content {
    padding: 0.875rem 0.75rem;
  }
  .card-body { padding: 1rem; }
  .card-header { padding: 0.875rem 1rem; }
  .form-section-body { padding: 0.875rem; }
  .modal-body { padding: 1rem; }
  .modal-header { padding: 1rem; }
}

/* ── BOTONES OK / MAL / APTO / NO APTO ─────────────────────── */
/* 
  Estado inactivo: borde de color, fondo blanco, texto de color
  Estado activo (active-ok / active-mal / active-na): fondo sólido
*/

/* Reset del estilo base btn-toggle — quitar el dorado marrón */
.btn-toggle {
  background: var(--surface) !important;
  color: var(--text-muted) !important;
  border: 2px solid var(--border) !important;
  min-height: 44px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-radius: 0.5rem;
  transition: all 0.18s ease;
}

/* Hover neutral */
.btn-toggle:hover {
  border-color: var(--text-muted) !important;
  color: var(--text) !important;
  background: var(--bg) !important;
}

/* Botón OK / APTO — verde contorno en reposo */
.btn-toggle.btn-outline-success {
  border-color: var(--success) !important;
  color: var(--success) !important;
  background: rgba(45,106,79,0.04) !important;
}
.btn-toggle.btn-outline-success:hover {
  background: rgba(45,106,79,0.1) !important;
  color: var(--success) !important;
}

/* Botón MAL / NO APTO — rojo contorno en reposo */
.btn-toggle.btn-outline-danger {
  border-color: var(--danger) !important;
  color: var(--danger) !important;
  background: rgba(176,42,55,0.04) !important;
}
.btn-toggle.btn-outline-danger:hover {
  background: rgba(176,42,55,0.1) !important;
  color: var(--danger) !important;
}

/* Botón N/A — gris contorno en reposo */
.btn-toggle.btn-outline-secondary {
  border-color: var(--text-light) !important;
  color: var(--text-muted) !important;
  background: var(--surface) !important;
}
.btn-toggle.btn-outline-secondary:hover {
  background: var(--bg) !important;
  border-color: var(--text-muted) !important;
}

/* ── ESTADOS ACTIVOS ─────────────────────────────────────────── */

/* OK / APTO activo → verde sólido vibrante */
.btn-toggle.active-ok,
.btn-toggle[data-value="realizado"].active {
  background: #27ae60 !important;
  border-color: #219150 !important;
  color: #fff !important;
  box-shadow: 0 2px 8px rgba(39,174,96,0.35) !important;
}

/* MAL / NO APTO activo → rojo sólido claro */
.btn-toggle.active-mal,
.btn-toggle[data-value="no_realizado"].active {
  background: #e74c3c !important;
  border-color: #c0392b !important;
  color: #fff !important;
  box-shadow: 0 2px 8px rgba(231,76,60,0.35) !important;
}

/* N/A activo → gris neutro */
.btn-toggle.active-na,
.btn-toggle[data-value="na"].active {
  background: #6c757d !important;
  border-color: #5a6268 !important;
  color: #fff !important;
}

/* ── ESTILOS DE BOTONES HOMOGÉNEOS (SIN MARRÓN) ──────────────── */
.btn-secondary {
  background: var(--primary-light) !important;
  border-color: var(--primary-light) !important;
  color: #fff !important;
}
.btn-secondary:hover {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}

.btn-outline-secondary,
.btn-outline-primary {
  background: transparent !important;
  color: var(--primary) !important;
  border-color: var(--primary) !important;
}
.btn-outline-secondary:hover,
.btn-outline-primary:hover {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}

/* Tamaño adecuado para móvil táctil */
@media (max-width: 480px) {
  .btn-toggle {
    min-height: 48px;
    flex: 1;
    justify-content: center;
  }
  .btn-toggle-group {
    gap: 0.4rem;
  }
}



/* ── Google Font — solo Montserrat ─────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700;800&display=swap');

/* ── Active nav item auto-highlight ────────────────────────── */
.sidebar-nav-item.is-active {
  background: rgba(197,168,128,0.18) !important;
  color: var(--secondary-light) !important;
  font-weight: 700 !important;
}
.sidebar-nav-item.is-active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--secondary-light);
  border-radius: 0 2px 2px 0;
}
.bottom-nav-item.is-active {
  color: var(--secondary) !important;
}
.bottom-nav-item.is-active::after {
  content: '';
  position: absolute;
  top: 0; left: 15%; right: 15%;
  height: 2.5px;
  background: var(--secondary);
  border-radius: 0 0 3px 3px;
}

/* ── Hotel switcher in sidebar (mobile friendly) ───────────── */
.sidebar-hotel-switcher {
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-hotel-switcher label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  margin-bottom: 0.4rem;
  display: block;
}
.sidebar-hotel-switcher select {
  width: 100%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  border-radius: 0.4rem;
  padding: 0.4rem 2rem 0.4rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 600;
  min-height: 38px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.5)' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  -webkit-appearance: none;
  appearance: none;
}
.sidebar-hotel-switcher select:focus {
  outline: none;
  border-color: rgba(197,168,128,0.5);
}
.sidebar-hotel-switcher select option {
  background: var(--primary-dark);
  color: #fff;
}

/* ── Sidebar nav heading (SISTEMA Y MULTI-HOTEL) ───────────── */
.sidebar-nav-heading {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.25);
  padding: 1rem 1.25rem 0.25rem;
  margin-top: 0.25rem;
}

/* ── Logout button proper styling ──────────────────────────── */
.sidebar-logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem 0.5rem;
  border-radius: 0.375rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: rgba(255,255,255,0.45);
  border: 1px solid rgba(255,255,255,0.1);
  transition: all 0.2s;
  text-decoration: none;
  min-height: 32px;
  min-width: 44px;
}
.sidebar-logout-btn:hover {
  background: rgba(176,42,55,0.2);
  border-color: rgba(176,42,55,0.4);
  color: #f87171;
  text-decoration: none;
}

/* ── Page header improvements ───────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.page-header h1, .page-header h2 {
  margin: 0;
}
.page-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ── Card improvements ──────────────────────────────────────── */
.card {
  transition: box-shadow 0.2s ease;
}
.card-header {
  background: linear-gradient(180deg, rgba(29,61,47,0.03) 0%, transparent 100%);
}

/* ── Form containers ─────────────────────────────────────────── */
.form-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1rem;
}
@media (min-width: 1025px) {
  .form-card { padding: 2rem; }
}

/* ── Responsive table improvements ─────────────────────────── */
@media (max-width: 1024px) {
  .table th:last-child,
  .table td:last-child {
    position: sticky;
    right: 0;
    background: var(--surface);
  }
  .table-responsive {
    border-radius: var(--radius-sm);
  }
  .btn-sm {
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
  }
}

/* ── Mobile form actions (full-width) ───────────────────────── */
@media (max-width: 480px) {
  .form-actions {
    flex-direction: column;
  }
  .form-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ── Flash messages refined ─────────────────────────────────── */
.flash-messages {
  padding: 0.75rem 1rem 0;
}
@media (min-width: 1025px) {
  .flash-messages { padding: 1rem 1.75rem 0; }
}

/* ── Topbar refinements ─────────────────────────────────────── */
.topbar {
  background: linear-gradient(90deg, var(--primary-dark) 0%, var(--primary) 100%);
  border-bottom: 2px solid rgba(197,168,128,0.3);
}

/* ── Badge success and danger explicit ──────────────────────── */
.badge-success {
  background: rgba(45,106,79,0.12);
  color: var(--success);
}
.badge-danger {
  background: rgba(176,42,55,0.12);
  color: var(--danger);
}
.badge-warning {
  background: rgba(212,163,115,0.18);
  color: #7a5a1f;
}
.badge-info {
  background: rgba(74,124,89,0.12);
  color: var(--info);
}

/* ── Table action buttons ───────────────────────────────────── */
.table-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
}

/* ── Stats grid responsive ──────────────────────────────────── */
.stats-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 1.5rem;
}
@media (min-width: 640px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ── Admin panel section titles ─────────────────────────────── */
.admin-page-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
  margin: 0 0 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.admin-page-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
}

/* ── Form label alignment ────────────────────────────────────── */
.form-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}

/* ── Input focus glow with brand color ──────────────────────── */
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29,61,47,0.12);
}

/* ── Scrollbar thin style ───────────────────────────────────── */
.sidebar {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

/* ── Body scroll lock when sidebar open on mobile ───────────── */
body.sidebar-open {
  overflow: hidden;
}

/* ── Skip link for accessibility ────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--primary);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-size: 0.875rem;
  z-index: 9999;
  transition: top 0.1s;
}
.skip-link:focus { top: 0; }

/* ── d-flex utility ─────────────────────────────────────────── */
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }

/* ── Print enhancements ─────────────────────────────────────── */
@media print {
  .sidebar-hotel-switcher,
  .sidebar-user,
  .sidebar-nav-heading { display: none !important; }
}

/* ── BOTONES HOMOGÉNEOS Y SIN TONOS MARRONES/BEIGES ─────────── */
.btn-warning {
  background: var(--primary-light) !important;
  border-color: var(--primary-light) !important;
  color: #fff !important;
}
.btn-warning:hover {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}
.btn-outline-warning {
  background: transparent !important;
  color: var(--primary) !important;
  border-color: var(--primary) !important;
}
.btn-outline-warning:hover {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}
.btn-light {
  background: #f1f5f9 !important; /* Gris pizarra limpio, sin beige */
  color: #334155 !important;
  border-color: #cbd5e1 !important;
}
.btn-light:hover {
  background: #e2e8f0 !important;
  color: #1e293b !important;
  border-color: #cbd5e1 !important;
}

/* ── CALENDAR DOTS LARGER ───────────────────────────────────── */
.calendar-dot {
  width: 9px !important;
  height: 9px !important;
}

/* ── RESPONSIVE GRIDS OVERRIDES ─────────────────────────────── */
@media (max-width: 1024px) {
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }

  /* Table density reduction on mobile */
  .table th,
  .table td {
    padding: 0.6rem 0.5rem !important;
    font-size: 0.75rem !important;
  }
  .signature-avatar {
    width: 24px !important;
    height: 24px !important;
    font-size: 0.6rem !important;
  }

  /* Flex column alignments on mobile */
  .flex.justify-between.items-center.gap-4.flex-wrap {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem !important;
  }
}

@media (min-width: 481px) and (max-width: 1024px) {
  .grid-3 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .grid-4 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ── Form footer actions on mobile ──────────────────────────── */
@media (max-width: 576px) {
  .form-footer-actions {
    flex-direction: column !important;
    gap: 0.75rem !important;
    align-items: stretch !important;
  }
  .form-footer-actions .btn,
  .form-footer-actions a {
    width: 100% !important;
    flex: none !important;
    margin: 0 !important;
  }
}

/* ── Calendar Page Responsiveness ───────────────────────────── */
.calendar-main-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
}

@media (max-width: 1024px) {
  .calendar-main-grid {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 480px) {
  .calendar-title {
    font-size: 0.95rem !important;
  }
  .calendar-nav {
    padding: 0.75rem 1rem !important;
  }
  .calendar-weekday {
    font-size: 0.6rem !important;
    padding: 0.35rem 0.1rem !important;
  }
  .calendar-day {
    min-height: 44px !important;
    padding: 2px !important;
  }
  .calendar-day-num {
    font-size: 0.7rem !important;
  }
  .calendar-dots {
    gap: 1.5px !important;
    justify-content: center;
  }
  .calendar-dot {
    width: 4px !important;
    height: 4px !important;
  }
  .calendar-legend {
    padding: 0.75rem 1rem !important;
    gap: 0.5rem !important;
  }
  .legend-item {
    font-size: 0.65rem !important;
  }
}

/* ── Submission View Page Responsiveness ────────────────────── */
.submission-view-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
}

@media (max-width: 1024px) {
  .submission-view-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ── Responsive Visibility Utilities ────────────────────────── */
@media (max-width: 1024px) {
  .desktop-only {
    display: none !important;
  }
  .mobile-only {
    display: block !important;
  }
}
@media (min-width: 1025px) {
  .desktop-only {
    display: block !important;
  }
  .mobile-only {
    display: none !important;
  }
}

/* ── ESTADOS DE ADVERTENCIA (FUERA DE RANGO NO GRAVE / NARANJA) ── */
.form-control.is-warning {
  border-color: #f59e0b !important;
  background-color: rgba(245, 158, 11, 0.04) !important;
  color: #d97706 !important;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.12) !important;
}

.temp-field-wrapper.oor-warning .form-control,
.cloro-field-wrapper.oor-warning .form-control,
.number-field-wrapper.oor-warning .form-control {
  border-color: #f59e0b !important;
  background-color: rgba(245, 158, 11, 0.04) !important;
  color: #d97706 !important;
}

.temp-field-wrapper.oor-warning .temp-range-indicator,
.cloro-field-wrapper.oor-warning .temp-range-indicator,
.number-field-wrapper.oor-warning .number-range-indicator {
  color: #d97706 !important;
}

/* ── ESTADOS DE PELIGRO EXTREMO (ROJO) ── */
.temp-field-wrapper.oor-danger .form-control,
.cloro-field-wrapper.oor-danger .form-control,
.number-field-wrapper.oor-danger .form-control {
  border-color: var(--danger) !important;
  background-color: rgba(239, 68, 68, 0.04) !important;
}

.temp-field-wrapper.oor-danger .temp-range-indicator,
.cloro-field-wrapper.oor-danger .temp-range-indicator,
.number-field-wrapper.oor-danger .number-range-indicator {
  color: var(--danger) !important;
  font-weight: 700 !important;
}

/* ============================================================
   RESPONSIVENESS & MOBILE ACCESSIBILITY OVERHAUL
   ============================================================ */

/* ── Container & Page Spacing ─────────────────────────────── */
@media (max-width: 639px) {
  .page-content {
    padding: 0.75rem 0.5rem !important;
  }
  .dashboard-header {
    margin-bottom: 1rem !important;
  }
  .dashboard-header h1 {
    font-size: 1.35rem !important;
  }
  .card-header {
    padding: 0.75rem 0.875rem !important;
  }
  .card-body {
    padding: 0.875rem !important;
  }
  .dept-section {
    margin-bottom: 1.25rem !important;
  }
}

/* ── Full-Width Cards on Mobile (< 640px) ──────────────────── */
@media (max-width: 639px) {
  .card-grid {
    grid-template-columns: 1fr !important;
    gap: 0.875rem !important;
  }
  .form-item-card {
    width: 100% !important;
    border-radius: var(--radius-sm) !important;
  }
  .form-item-card .card-body {
    padding: 0.875rem !important;
  }
}

/* ── Touch-Friendly Action Buttons ───────────────────────── */
.btn-block {
  width: 100% !important;
}
@media (max-width: 768px) {
  .form-item-card .btn,
  .form-item-card a.btn {
    min-height: 44px !important;
    font-size: 0.875rem !important;
    font-weight: 700 !important;
    padding: 0.5rem 0.75rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    word-break: break-word !important;
  }
}

/* ── Calendar Page Responsiveness ────────────────────────── */
@media (max-width: 1024px) {
  .calendar-main-grid {
    grid-template-columns: 1fr !important;
    gap: 1.25rem !important;
  }
}

@media (max-width: 639px) {
  .calendar-wrapper {
    padding: 0.25rem !important;
  }
  .calendar-title {
    font-size: 1rem !important;
    font-weight: 800 !important;
  }
  .calendar-nav {
    padding: 0.5rem !important;
  }
  .calendar-day {
    min-height: 52px !important;
    padding: 3px 2px !important;
  }
  .calendar-day-num {
    font-size: 0.75rem !important;
    font-weight: 700 !important;
  }
  .checklist-item {
    padding: 0.875rem 0.75rem !important;
  }
  .checklist-item .btn {
    min-height: 44px !important;
    font-size: 0.875rem !important;
    font-weight: 700 !important;
  }
}

/* ── Table Responsiveness & Touch Scroll ─────────────────── */
.table-responsive {
  width: 100% !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
  margin-bottom: 1rem;
}

@media (max-width: 768px) {
  .table-responsive .table {
    min-width: 540px;
  }
  .table th,
  .table td {
    padding: 0.65rem 0.75rem !important;
    font-size: 0.8rem !important;
  }
}

/* ── Form Filler Steppers & Toggle Buttons on Mobile ──────── */
@media (max-width: 480px) {
  .btn-toggle-group {
    display: flex !important;
    gap: 0.35rem !important;
    flex-wrap: wrap !important;
  }
  .btn-toggle {
    flex: 1 1 calc(50% - 0.35rem) !important;
    min-width: 70px !important;
    min-height: 44px !important;
    padding: 0.5rem !important;
    font-size: 0.8rem !important;
  }
  .temp-stepper {
    min-width: 44px !important;
    min-height: 44px !important;
    font-size: 1.25rem !important;
  }
}

