/* ====================================================================
   HOTEL SAAS B2B - PREMIUM LIGHT THEME DESIGN SYSTEM (RESPONSIVE MOBILE-FIRST)
   ==================================================================== */

:root {
  --bg-dark: #f8fafc;        /* Fondo principal claro */
  --bg-card: #ffffff;        /* Fondo de tarjetas en blanco */
  --bg-sidebar: #0f172a;     /* Sidebar azul marino profesional */
  
  --text-main: #0f172a;      /* Texto principal */
  --text-muted: #64748b;     /* Texto secundario */
  --text-sidebar: #cbd5e1;   /* Texto sidebar */
  
  --primary: #2563eb;        /* Azul corporativo */
  --primary-hover: #1d4ed8;
  --accent: #4f46e5;
  --border-color: #e2e8f0;    /* Bordes suaves */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.1);
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.05), 0 2px 6px -1px rgba(0, 0, 0, 0.03);

  /* Status Colors */
  --status-disponible: #16a34a;
  --status-ocupada: #dc2626;
  --status-limpieza: #d97706;
  --status-mantenimiento: #7c3aed;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
}

/* Layout Container */
.app-container {
  display: flex;
  width: 100%;
  min-height: 100vh;
  position: relative;
}

/* Sidebar Navigation (Desktop Fixed + Internal Scroll + Mobile Drawer + Collapse Mode) */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  transition: width 0.3s ease, padding 0.3s ease, transform 0.3s ease, z-index 0.3s ease;
  z-index: 100;

  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  height: 100vh;
  overflow-y: auto;
}

/* Toggle Compress Button */
.sidebar-toggle-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #ffffff;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.08);
}

/* Custom Internal Scrollbar for Sidebar */
.sidebar::-webkit-scrollbar {
  width: 5px;
}
.sidebar::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.6);
}
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  padding-left: 8px;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  flex-shrink: 0;
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.5px;
  white-space: nowrap;
  transition: opacity 0.2s ease;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-sidebar);
  text-decoration: none;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 500;
  transition: all 0.2s ease;
  touch-action: manipulation;
  position: relative;
  white-space: nowrap;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

/* ACTIVE STATE STYLING */
.nav-link.active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8) !important;
  color: #ffffff !important;
  font-weight: 800 !important;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
  border-left: 4px solid #38bdf8;
  padding-left: 14px;
}

.nav-link.active i {
  color: #ffffff !important;
  transform: scale(1.15);
}

.nav-link.active::after {
  content: "›";
  font-size: 1.5rem;
  font-weight: 900;
  margin-left: auto;
  color: #ffffff;
  line-height: 1;
}

/* NAV GROUP & SUBMENU STYLING */
.nav-group {
  display: flex;
  flex-direction: column;
}

.nav-group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  color: var(--text-sidebar);
  background: transparent;
  border: none;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.nav-group-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.nav-group.open .nav-group-toggle {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}

.nav-group-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-group-chevron {
  font-size: 0.8rem;
  transition: transform 0.25s ease;
}

.nav-group.open .nav-group-chevron {
  transform: rotate(180deg);
}

.nav-sublist {
  list-style: none;
  display: none;
  flex-direction: column;
  gap: 4px;
  padding-left: 10px;
  margin-top: 4px;
  margin-bottom: 6px;
  border-left: 2px solid rgba(255, 255, 255, 0.1);
  margin-left: 18px;
}

.nav-group.open .nav-sublist {
  display: flex;
}

.nav-sublist .nav-link {
  padding: 9px 12px;
  font-size: 0.88rem;
  border-radius: 8px;
}

/* ====================================================================
   ESTADO COMPRIMIDO DEL MENÚ LATERAL (SIDEBAR COLLAPSED / MINI SIDEBAR)
   ==================================================================== */
body.sidebar-collapsed .sidebar {
  width: 76px;
  padding: 20px 8px;
}

body.sidebar-collapsed .sidebar-brand {
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  gap: 10px !important;
  margin-bottom: 24px !important;
}

