/* ==============================================================================
   HORARIOS WC — Panel de Administración & Dashboard
   ============================================================================== */

/* Layout Principal */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* El contenido principal empuja 260px a la derecha para compensar el sidebar fijo */
.main-content {
  margin-left: 260px;
  flex: 1;
  min-width: 0;
  overflow-y: auto;
}

/* Barra Lateral (Sidebar) */
.sidebar {
  width: 260px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform var(--transition-normal);
  z-index: 100;
  /* Fijar el sidebar para que siempre sea visible al hacer scroll */
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-header {
  padding: 1.5rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

.logo-badge {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.2rem;
  color: #fff;
  box-shadow: var(--glow-primary);
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-nav {
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex-grow: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.925rem;
  transition: all var(--transition-fast);
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-link svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  transition: stroke var(--transition-fast);
}

.nav-link:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
}

.nav-link.active {
  background: var(--brand-primary-light);
  color: #c4b5fd;
  border-color: var(--border-active);
}

.nav-link.active svg {
  stroke: var(--brand-primary);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.2);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  overflow: hidden;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--brand-cyan);
}

.user-info {
  line-height: 1.2;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.user-role {
  font-size: 0.7rem;
  color: var(--brand-primary);
  text-transform: capitalize;
}

/* Área Principal de Contenido */
.main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.topbar {
  height: 68px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
}

.topbar-title-section {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 800;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--status-active-bg);
  border: 1px solid var(--status-active-border);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
  color: #34d399;
}

/* Contenedor de Vista / Pantalla */
.content-body {
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.view-section {
  display: none;
}

.view-section.active {
  display: block;
  animation: fadeInView 0.2s ease;
}

@keyframes fadeInView {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Métricas del Dashboard */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}

.metric-card {
  background: var(--gradient-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-top: 1px solid var(--border-highlight);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.15rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.metric-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md), 0 0 20px rgba(168, 85, 247, 0.15);
}

.metric-card::after {
  content: '';
  position: absolute;
  top: -20px;
  right: -20px;
  width: 80px;
  height: 80px;
  background: radial-gradient(circle, var(--metric-color, rgba(168, 85, 247, 0.25)) 0%, transparent 70%);
}

.metric-icon-box {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--metric-color, var(--brand-primary));
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.metric-data {
  line-height: 1.2;
}

.metric-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.metric-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.25rem;
}

/* Matriz de Habitaciones (Rooms Matrix) */
.rooms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.35rem;
}

.room-card {
  background: var(--bg-surface);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-top: 1px solid var(--border-highlight);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  position: relative;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal);
}

.room-card:hover {
  border-color: var(--border-focus);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md), 0 0 25px rgba(168, 85, 247, 0.15);
}

.room-card.occupied {
  border-left: 4px solid var(--status-active);
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.08) 0%, var(--bg-surface) 100%);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.12);
}

.room-card.available {
  border-left: 4px solid var(--status-muted);
}

.room-card.maintenance {
  border-left: 4px solid var(--status-warning);
}

.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.room-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.room-code-tag {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  color: var(--brand-cyan);
}

.room-model-active {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.model-avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: #fff;
}

.shift-time-range {
  font-family: var(--font-mono);
  font-size: 0.825rem;
  color: var(--text-secondary);
}

/* Tablas Modernas */
.table-container {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
}

