/* ===== VARIABLES Y CONFIGURACIÓN GLOBAL ===== */
:root {
  --brand: #ec7400;
  --brand-light: #ff8c29;
  --brand-pale: rgba(236, 116, 0, 0.08);
  --brand-semi: rgba(236, 116, 0, 0.15);
  --brand-accent: rgba(236, 116, 0, 0.3);
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: rgba(255, 255, 255, 0.05);
  --text-primary: #ffffff;
  --text-secondary: #e2e8f0;
  --text-muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.1);
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.2);
  --shadow-xl: 0 12px 48px rgba(0, 0, 0, 0.25);
  --shadow-brand: 0 8px 32px rgba(236, 116, 0, 0.3);
  --shadow-glow: 0 0 20px rgba(236, 116, 0, 0.4);
  --blur: blur(20px);
  --blur-sm: blur(10px);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== ESTILOS BASE ===== */
.settings-page {
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  min-height: 100vh;
  position: relative;
  font-family: 'Inter', sans-serif;
}

.settings-page::before {
  content: '';
  position: fixed;
  inset: 0;
  background: 
    radial-gradient(circle at 25% 25%, rgba(236, 116, 0, 0.06) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(236, 116, 0, 0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ===== ESTRUCTURA PRINCIPAL ===== */
.settings-section {
  padding: 7rem 0 4rem;
  position: relative;
  z-index: 1;
  min-height: calc(100vh - 11rem);
}

.settings-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* ===== CABECERA DE PÁGINA ===== */
.page-header {
  text-align: center;
  margin-bottom: 3rem;
  opacity: 0;
  animation: fadeInUp 0.8s ease forwards;
}

.page-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--brand-pale);
  color: var(--brand);
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  border: 1px solid var(--brand-accent);
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  backdrop-filter: var(--blur);
  transition: var(--transition);
  box-shadow: var(--shadow);
}

.page-badge:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-brand);
}

.page-title {
  font-size: clamp(2.25rem, 4vw, 3rem);
  font-weight: 900;
  color: var(--text-primary);
  margin: 0 0 0.75rem 0;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-primary), var(--brand));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
}

.page-subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

/* ===== PESTAÑAS ===== */
.settings-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2.5rem;
  background: var(--bg-card);
  padding: 0.5rem;
  border-radius: var(--radius-xl);
  backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  opacity: 0;
  animation: fadeInUp 0.8s ease 0.2s forwards;
  position: relative;
  overflow: hidden;
}

.settings-tabs::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  opacity: 0.5;
}

.tab-button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  font-size: 0.95rem;
  min-height: 52px;
}

.tab-button::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--brand-pale);
  opacity: 0;
  transition: var(--transition);
}

.tab-button:hover:not(.active) {
  color: var(--text-primary);
  transform: translateY(-1px);
}

.tab-button:hover:not(.active)::before {
  opacity: 0.5;
}

.tab-button.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  color: white;
  box-shadow: var(--shadow-brand);
  transform: scale(1.02);
}

.tab-button.active::before {
  opacity: 0;
}

.tab-button i {
  font-size: 1rem;
  position: relative;
  z-index: 1;
}

.tab-button span {
  position: relative;
  z-index: 1;
}

/* ===== TARJETAS DE CONFIGURACIÓN ===== */
.settings-form {
  position: relative;
}

.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  backdrop-filter: var(--blur);
  overflow: hidden;
  margin-bottom: 2rem;
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.5s ease forwards;
  position: relative;
  box-shadow: var(--shadow-lg);
  transition: var(--transition);
}

.settings-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--brand-light));
  opacity: 0;
  transition: var(--transition);
}

.settings-card:hover {
  border-color: var(--brand-accent);
  box-shadow: var(--shadow-xl);
  transform: translateY(-2px);
}

.settings-card:hover::before {
  opacity: 1;
}

.card-header {
  padding: 2rem 2rem 1rem;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0 0 0.5rem 0;
  line-height: 1.2;
}

.card-title i {
  color: var(--brand);
  font-size: 1.25rem;
  filter: drop-shadow(0 2px 4px rgba(236, 116, 0, 0.3));
}

.card-subtitle {
  color: var(--text-muted);
  margin: 0;
  font-size: 1rem;
  line-height: 1.5;
}

/* ===== SECCIONES DEL FORMULARIO ===== */
.form-section {
  padding: 1.5rem 2rem 2rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  align-items: start;
}

