:root {
  --sidebar-width: 280px;
  --primary-color: #0d6efd;
  --success-color: #198754;
  --warning-color: #ffc107;
  --danger-color: #dc3545;
  --dark-bg: #1a1a1a;
  --dark-sidebar: #2d3436;
  --dark-card: #2d3436;
  --light-bg: #f8f9fa;
  --light-sidebar: #ffffff;
  --light-card: #ffffff;
  --transition-speed: 0.3s;
}

/* Light theme (default) */
body {
  font-family: 'Inter', sans-serif;
  background-color: var(--light-bg);
  color: #212529;
  transition:
    background-color var(--transition-speed),
    color var(--transition-speed);
}

.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background-color: var(--light-sidebar);
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  transition: all var(--transition-speed);
}

.main-content {
  margin-left: var(--sidebar-width);
  transition: margin-left var(--transition-speed);
}

/* Menu styles */
.sidebar .nav-link {
  color: #6c757d;
  padding: 1rem 1.25rem;
  margin: 0.25rem 0.75rem;
  border-radius: 0.75rem;
  transition: all var(--transition-speed);
  position: relative;
  font-weight: 500;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar .nav-link:hover {
  color: var(--primary-color);
  background-color: rgba(13, 110, 253, 0.1);
  transform: translateX(4px);
}

.sidebar .nav-link.active {
  color: white;
  background: linear-gradient(135deg, var(--primary-color), #0056b3);
  box-shadow: 0 4px 15px rgba(13, 110, 253, 0.3);
  transform: translateX(4px);
}

.sidebar .nav-link.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 60%;
  background-color: white;
  border-radius: 2px;
}

.sidebar .nav-link .bi {
  font-size: 1.2rem;
  transition: transform var(--transition-speed);
}

.sidebar .nav-link:hover .bi {
  transform: scale(1.1);
}

/* Cards */
.card {
  border: none;
  border-radius: 1rem;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.08);
  transition: all var(--transition-speed);
  background-color: var(--light-card);
}

.card:hover {
  box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
}

/* Dark theme */
[data-bs-theme='dark'] {
  --bg-color: var(--dark-bg);
  --sidebar-bg: var(--dark-sidebar);
  --card-bg: var(--dark-card);
}

[data-bs-theme='dark'] body {
  background-color: var(--dark-bg);
  color: #e9ecef;
}

[data-bs-theme='dark'] .sidebar {
  background-color: var(--dark-sidebar);
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
}

[data-bs-theme='dark'] .sidebar .nav-link {
  color: #adb5bd;
}

[data-bs-theme='dark'] .sidebar .nav-link:hover {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme='dark'] .card {
  background-color: var(--dark-card);
  color: #e9ecef;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.3);
}

[data-bs-theme='dark'] .card:hover {
  box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.4);
}

/* Theme switch animation */
.theme-switch-wrapper {
  position: relative;
}

.theme-switch {
  position: relative;
  width: 50px;
  height: 24px;
  border-radius: 12px;
  background-color: #ccc;
  cursor: pointer;
  transition: background-color var(--transition-speed);
}

.theme-switch.active {
  background-color: var(--primary-color);
}

.theme-switch::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: white;
  transition: transform var(--transition-speed);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.theme-switch.active::before {
  transform: translateX(26px);
}

/* Loading animations */
@keyframes pulse {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
  100% {
    opacity: 1;
  }
}

.loading {
  animation: pulse 1.5s infinite;
}

/* Dashboard cards enhancements */
.dashboard-card {
  background: linear-gradient(135deg, var(--primary-color), #0056b3);
  color: white;
  border-radius: 1rem;
  transition: all var(--transition-speed);
  position: relative;
  overflow: hidden;
}

.dashboard-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100px;
  height: 100px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  transform: translate(30px, -30px);
}

