/**
 * PERSONALIZADOR DE ESTILO Y COLORES
 * Inspirado en Apple Human Interface Design System
 */

/* ==========================================================================
   BOTÓN FLOTANTE TRIGGER (Discreto y Táctil)
   ========================================================================== */
.theme-customizer-toggle {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: calc(24px + env(safe-area-inset-left, 0px));
  z-index: 999;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: var(--touch-target-min, 44px);
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--color-text, #171717);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: var(--radius-full, 9999px);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.12);
  font-family: var(--font-sans, -apple-system, sans-serif);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition-fast, 200ms ease), box-shadow var(--transition-fast, 200ms ease), background-color var(--transition-fast, 200ms ease);
  user-select: none;
}

.theme-customizer-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
  background: #FFFFFF;
}

.theme-customizer-toggle:active {
  transform: scale(0.97);
}

.theme-customizer-toggle .palette-icon {
  width: 20px;
  height: 20px;
  color: var(--color-accent, #7E3037);
  flex-shrink: 0;
}

/* ==========================================================================
   DRAWER / MODAL OVERLAY (Apple Glassmorphism)
   ========================================================================== */
.theme-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 250ms ease, visibility 250ms ease;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 24px;
}

.theme-modal-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.theme-modal-card {
  width: 100%;
  max-width: 440px;
  max-height: calc(88vh - env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(0.98);
  transition: transform 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

.theme-modal-backdrop.is-open .theme-modal-card {
  transform: translateY(0) scale(1);
}

/* Header */
.theme-modal-header {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.theme-modal-title {
  font-family: var(--font-sans, -apple-system, sans-serif);
  font-size: 1rem;
  font-weight: 700;
  color: #171717;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.theme-modal-close {
  min-width: 36px;
  min-height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.05);
  color: #555555;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  transition: background-color 150ms ease, color 150ms ease;
}

.theme-modal-close:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #171717;
}

/* Body con scroll */
.theme-modal-body {
  padding: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.theme-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6E6E73;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   PRESETS DE PALETAS (1-Click)
   ========================================================================== */
.theme-presets-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.theme-preset-btn {
  background: #FFFFFF;
  border: 1.5px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  transition: all 180ms ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.theme-preset-btn:hover {
  border-color: rgba(0, 113, 227, 0.4);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.theme-preset-btn.is-active {
  border-color: #0071E3;
  background: rgba(0, 113, 227, 0.04);
  box-shadow: 0 0 0 2px rgba(0, 113, 227, 0.2);
}

.theme-swatch-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.theme-swatch-circle {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.theme-preset-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #1D1D1F;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.theme-preset-sub {
  font-size: 0.6875rem;
  color: #86868B;
  margin: 0;
}

/* ==========================================================================
   SELECTORES DE COLOR EN VIVO
   ========================================================================== */
.theme-pickers-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.theme-picker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #FFFFFF;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  padding: 8px 12px;
  min-height: 48px;
}

.theme-picker-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.theme-picker-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #1D1D1F;
}

.theme-picker-desc {
  font-size: 0.6875rem;
  color: #86868B;
}

.theme-picker-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-color-input-wrapper {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.15);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
  cursor: pointer;
}

.theme-color-input {
  position: absolute;
  top: -8px;
  left: -8px;
  width: 50px;
  height: 50px;
  border: none;
  cursor: pointer;
  background: none;
}

.theme-hex-input {
  width: 80px;
  height: 34px;
  padding: 0 8px;
  font-family: monospace;
  font-size: 0.75rem;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 6px;
  text-transform: uppercase;
  color: #333333;
}

/* ==========================================================================
   FOOTER CON ACCIONES
   ========================================================================== */
.theme-modal-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(250, 250, 250, 0.8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.btn-theme-action {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #FFFFFF;
  color: #333333;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 150ms ease;
  min-height: 36px;
}

.btn-theme-action:hover {
  background: #F5F5F7;
  color: #000000;
}

.btn-theme-primary {
  background: #0071E3;
  color: #FFFFFF;
  border-color: #0071E3;
}

.btn-theme-primary:hover {
  background: #005BB5;
  color: #FFFFFF;
}

/* En mobile: modal bottom-sheet */
@media (max-width: 600px) {
  .theme-modal-backdrop {
    padding: 0;
  }
  .theme-modal-card {
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 85vh;
  }
  .theme-presets-grid {
    grid-template-columns: 1fr;
  }
  .theme-customizer-toggle span.toggle-label {
    display: none;
  }
  .theme-customizer-toggle {
    padding: 12px;
  }
}