body.sidebar-collapsed .sidebar-brand .brand-icon {
  margin: 0 auto;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

body.sidebar-collapsed .sidebar-brand .brand-name,
body.sidebar-collapsed .nav-link span,
body.sidebar-collapsed .nav-link::after,
body.sidebar-collapsed .nav-group-toggle span,
body.sidebar-collapsed .nav-group-chevron {
  display: none !important;
}

body.sidebar-collapsed .nav-link,
body.sidebar-collapsed .nav-group-toggle {
  justify-content: center;
  padding: 12px 0;
}

body.sidebar-collapsed .nav-sublist {
  padding-left: 0;
  margin-left: 0;
  border-left: none;
}

body.sidebar-collapsed .nav-link.active {
  border-left: none !important;
  border-bottom: 3px solid #38bdf8 !important;
  padding-left: 0 !important;
}

body.sidebar-collapsed .nav-link i,
body.sidebar-collapsed .nav-group-toggle i {
  font-size: 1.3rem;
}

body.sidebar-collapsed .main-content {
  margin-left: 76px;
}

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-left: 260px;
  background-color: var(--bg-dark);
  min-width: 0;
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}

.topbar {
  height: 70px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}

.topbar-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 12px;
}

.role-pill {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.content-body {
  padding: 32px;
}

/* Premium Light Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow-card);
}

/* Grid Systems */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
}

.stat-val {
  font-size: 2rem;
  font-weight: 800;
  margin-top: 4px;
  color: var(--text-main);
}

/* Room Matrix Grid */
.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.room-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  touch-action: manipulation;
}

.room-card:hover, .room-card:active {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
  border-color: var(--primary);
}

.room-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
  border-top-left-radius: 12px;
  border-bottom-left-radius: 12px;
}

.room-card.disponible::before { background: var(--status-disponible); }
.room-card.ocupada::before { background: var(--status-ocupada); }
.room-card.limpieza::before { background: var(--status-limpieza); }
.room-card.mantenimiento::before { background: var(--status-mantenimiento); }

.room-num {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
}

.room-type {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 500;
}

/* Status Badges */
.badge-status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-disponible { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.badge-ocupada { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.badge-limpieza { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.badge-mantenimiento { background: #f3e8ff; color: #6b21a8; border: 1px solid #e9d5ff; }

/* Tables (Responsive Scroll) */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  text-align: left;
  min-width: 600px; /* Garantiza lectura limpia en móviles */
}

.custom-table th {
  padding: 14px 16px;
  background: #f1f5f9;
  color: #475569;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
}

.custom-table td {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.92rem;
  color: var(--text-main);
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: #334155;
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn {
  padding: 12px 22px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  touch-action: manipulation;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover, .btn-primary:active {
  background: var(--primary-hover);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.btn-danger {
  background: var(--status-ocupada);
  color: #ffffff;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.6rem;
  color: #0f172a;
  cursor: pointer;
  padding: 4px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 90;
}

/* ====================================================================
   MEDIA QUERIES RESPONSIVAS (MÓVILES Y TABLETS 320px - 768px)
   ==================================================================== */
@media (max-width: 768px) {
  body {
    flex-direction: column;
  }

  .mobile-menu-btn {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.3);
  }

  .main-content {
    margin-left: 0 !important;
  }

  .sidebar.active {
    transform: translateX(0);
  }

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

  .topbar {
    padding: 0 16px;
    height: 64px;
  }

  .topbar-title {
    font-size: 1.05rem;
  }

  .content-body {
    padding: 16px;
  }

  .grid-4 {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .stat-card {
    padding: 16px;
  }

  .stat-val {
    font-size: 1.5rem;
  }

  .room-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
  }

  .room-card {
    padding: 12px;
  }

  .room-num {
    font-size: 1.3rem;
  }

  /* Modales Responsivos Táctiles */
  #tenantModal .card,
  #editTenantModal .card,
  #statusModal .card,
  #createPlanModal .card,
  #editPlanModal .card {
    width: 95% !important;
    max-height: 85vh !important;
    padding: 20px !important;
    margin: 0 10px;
  }

  /* Formularios en 1 columna para Smartphone */
  div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 480px) {
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .user-badge .role-pill {
    display: none; /* Simplifica en pantallas ultracompactas */
  }
}