.dashboard-card.success {
  background: linear-gradient(135deg, var(--success-color), #0f5132);
}

.dashboard-card.warning {
  background: linear-gradient(135deg, var(--warning-color), #997404);
  color: #212529;
}

.dashboard-card.danger {
  background: linear-gradient(135deg, var(--danger-color), #8b1d2c);
}

.dashboard-card .card-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  opacity: 0.9;
}

.dashboard-card .card-text {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0;
}

.dashboard-card .opacity-50 {
  opacity: 0.7;
}

/* Table enhancements */
.table-hover tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.05);
  transform: scale(1.01);
  transition: all var(--transition-speed);
}

[data-bs-theme='dark'] .table-hover tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

/* Button enhancements */
.btn {
  border-radius: 0.75rem;
  font-weight: 500;
  transition: all var(--transition-speed);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Header enhancements */
header {
  background: white;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  border-radius: 1rem;
  margin-bottom: 2rem;
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

[data-bs-theme='dark'] header {
  background: var(--dark-card);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Ensure theme switch is properly positioned in header */
header .theme-switch-wrapper {
  order: -1;
}

header h1,
header h2 {
  margin: 0;
  flex: 1;
}

[data-bs-theme='dark'] header {
  background: var(--dark-card);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Sidebar header */
.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 1rem;
}

.sidebar-header a {
  font-size: 1.5rem;
  font-weight: 700;
  text-decoration: none;
  transition: all var(--transition-speed);
}

.sidebar-header a:hover {
  transform: scale(1.05);
}

/* Footer */
.sidebar-footer {
  margin-top: auto;
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-footer .nav-link {
  color: rgba(255, 255, 255, 0.6);
  padding: 0.75rem 1rem;
  margin: 0;
}

.sidebar-footer .nav-link:hover {
  color: rgba(255, 255, 255, 0.8);
  background-color: rgba(255, 255, 255, 0.05);
}

/* Calendar Styles */
.calendar-grid {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}

.calendar-grid th {
  border-bottom: 2px solid #dee2e6;
  border-right: 1px solid #dee2e6;
  padding: 0.75rem 0.25rem;
  vertical-align: bottom;
}

.calendar-grid th:last-child {
  border-right: none;
}

.calendar-grid .time-column {
  border-right: 2px solid #dee2e6 !important;
  background-color: #f8f9fa;
  width: 80px;
  min-width: 80px;
}

.calendar-grid .day-column {
  min-width: 120px;
}

.calendar-grid .professional-column {
  padding: 0.25rem;
  font-size: 0.75rem;
  color: #6c757d;
  border-right: 1px solid #dee2e6;
}

.calendar-grid .professional-column:last-child {
  border-right: none;
}

.calendar-cell {
  height: 60px;
  min-height: 60px;
  border-right: 1px solid #dee2e6;
  border-bottom: 1px solid #dee2e6;
  padding: 2px;
  position: relative;
  vertical-align: top;
  background-color: white;
  transition: background-color var(--transition-speed);
}

.calendar-cell:hover {
  background-color: #f8f9fa;
}

.calendar-cell:last-child {
  border-right: none;
}

.booking-card {
  background: transparent;
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  padding: 0.25rem 0.375rem;
  margin-bottom: 2px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: all var(--transition-speed);
  overflow: hidden;
  position: relative;
}

.calendar-cell.cell-free {
  background-color: #e8f5e9; /* Light Green */
  color: #1b5e20;
}
.calendar-cell.cell-free:hover {
  background-color: #dcedc8;
}

.calendar-cell.cell-occupied {
  background-color: #ffebee; /* Light Red */
}

.calendar-cell.cell-pending {
  background-color: #fffde7; /* Light Yellow */
}

.calendar-cell.cell-out-of-hours {
  background-color: #f5f5f5; /* Light Gray */
  pointer-events: none;
}

.booking-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

.booking-card.booking-confirmed {
  border-left: 4px solid var(--success-color);
  background: linear-gradient(135deg, rgba(25, 135, 84, 0.1), rgba(25, 135, 84, 0.05));
}

.booking-card.booking-pending {
  border-left: 4px solid var(--warning-color);
  background: linear-gradient(135deg, rgba(255, 193, 7, 0.1), rgba(255, 193, 7, 0.05));
}

.booking-card.booking-cancelled {
  border-left: 4px solid var(--danger-color);
  background: linear-gradient(135deg, rgba(220, 53, 69, 0.1), rgba(220, 53, 69, 0.05));
}

.booking-card.booking-no_show {
  border-left: 4px solid #fd7e14;
  background: linear-gradient(135deg, rgba(253, 126, 20, 0.1), rgba(253, 126, 20, 0.05));
}

.booking-content {
  font-size: 0.75rem;
  line-height: 1.2;
}

.booking-client {
  font-weight: 600;
  color: #212529;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.booking-service {
  color: #6c757d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.7rem;
}

.booking-phone {
  color: #6c757d;
  font-size: 0.65rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Week navigation */
#currentWeek {
  font-weight: 600;
  color: var(--primary-color);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  background-color: rgba(13, 110, 253, 0.1);
  border: 1px solid rgba(13, 110, 253, 0.2);
}

/* ========================================
   CALENDAR ENHANCEMENTS
   ======================================== */

/* Slot indicators for empty cells */
.slot-indicator {
  padding: 0.25rem;
  text-align: center;
  cursor: pointer;
  border-radius: 0.25rem;
  transition: all var(--transition-speed);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slot-indicator:hover {
  background-color: rgba(13, 110, 253, 0.1);
  transform: scale(1.02);
}

.slot-free {
  background-color: rgba(25, 135, 84, 0.1);
  border: 1px dashed rgba(25, 135, 84, 0.3);
}

.slot-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
}

.status-icon {
  font-size: 1.2rem;
}

.status-text {
  font-size: 0.7rem;
  font-weight: 600;
  color: #198754;
}

/* Enhanced booking cards */
.booking-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.booking-time {
  font-size: 0.7rem;
  color: #6c757d;
  font-weight: 500;
}

/* Professional color indicators */
.professional-color-indicator {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 0.5rem;
  vertical-align: middle;
}

/* Stats card */
.stats-card {
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  border: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.stat-item {
  text-align: center;
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.8rem;
  color: #6c757d;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.professional-stats {
  padding: 0.75rem;
  background: white;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.professional-stats h6 {
  margin: 0 0 0.5rem 0;
  color: #495057;
  font-size: 0.9rem;
}

/* Booking details modal */
.booking-details {
  background: #f8f9fa;
  padding: 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid #dee2e6;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-row strong {
  color: #495057;
  min-width: 120px;
}

/* Filter buttons */
.btn-group .btn.active {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

/* Search input in filters */
#search-client {
  min-width: 200px;
}

/* Dark theme calendar adjustments */
[data-bs-theme='dark'] .calendar-cell {
  background-color: var(--dark-card);
  border-color: #495057;
}

[data-bs-theme='dark'] .calendar-grid th {
  background-color: var(--dark-card);
  border-color: #495057;
  color: #e9ecef;
}

[data-bs-theme='dark'] .calendar-grid .time-column {
  background-color: #343a40;
}

[data-bs-theme='dark'] .booking-card {
  background-color: var(--dark-card);
  border-color: #495057;
  color: #e9ecef;
}

[data-bs-theme='dark'] .booking-card .booking-client {
  color: #e9ecef;
}

[data-bs-theme='dark'] .booking-card .booking-service,
[data-bs-theme='dark'] .booking-card .booking-phone {
  color: #adb5bd;
}

[data-bs-theme='dark'] .slot-free {
  background-color: rgba(25, 135, 84, 0.2);
  border-color: rgba(25, 135, 84, 0.5);
}

[data-bs-theme='dark'] .stats-card {
  background: linear-gradient(135deg, #343a40, #495057);
  color: #e9ecef;
}

[data-bs-theme='dark'] .professional-stats {
  background: var(--dark-card);
  color: #e9ecef;
}

[data-bs-theme='dark'] .booking-details {
  background: var(--dark-card);
  color: #e9ecef;
}

/* ========================================
   MOBILE FIRST - RESPONSIVE LAYOUT
   ======================================== */

/* Reset del body */
body {
  display: block !important; /* Cambiar de flex a block */
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

/* Botón hamburguesa (solo móvil) */
.mobile-menu-toggle {
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 1100;
  background: #0d6efd;
  color: white;
  border: none;
  border-radius: 8px;
  width: 45px;
  height: 45px;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: all var(--transition-speed);
}

.mobile-menu-toggle:hover {
  background: #0b5ed7;
  transform: scale(1.05);
}

/* Overlay oscuro (solo móvil) */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1040;
  display: none;
  transition: opacity var(--transition-speed);
}

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

/* ========================================
   SIDEBAR - RESPONSIVE
   ======================================== */

.sidebar-wrapper {
  /* Desktop por defecto */
  width: 280px;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1050;
  background: white;
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
  overflow-y: auto;
  transition: transform var(--transition-speed);
}

/* ========================================
   MAIN CONTENT - RESPONSIVE
   ======================================== */

.main-content {
  /* Desktop: margen para el sidebar */
  margin-left: 280px;
  width: calc(100% - 280px);
  min-height: 100vh;
  padding: 20px;
  transition: margin-left var(--transition-speed);
}

/* ========================================
   MOBILE (< 768px)
   ======================================== */

@media (max-width: 767px) {
  /* Mostrar botón hamburguesa */
  .mobile-menu-toggle {
    display: flex !important;
  }

  /* Sidebar oculto por defecto */
  .sidebar-wrapper {
    transform: translateX(-100%);
  }

  /* Sidebar visible cuando tiene clase "active" */
  .sidebar-wrapper.active {
    transform: translateX(0);
  }

  /* Main content ocupa todo el ancho */
  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    padding: 70px 15px 15px 15px; /* Espacio arriba para el botón */
  }

  /* Tablas responsive */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Calendario en móvil: scroll horizontal */
  .calendar-grid {
    min-width: 800px; /* Forzar scroll horizontal */
    font-size: 0.75rem;
  }

  .calendar-cell {
    height: 50px;
    min-height: 50px;
    padding: 1px;
  }

  .booking-card {
    padding: 0.125rem 0.25rem;
    margin-bottom: 1px;
  }

  .booking-content {
    font-size: 0.7rem;
  }

  .booking-client {
    font-size: 0.75rem;
  }

  .booking-service {
    font-size: 0.65rem;
  }

  .booking-phone {
    font-size: 0.6rem;
  }

  /* Hide weekend columns on mobile */
  .d-md-none {
    display: none !important;
  }

  .d-md-table-cell {
    display: none !important;
  }

  /* Show only selected day on mobile */
  .calendar-cell.mobile-hidden {
    display: none;
  }

  .calendar-cell.mobile-visible {
    display: table-cell;
  }

  /* Cards más compactas */
  .card {
    margin-bottom: 15px;
  }

  /* Botones más grandes para touch */
  .btn {
    min-height: 44px; /* Tamaño mínimo recomendado para touch */
  }

  /* Headers más compactos */
  header h1 {
    font-size: 1.5rem;
  }

  /* Modales a pantalla completa en móvil */
  .modal-dialog {
    margin: 0;
    max-width: 100%;
  }

  .modal-content {
    border-radius: 0;
    min-height: 100vh;
  }

  /* Theme switch más accesible en móvil */
  .theme-switch-wrapper {
    margin-right: 1rem !important;
  }
}

/* ========================================
   TABLET (768px - 991px)
   ======================================== */

@media (min-width: 768px) and (max-width: 991px) {
  .main-content {
    margin-left: 280px;
    width: calc(100% - 280px);
  }
}

/* ========================================
   DESKTOP (> 992px)
   ======================================== */

@media (min-width: 992px) {
  .main-content {
    margin-left: 280px;
    width: calc(100% - 280px);
  }
}