/* ===== SECCIÓN AVATAR ===== */
.avatar-section {
  display: flex;
  align-items: center;
  gap: 2rem;
  grid-column: 1 / -1;
  padding: 2rem;
  background: var(--brand-pale);
  border-radius: var(--radius-xl);
  border: 1px solid var(--brand-accent);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  margin-bottom: 1rem;
}

.avatar-section::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--brand-pale), rgba(236, 116, 0, 0.05));
  opacity: 0.5;
}

.avatar-section:hover {
  background: var(--brand-semi);
  transform: translateY(-1px);
}

.avatar-preview {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--brand);
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
  box-shadow: var(--shadow-brand);
  z-index: 1;
}

.avatar-preview:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-glow);
}

.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--transition);
}

.avatar-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: var(--transition);
  backdrop-filter: var(--blur-sm);
}

.avatar-preview:hover .avatar-overlay {
  opacity: 1;
}

.avatar-overlay i {
  font-size: 1.5rem;
  color: white;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.avatar-info {
  flex: 1;
  z-index: 1;
}

.avatar-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0 0 0.5rem 0;
  line-height: 1.2;
}

.avatar-subtitle {
  color: var(--text-muted);
  margin: 0 0 1.5rem 0;
  font-size: 0.95rem;
  line-height: 1.4;
}

.file-input {
  position: relative;
  overflow: hidden;
  display: inline-block;
}

.file-input input[type="file"] {
  position: absolute;
  left: -9999px;
}

.file-input-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  color: white;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
  font-weight: 700;
  box-shadow: var(--shadow-brand);
  border: none;
  font-size: 0.9rem;
}

.file-input-btn:hover {
  background: linear-gradient(135deg, var(--brand-light), var(--brand));
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.file-input-btn:active {
  transform: scale(0.98);
}

/* ===== GRUPOS DE FORMULARIO ===== */
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-weight: 700;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.form-label i {
  color: var(--brand);
  width: 16px;
  text-align: center;
  font-size: 1rem;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: var(--transition);
  backdrop-filter: var(--blur-sm);
  font-family: inherit;
  box-shadow: var(--shadow);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-pale), var(--shadow-lg);
  background: var(--brand-pale);
  transform: translateY(-1px);
}

.form-textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.5;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

/* ===== SECCIÓN SEGURIDAD ===== */
.security-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.info-card {
  padding: 2rem;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  transition: var(--transition);
  text-align: center;
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.8s ease forwards;
  position: relative;
  overflow: hidden;
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
  height: fit-content;
}

.info-card:nth-child(1) { animation-delay: 0.1s; }
.info-card:nth-child(2) { animation-delay: 0.2s; }

.info-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  opacity: 0;
  transition: var(--transition);
}

.info-card:hover {
  background: var(--brand-pale);
  border-color: var(--brand-accent);
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
}

.info-card:hover::before {
  opacity: 1;
}

.info-card-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0 0 1rem 0;
  line-height: 1.2;
}

.info-card-title i {
  color: var(--brand);
  font-size: 1.25rem;
  filter: drop-shadow(0 2px 4px rgba(236, 116, 0, 0.3));
}

.info-card-text {
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 1.5rem 0;
  font-size: 0.95rem;
}

/* ===== BOTONES ===== */
.btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  border-radius: var(--radius-lg);
  font-weight: 700;
  text-decoration: none;
  transition: var(--transition);
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  min-height: 48px;
  justify-content: center;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  color: white;
  box-shadow: var(--shadow-brand);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--brand-light), var(--brand));
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.btn-secondary:hover {
  background: var(--brand-pale);
  color: var(--text-primary);
  border-color: var(--brand-accent);
  transform: translateY(-2px);
}

/* ===== INDICADOR DE CAMBIOS SIN GUARDAR ===== */
.unsaved-indicator {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  background: var(--brand);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  transition: var(--transition);
  z-index: 1000;
  backdrop-filter: var(--blur);
  border: 1px solid var(--brand-light);
  font-size: 0.9rem;
}

.unsaved-indicator.show {
  transform: translateX(-50%) translateY(0);
}

.unsaved-indicator i {
  font-size: 1.1rem;
  animation: pulse 2s infinite;
}

/* ===== ALERTAS ===== */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
  border: 1px solid;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  backdrop-filter: var(--blur);
  font-weight: 600;
  font-size: 0.95rem;
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.3);
}

.alert i {
  font-size: 1.1rem;
}

