/* ==========================================
   RESET Y VARIABLES CSS
   ========================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Colores principales */
  --primary-color: #054496;
  --primary-dark: #043775;
  --success-color: #4caf50;
  --success-light: #e8f5e9;
  --success-dark: #388e3c;
  --warning-color: #f9ab00;
  --warning-light: #fff8e1;
  --error-color: #ef5350;
  --error-light: #ffebee;

  /* Fondos y superficies */
  --background: #f1f3f4;
  --surface: #ffffff;
  --bg-white: #ffffff;
  --bg-gray-50: #f9fafb;
  --bg-gray-100: #f3f4f6;

  /* Texto */
  --text-primary: #202124;
  --text-secondary: #5f6368;

  /* Bordes y sombras */
  --border-color: #dadce0;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.15);

  /* Accent colors */
  --accent-blue: #054496;
  --accent-blue-light: #e3f2fd;

  /* Border radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

/* ==========================================
   LAYOUT BASE
   ========================================== */

html,
body {
  height: 100%;
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--background);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ==========================================
   HEADER
   ========================================== */

.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.header-content {
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.view-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.tab-btn,
button[data-view] {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
  position: relative;
  font-family: 'Roboto', sans-serif;
}

.tab-btn:hover,
button[data-view]:hover {
  background: rgba(26, 115, 232, 0.08);
  color: var(--primary-color);
}

.tab-btn.active,
button[data-view].active {
  background: rgba(26, 115, 232, 0.12);
  color: var(--primary-color);
}

.tab-btn svg,
button[data-view] svg {
  opacity: 0.7;
}

.tab-btn.active svg,
button[data-view].active svg {
  opacity: 1;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: center;
}

.title {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  white-space: nowrap;
  margin: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.last-update {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 6px 12px;
  background: var(--bg-gray-50);
  border-radius: var(--radius-sm);
}

/* ==========================================
   BOTONES
   ========================================== */

.btn-icon {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: var(--accent-blue-light);
  color: var(--primary-color);
}

.btn-icon.loading svg {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.btn-nav {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary-color);
  color: white;
  font-size: 13px;
  font-weight: 500;
  font-family: 'Roboto', sans-serif;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

.btn-nav:hover {
  background: var(--primary-dark);
  box-shadow: var(--shadow-md);
}

.btn-nav:active {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.btn-primary,
.btn-secondary {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  font-family: 'Roboto', sans-serif;
  transition: all 0.2s;
}

/* NOTA: Los botones dentro de .modal-actions usan estilos de formulario-cita.css */
/* Estos estilos son para botones FUERA de formularios */

.btn-primary {
  background: var(--primary-color);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
  background: #e0e0e0;
  color: #9e9e9e;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: transparent;
  color: var(--primary-color);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: #f8f9fa;
}

/* Sobrescribir para botones de formulario */
.modal-actions .btn-primary,
.modal-actions .btn-secondary {
  /* Estilos definidos en formulario-cita.css */
  all: unset;
}

.btn-accion {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
}

.btn-accion .material-icons {
  font-size: 20px;
  color: var(--text-secondary);
}

.btn-accion:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-accion-llamar:hover {
  background: var(--accent-blue-light);
  border-color: var(--primary-color);
}

.btn-accion-llamar:hover .material-icons {
  color: var(--primary-color);
}

.btn-accion-modificar:hover {
  background: #fff3e0;
  border-color: #f57c00;
}

.btn-accion-modificar:hover .material-icons {
  color: #f57c00;
}

.btn-accion-eliminar:hover {
  background: #fce8e6;
  border-color: #c5221f;
}

.btn-accion-eliminar:hover .material-icons {
  color: #c5221f;
}

/* ==========================================
   MAIN LAYOUT
   ========================================== */

.main-content {
  flex: 1;
  display: flex;
  width: 100%;
  overflow: hidden;
}

.vista-container {
  display: none;
  flex: 1;
  width: 100%;
  overflow: hidden;
}

.vista-container.active {
  display: flex;
  flex-direction: column;
}

.grid-wrapper {
  flex: 1;
  padding: 0;
  width: 100%;
  overflow-x: auto;
  overflow-y: auto;
}

.slots-view {
  overflow-y: auto;
  padding: 20px;
}

/* ==========================================
   SIDEBAR
   ========================================== */

.sidebar {
  display: none;
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border-color);
  padding: 24px;
  overflow-y: auto;
}

body.device-desktop .sidebar {
  display: block;
}

body.device-android-tablet .sidebar,
body.device-ipad .sidebar,
body.device-tablet .sidebar,
body.device-mobile .sidebar {
  display: none !important;
}

/* ==========================================
   MODAL
   ========================================== */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal.show {
  display: flex;
  opacity: 1;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
  position: relative;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.modal.show .modal-content {
  transform: scale(1);
}

.modal-close,
.close-modal {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--bg-gray-100);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0;
  z-index: 10;
}

.modal-close:hover,
.close-modal:hover {
  background: var(--border-color);
  color: var(--text-primary);
  transform: rotate(90deg);
}

.modal-close svg,
.close-modal svg {
  width: 20px;
  height: 20px;
}

.modal h3 {
  color: var(--text-primary);
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 16px;
  padding-right: 40px;
}

.modal p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 8px;
}

.cita-detalle {
  margin: 16px 0;
}

.cita-detalle p {
  margin-bottom: 12px;
  line-height: 1.5;
}

.cita-detalle strong {
  color: var(--text-primary);
  font-weight: 500;
  display: inline-block;
  min-width: 80px;
}

.modal-actions {
  margin-top: 20px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ==========================================
   FORMULARIOS - TODOS LOS ESTILOS MOVIDOS A styles/formulario-cita.css
   ========================================== */

/* ==========================================
   CITAS CANCELADAS
   ========================================== */

.cita-cancelada-item {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s ease;
}

.cita-cancelada-item:hover {
  background: var(--bg-gray-50);
}

.cita-cancelada-item:last-child {
  border-bottom: none;
}

/* ==========================================
   LOADING
   ========================================== */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-overlay.show {
  display: flex;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-dialog {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.loading-dialog .spinner {
  border-color: var(--border-color);
  border-top-color: var(--primary-color);
}

.loading-dialog p {
  color: var(--text-secondary);
  margin: 0;
}