.table-custom {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.table-custom th {
  padding: 0.9rem 1.25rem;
  background: var(--bg-surface-elevated);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
}

.table-custom td {
  padding: 1rem 1.25rem;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

.table-custom tr:last-child td {
  border-bottom: none;
}

.table-custom tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Drag & Drop Reordering */
.room-drag-row {
  cursor: grab;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.room-drag-row:active {
  cursor: grabbing;
}

.room-drag-row.dragging {
  opacity: 0.45;
  background: rgba(139, 92, 246, 0.12) !important;
}

.room-drag-row.drag-over-top td {
  border-top: 2px solid var(--brand-cyan) !important;
  box-shadow: inset 0 2px 4px rgba(6, 182, 212, 0.2);
}

.room-drag-row.drag-over-bottom td {
  border-bottom: 2px solid var(--brand-cyan) !important;
  box-shadow: inset 0 -2px 4px rgba(6, 182, 212, 0.2);
}

.drag-handle-cell {
  text-align: center;
  width: 70px;
}

.drag-handle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
}

.room-drag-row:hover .drag-handle {
  color: var(--brand-cyan);
  border-color: rgba(6, 182, 212, 0.3);
  background: rgba(6, 182, 212, 0.06);
}

.room-seq-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.room-drag-row:hover .room-seq-num {
  color: var(--brand-cyan);
}

/* Vista Agenda Diaria y Filtros */
.agenda-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--bg-surface);
  padding: 1rem 1.25rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

.agenda-date-picker {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.agenda-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.timeline-hour-block {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  padding: 1rem 1.25rem;
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 1.25rem;
  align-items: center;
}

.timeline-hour-label {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--brand-primary);
}

.timeline-shifts-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.timeline-shift-chip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.timeline-shift-chip:hover {
  border-color: var(--brand-primary);
  transform: scale(1.02);
}

/* Banner de Alerta de Conflicto en Formulario */
.conflict-alert {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  display: none;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1.1rem;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.15);
  animation: fadeIn 0.2s ease;
}

.conflict-alert.show {
  display: flex !important;
}

.conflict-alert.shared-room {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.45);
  color: #ddd6fe;
  box-shadow: 0 4px 18px rgba(139, 92, 246, 0.22);
}

/* Botón Hamburguesa Móvil */
.mobile-menu-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 0.45rem;
  border-radius: var(--radius-md);
  cursor: pointer;
}

.mobile-menu-btn:hover {
  background: var(--bg-surface-elevated);
}

/* Fondo Oscuro para Menú Móvil */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 95;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ==============================================================================
   RESPONSIVE — Sistema unificado (sin duplicados)
   ============================================================================== */

/* Botón Hamburguesa — Oculto en escritorio, visible en móvil */
.mobile-menu-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 0.45rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.mobile-menu-btn:hover {
  background: var(--bg-surface-elevated);
}

/* Fondo Oscuro para Menú Móvil */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 95;
  opacity: 0;
  transition: opacity var(--transition-normal);
}
.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* Labels móviles en tablas */
.mobile-td-label { display: none; }
.mobile-btn-actions { display: inline-flex; gap: 0.4rem; }

/* ── Tablets medianas (≤ 1024px) ──────────────────────────────────────────── */
@media (max-width: 1024px) {
  .app-layout, .main-content, .content-body {
    max-width: 100vw;
    overflow-x: hidden;
    box-sizing: border-box;
  }
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
  }
  .rooms-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
  .content-body {
    padding: 1.25rem;
    gap: 1.25rem;
  }
}

/* ── Tablets pequeñas y móviles grandes (≤ 860px) — SIDEBAR COMO DRAWER ──── */
@media (max-width: 860px) {
  .mobile-menu-btn {
    display: inline-flex;
  }

  /* El sidebar se oculta fuera de pantalla; aparece al presionar hamburguesa */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(280px, 80vw);
    height: 100vh;
    z-index: 200;
    transform: translateX(-100%);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.85);
    transition: transform var(--transition-normal);
    overflow-y: auto;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }

  /* El contenido ocupa el 100% en móvil (sin margin-left) */
  .main-content {
    margin-left: 0 !important;
    width: 100%;
  }

  .topbar {
    padding: 0 1rem;
    height: 60px;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
  }
  .topbar-title-section {
    gap: 0.6rem;
    min-width: 0;
  }
  .page-title {
    font-size: 1.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .timeline-hour-block {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .agenda-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    width: 100%;
  }
  .agenda-date-picker {
    justify-content: space-between;
    flex-wrap: wrap;
    width: 100%;
  }
  .agenda-date-picker input[type="date"] {
    flex: 1;
    min-width: 130px;
  }
}