/* ===== ANIMACIONES ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

@keyframes saveSuccess {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

/* ===== ESTADOS DE CARGA ===== */
.settings-form.saving {
  opacity: 0.7;
  pointer-events: none;
}

.settings-form.saving * {
  animation: pulse 1.5s ease-in-out infinite;
}

.save-success {
  animation: saveSuccess 0.5s ease;
}

.save-success::before {
  opacity: 1 !important;
  background: linear-gradient(90deg, transparent, #10b981, transparent) !important;
}

/* ===== ACCIONES DEL FORMULARIO ===== */
.form-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  align-items: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* ===== MEDIDOR DE CONTRASEÑA ===== */
.password-strength {
  margin-top: 0.5rem;
}

.password-bar-container {
  height: 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.password-bar {
  height: 6px;
  width: 0%;
  background: linear-gradient(90deg, #ef4444, #f59e0b, #10b981);
  transition: width 0.25s ease;
  border-radius: 8px;
}

.password-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.3;
}

/* ===== TOGGLE VISIBILIDAD CONTRASEÑA ===== */
.toggle-visibility {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius);
  transition: var(--transition);
  z-index: 2;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toggle-visibility:hover {
  color: var(--brand);
  background: var(--brand-pale);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

/* ===== DISEÑO RESPONSIVE ===== */
@media (max-width: 1024px) {
  .settings-container {
    max-width: 900px;
  }
  
  .form-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

@media (max-width: 768px) {
  .settings-section {
    padding: 6rem 0 3rem;
  }
  
  .settings-container {
    padding: 0 1.5rem;
  }
  
  .settings-tabs {
    flex-direction: column;
    gap: 0.25rem;
  }
  
  .tab-button {
    padding: 0.875rem 1rem;
    justify-content: flex-start;
    min-height: 48px;
  }
  
  .settings-card,
  .form-section {
    padding: 1.5rem;
  }
  
  .card-header {
    padding: 1.5rem 1.5rem 0.5rem;
  }
  
  .avatar-section {
    flex-direction: column;
    text-align: center;
    gap: 1.5rem;
    padding: 1.5rem;
  }
  
  .security-section {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .avatar-preview {
    width: 80px;
    height: 80px;
  }
  
  .form-actions {
    flex-direction: column;
    gap: 1rem;
  }
  
  .btn {
    width: 100%;
    justify-content: center;
  }
  
  .page-title {
    font-size: 2rem;
  }
  
  .card-title {
    font-size: 1.35rem;
  }
}

@media (max-width: 480px) {
  .settings-section {
    padding: 5rem 0 2rem;
  }
  
  .settings-container {
    padding: 0 1rem;
  }
  
  .page-header {
    margin-bottom: 2rem;
  }
  
  .page-badge {
    padding: 0.625rem 1.25rem;
    font-size: 0.9rem;
  }
  
  .settings-card,
  .form-section,
  .avatar-section,
  .info-card {
    padding: 1.25rem;
  }
  
  .card-header {
    padding: 1.25rem 1.25rem 0.5rem;
  }
  
  .card-title {
    font-size: 1.25rem;
    gap: 0.5rem;
  }
  
  .avatar-preview {
    width: 70px;
    height: 70px;
  }
  
  .avatar-title {
    font-size: 1.1rem;
  }
  
  .form-input,
  .form-textarea,
  .form-select {
    padding: 0.875rem 1rem;
  }
  
  .file-input-btn {
    padding: 0.75rem 1.25rem;
    font-size: 0.85rem;
  }
  
  .unsaved-indicator {
    bottom: 1rem;
    padding: 0.875rem 1.25rem;
    margin: 0 1rem;
    left: 0;
    right: 0;
    transform: translateY(120px);
    font-size: 0.85rem;
  }
  
  .unsaved-indicator.show {
    transform: translateY(0);
  }
  
  .info-card {
    padding: 1.5rem;
  }
  
  .info-card-title {
    font-size: 1.1rem;
  }
  
  .btn {
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    min-height: 44px;
  }
}

/* ===== MEJORAS DE ACCESIBILIDAD ===== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== ESTILOS PARA ESTADOS DE FOCO MEJORADOS ===== */
.tab-button:focus-visible,
.btn:focus-visible,
.form-input:focus-visible,
.form-textarea:focus-visible,
.file-input-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ===== SCROLLBAR PERSONALIZADO ===== */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--brand);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--brand-light);
}