/* ====================================
   RESPONSIVE DESIGN - MOBILE FIRST
   ==================================== */

/* ===================================
   BASE STYLES (Mobile First - Default)
   =================================== */

/* Sidebar móvil por defecto */
.sidebar {
  width: 280px;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}

.sidebar.active {
  transform: translateX(0);
}

.sidebar-toggle {
  display: block;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 101;
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 0.75rem;
  border-radius: 0.5rem;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.sidebar-toggle:hover {
  background-color: var(--primary-dark);
}

/* Overlay para cerrar sidebar en móvil */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

.sidebar-overlay.active {
  display: block;
}

/* Contenido principal móvil */
.main-content {
  margin-left: 0;
  padding: 1rem;
  padding-top: 4rem;
  /* Espacio para el toggle */
  width: 100%;
}

/* Grid responsive - Mobile */
.grid-2,
.grid-3,
.grid-4 {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

/* Stats cards móvil */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.stat-card {
  padding: 1rem;
}

.stat-value {
  font-size: 1.5rem;
}

/* Tarjetas de citas móvil */
.appointments-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.appointment-card {
  width: 100%;
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  background-color: var(--dark-secondary);
}

/* Tables responsive */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  min-width: 600px;
  font-size: 0.875rem;
}

th,
td {
  padding: 0.75rem 0.5rem;
}

/* Modales móvil */
.modal {
  max-width: 100%;
  margin: 0;
  border-radius: 0;
  max-height: 100vh;
  overflow-y: auto;
}

.modal-content {
  padding: 1rem;
}

/* Page header móvil */
.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.page-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.page-actions .btn {
  width: 100%;
  justify-content: center;
}

/* Cards móvil */
.card {
  padding: 1rem;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

/* Forms móvil */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  width: 100%;
}

/* Calendar móvil */
.calendar-grid {
  gap: 0.25rem;
}

.calendar-day {
  font-size: 0.875rem;
  padding: 0.5rem;
}

/* Toast notifications móvil */
#toast-container {
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  pointer-events: none !important;
}

.toast {
  min-width: auto;
  max-width: 100%;
}

/* Dashboard widgets móvil */
.widget {
  margin-bottom: 1rem;
}

.chart-container {
  height: 250px;
}

/* ===================================
   TABLETS (min-width: 768px)
   =================================== */

@media (min-width: 768px) {

  /* Contenido principal */
  .main-content {
    padding: 1.5rem;
  }

  /* Grid 2 columnas */
  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Stats cards - 2 columnas */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-card {
    padding: 1.5rem;
  }

  .stat-value {
    font-size: 2rem;
  }

  /* Tarjetas de citas - 2 por fila */
  .appointments-container {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .appointment-card {
    width: calc(50% - 0.5rem);
  }

  /* Page header */
  .page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .page-header h1 {
    font-size: 1.75rem;
    margin-bottom: 0;
  }

  .page-actions {
    flex-direction: row;
    margin-top: 0;
  }

  .page-actions .btn {
    width: auto;
  }

  /* Cards */
  .card {
    padding: 1.5rem;
  }

  .card-title {
    font-size: 1.5rem;
  }

  /* Forms - 2 columnas */
  .form-row {
    flex-direction: row;
  }

  .form-group {
    flex: 1;
  }

  /* Tables */
  .table {
    font-size: 0.9375rem;
  }

  th,
  td {
    padding: 1rem 0.75rem;
  }

  /* Modales */
  .modal {
    max-width: 600px;
    margin: 2rem auto;
    border-radius: 0.75rem;
    max-height: calc(100vh - 4rem);
  }

  .modal-content {
    padding: 1.5rem;
  }

  /* Calendar */
  .calendar-day {
    font-size: 1rem;
    padding: 0.75rem;
  }

  /* Charts */
  .chart-container {
    height: 300px;
  }

  /* Toast notifications */
  #toast-container {
    right: 2rem;
    left: auto;
    bottom: 2rem;
    pointer-events: none !important;
  }

  .toast {
    min-width: 300px;
    max-width: 400px;
  }
}

/* ===================================
   DESKTOP SMALL (min-width: 1024px)
   =================================== */