/* ── Móviles generales (≤ 768px) — TARJETAS + AJUSTES DE UI ─────────────── */
@media (max-width: 768px) {
  .app-layout, .main-content, .content-body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    box-sizing: border-box;
  }
  .content-body {
    padding: 0.75rem;
    gap: 0.85rem;
  }
  .topbar {
    padding: 0 0.75rem;
    height: 56px;
  }
  .page-title {
    font-size: 1rem;
    max-width: 160px;
  }
  .topbar-actions .live-indicator {
    display: none;
  }
  .topbar-actions .btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
  }
  .metrics-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    width: 100%;
  }
  .metric-card {
    padding: 0.85rem 1rem;
  }
  .metric-value {
    font-size: 1.5rem;
  }
  .rooms-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
    width: 100%;
  }
  .card {
    padding: 0.85rem;
    border-radius: var(--radius-md);
    width: 100%;
    box-sizing: border-box;
  }
  .card-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }
  .card-header .btn {
    width: 100%;
  }

  /* ── Tablas → Tarjetas apiladas ── */
  .table-container {
    width: 100%;
    max-width: 100%;
    background: transparent !important;
    border: none !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .table-custom {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    border: none !important;
  }
  .table-custom thead {
    display: none !important;
  }
  .table-custom tbody {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.75rem !important;
    width: 100% !important;
  }
  .table-custom tr,
  .table-custom tr.responsive-table-card {
    display: flex !important;
    flex-direction: column !important;
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: var(--radius-lg) !important;
    padding: 0.85rem 1rem !important;
    gap: 0.45rem !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4) !important;
    box-sizing: border-box !important;
    width: 100% !important;
    margin-bottom: 0.25rem !important;
    transition: all var(--transition-fast) !important;
  }
  .table-custom tr:hover {
    border-color: var(--border-focus) !important;
    background: var(--bg-surface-elevated) !important;
  }
  .table-custom td {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0.35rem 0 !important;
    border: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
    width: 100% !important;
    box-sizing: border-box !important;
    font-size: 0.88rem !important;
  }
  .table-custom td:last-child,
  .table-custom td.td-actions {
    border-bottom: none !important;
    margin-top: 0.35rem !important;
    padding-top: 0.65rem !important;
    border-top: 1px solid var(--border-subtle) !important;
    display: flex !important;
    justify-content: stretch !important;
  }
  .table-custom td.td-highlight,
  .table-custom td.td-order-code {
    background: rgba(255, 255, 255, 0.03) !important;
    padding: 0.45rem 0.65rem !important;
    border-radius: var(--radius-sm) !important;
    margin-bottom: 0.2rem !important;
    border-bottom: none !important;
  }
  .mobile-td-label {
    display: inline-block !important;
    font-size: 0.72rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    color: var(--text-muted) !important;
    letter-spacing: 0.06em !important;
    text-align: left !important;
    flex-shrink: 0 !important;
  }
  .mobile-btn-actions {
    display: flex !important;
    width: 100% !important;
    gap: 0.5rem !important;
  }
  .mobile-btn-actions .btn {
    flex: 1 !important;
    text-align: center !important;
    justify-content: center !important;
    padding: 0.55rem 0.75rem !important;
    font-size: 0.85rem !important;
  }

  /* Modales en Móvil */
  .modal-backdrop {
    padding: 0.5rem;
    box-sizing: border-box;
  }
  .modal-dialog {
    width: 100%;
    max-width: calc(100vw - 1rem);
    margin: auto;
    padding: 1.1rem;
    box-sizing: border-box;
    border-radius: var(--radius-lg);
  }
  .modal-dialog [style*="grid-template-columns: 1fr 1fr"],
  .modal-dialog [style*="grid-template-columns: 1fr 2fr"],
  .modal-dialog [style*="grid-template-columns: 2fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 0.65rem !important;
  }
  .modal-footer {
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
    width: 100%;
  }
  .modal-footer .btn {
    width: 100%;
    padding: 0.65rem 1rem;
  }

  /* Toasts */
  .toast-container {
    top: auto;
    bottom: 1rem;
    right: 0.75rem;
    left: 0.75rem;
    max-width: calc(100vw - 1.5rem);
  }
}

/* ── Teléfonos compactos (≤ 480px) ─────────────────────────────────────────── */
@media (max-width: 480px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  .topbar-actions .user-profile .user-info {
    display: none;
  }
  .topbar-actions .user-profile {
    gap: 0;
  }
  .btn {
    padding: 0.55rem 0.85rem;
    font-size: 0.85rem;
  }
  .room-header {
    flex-wrap: wrap;
    gap: 0.35rem;
  }
  .page-title {
    font-size: 0.9rem;
    max-width: 110px;
  }
}