@media (min-width: 1024px) {

  /* Sidebar ELIMINADO - Contenido Full Width */
  .sidebar,
  .sidebar-toggle,
  .sidebar-overlay {
    display: none !important;
  }

  /* Contenido principal CENTRADO en desktop */
  .main-content {
    margin: 0 auto !important;
    padding: 2rem;
    padding-top: 2rem;
    width: 100% !important;
  }

  /* Grid 3 columnas */
  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Stats cards - 3 o 4 columnas */
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }

  /* Tarjetas de citas - 3 por fila */
  .appointments-container {
    gap: 1rem;
  }

  .appointment-card {
    width: calc(33.333% - 0.67rem);
  }

  /* Page header */
  .page-header h1 {
    font-size: 2rem;
  }

  /* Cards */
  .card {
    padding: 2rem;
  }

  /* Modales más grandes */
  .modal {
    max-width: 700px;
  }

  /* Charts */
  .chart-container {
    height: 350px;
  }
}

/* ===================================
   DESKTOP LARGE (min-width: 1200px)
   =================================== */

@media (min-width: 1200px) {

  /* Grid 4 columnas */
  .grid-4 {
    grid-template-columns: repeat(4, 1fr);
  }

  /* Stats cards - 4 columnas */
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  /* Tarjetas de citas - 4 por fila */
  .appointment-card {
    width: calc(25% - 0.75rem);
  }

  /* Modales extra grandes */
  .modal.modal-large {
    max-width: 900px;
  }

  /* Charts más grandes */
  .chart-container {
    height: 400px;
  }

  /* Tables con más espacio */
  th,
  td {
    padding: 1rem;
  }
}

/* ===================================
   DESKTOP EXTRA LARGE (min-width: 1440px)
   =================================== */

@media (min-width: 1440px) {
  .main-content {
    max-width: 1400px;
    margin-left: auto !important;
    margin-right: auto !important;
    padding: 2rem;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
  }

  .chart-container {
    height: 450px;
  }
}

/* ===================================
   UTILITY CLASSES
   =================================== */

/* Ocultar en móvil */
@media (max-width: 767px) {
  .hide-mobile {
    display: none !important;
  }
}

/* Ocultar en tablet */
@media (min-width: 768px) and (max-width: 1023px) {
  .hide-tablet {
    display: none !important;
  }
}

/* Ocultar en desktop */
@media (min-width: 1024px) {
  .hide-desktop {
    display: none !important;
  }
}

/* Mostrar solo en móvil */
.show-mobile {
  display: block;
}

@media (min-width: 768px) {
  .show-mobile {
    display: none !important;
  }
}

/* Mostrar solo en tablet */
.show-tablet {
  display: none;
}

@media (min-width: 768px) and (max-width: 1023px) {
  .show-tablet {
    display: block !important;
  }
}

/* Mostrar solo en desktop */
.show-desktop {
  display: none;
}

@media (min-width: 1024px) {
  .show-desktop {
    display: block !important;
  }
}

/* ===================================
   PRINT STYLES
   =================================== */

@media print {

  .sidebar,
  .sidebar-toggle,
  .page-actions,
  .btn {
    display: none !important;
  }

  .main-content {
    margin-left: 0;
    padding: 0;
  }

  .card {
    page-break-inside: avoid;
    border: 1px solid #000;
  }
}

@media (max-width: 480px) {
  .auth-card {
    padding: 1.5rem;
  }

  .btn {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
  }

  .form-group input,
  .form-group select,
  .form-group textarea {
    padding: 0.625rem;
    font-size: 0.875rem;
  }

  .sidebar {
    width: 100%;
  }

  .appointment-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .appointment-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* Landscape phone */
@media (max-height: 500px) and (orientation: landscape) {
  .auth-container {
    padding: 1rem;
  }

  .auth-card {
    padding: 1.5rem;
  }

  .sidebar {
    overflow-y: auto;
  }
}

/* ===================================
   DESKTOP UI CLEANUP
   =================================== */
@media (min-width: 1024px) {

  .sidebar,
  .sidebar-toggle,
  .mobile-menu-btn,
  .sidebar-overlay {
    display: none !important;
  }

  .main-content {
    margin: 0 auto !important;
    width: 100% !important;
  }
}

/* Print styles */
@media print {

  .sidebar,
  .page-actions,
  .action-buttons,
  #toast-container,
  .modal-overlay {
    display: none !important;
  }

  .main-content {
    margin-left: 0;
    padding: 0;
  }

  body {
    background: white;
    color: black;
  }

  .card {
    border: 1px solid #ddd;
    box-shadow: none;
  }
}