/* ===== VARIABLES CSS ===== */
:root {
  --color-primary: #2563EB;
  --color-primary-hover: #1d4ed8;
  --color-primary-light: #3b82f6;
  --color-success: #10B981;
  --color-error: #ef4444;
  --color-warning: #f59e0b;
  --border-radius: 8px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --transition: all 0.3s ease;
}

/* ===== SISTEMA DE TEMAS DE COLOR ===== */
/* Tema Gris */
[data-theme="gray"] {
  --color-primary: #374151;
  --color-primary-hover: #1f2937;
  --color-primary-light: #4b5563;
}

/* Tema Café */
[data-theme="brown"] {
  --color-primary: #92400e;
  --color-primary-hover: #78350f;
  --color-primary-light: #a16207;
}

/* Aplicar colores dinámicos */
.text-primary,
.border-primary {
  color: var(--color-primary) !important;
  border-color: var(--color-primary) !important;
}

.bg-primary {
  background-color: var(--color-primary) !important;
}

.hover\:bg-blue-600:hover {
  background-color: var(--color-primary-hover) !important;
}

.from-primary {
  --tw-gradient-from: var(--color-primary) !important;
}

.to-blue-600 {
  --tw-gradient-to: var(--color-primary-light) !important;
}

.hover\:from-blue-600:hover {
  --tw-gradient-from: var(--color-primary-hover) !important;
}

.hover\:to-blue-700:hover {
  --tw-gradient-to: var(--color-primary-hover) !important;
}

/* ===== BASE STYLES ===== */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===== BOTONES RESPONSIVE OPTIMIZADOS ===== */

/* Botones del header más compactos */
header .flex.items-center button {
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
}

/* Botones de información personal más pequeños */
.personal-info-buttons {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}

/* Dropdown más compacto */
#colorThemeDropdown {
  animation: fadeIn 0.2s ease-out;
  font-size: 0.75rem;
}

/* Optimización para móviles */
@media (max-width: 640px) {
  /* Header buttons más compactos */
  header button {
    min-height: 32px !important;
    font-size: 0.75rem !important;
    padding: 0.375rem 0.5rem !important;
  }
  
  header button i {
    font-size: 0.75rem !important;
  }
  
  /* Título más pequeño */
  header h1 {
    font-size: 1.125rem !important;
    margin-left: 0.5rem !important;
  }
  
  /* Botones de información personal mínimos */
  #colorThemeBtn,
  button[onclick*="photoInput"],
  #removePhoto {
    min-height: 28px !important;
    font-size: 0.75rem !important;
    padding: 0.25rem 0.5rem !important;
    border-radius: 0.375rem !important;
  }
  
  /* Iconos de botones pequeños */
  #colorThemeBtn i,
  button[onclick*="photoInput"] i,
  #removePhoto i {
    font-size: 0.625rem !important;
  }
  
  /* Dropdown más pequeño */
  #colorThemeDropdown {
    min-width: 80px !important;
    font-size: 0.7rem !important;
  }
  
  #colorThemeDropdown button {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.7rem !important;
  }
  
  #colorThemeDropdown .w-2 {
    width: 0.45rem !important;
    height: 0.45rem !important;
  }
  
  /* Botones de agregar secciones */
  .bg-accent,
  button[id*="add"] {
    font-size: 0.75rem !important;
    padding: 0.375rem 0.75rem !important;
    min-height: 32px !important;
  }
  
  /* Espaciado de header reducido */
  header .flex.items-center.gap-1\.5 {
    gap: 0.25rem !important;
  }
  
  /* Ocultar texto en botones muy pequeños */
  #colorThemeBtn span:not(.hidden),
  button[onclick*="photoInput"] span:not(.hidden),
  #removePhoto span:not(.hidden) {
    display: none;
  }
}

/* Optimización para tablets */
@media (min-width: 641px) and (max-width: 1024px) {
  header button {
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
    min-height: 34px;
  }
  
  #colorThemeBtn,
  button[onclick*="photoInput"],
  #removePhoto {
    font-size: 0.875rem;
    padding: 0.25rem 0.75rem;
  }
}

/* Para pantallas muy pequeñas (< 375px) */
@media (max-width: 374px) {
  header h1 {
    display: none;
  }
  
  header .bg-gradient-to-r {
    margin-right: 0.5rem;
  }
  
  /* Botones del header aún más pequeños */
  header button {
    padding: 0.25rem 0.375rem !important;
    min-height: 28px !important;
  }
  
  /* Solo mostrar iconos en botones principales */
  header button span:not(#currentLang) {
    display: none !important;
  }
  
  header button i {
    margin-right: 0 !important;
  }
  
  /* Mantener texto en botón de idioma */
  #languageToggle span {
    display: inline !important;
  }
}

/* ===== COMPONENTES CONSOLIDADOS ===== */
.skill-tag {
  display: inline-block;
  background: linear-gradient(135deg, var(--color-primary), var(--color-success));
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  margin: 2px;
  transition: var(--transition);
}

.skill-tag:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

.skill-tag .remove-skill {
  margin-left: 8px;
  cursor: pointer;
  font-weight: bold;
  opacity: 0.8;
}

.skill-tag .remove-skill:hover {
  opacity: 1;
}

/* Formulario items consolidados */
.experience-item,
.education-item,
.language-item,
.custom-section-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--border-radius);
  padding: 16px;
  position: relative;
  transition: var(--transition);
}

.experience-item:hover,
.education-item:hover,
.language-item:hover,
.custom-section-item:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.remove-item {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--color-error);
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.remove-item:hover {
  background: #dc2626;
  transform: scale(1.1);
}

/* ===== DROPDOWN STYLES ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== CV PREVIEW OPTIMIZADO ===== */
#cvPreview {
  font-family: 'Inter', system-ui, sans-serif;
  line-height: 1.5;
  background: white;
  color: #1f2937;
}

.preview-experience-item,
.preview-education-item {
  margin-bottom: 16px;
  padding-bottom: 16px;
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: break-word;
  min-width: 0;
}

.preview-experience-item:not(:last-child),
.preview-education-item:not(:last-child) {
  border-bottom: 1px solid #e5e7eb;
}

.preview-experience-item h4,
.preview-education-item h4 {
  line-height: 1.2;
  min-width: 0;
  flex: 1;
  margin-right: 8px;
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: break-word;
}

.preview-skill-item {
  display: inline-block;
  background: #f3f4f6;
  color: #374151;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  margin: 2px 4px 2px 0;
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

.preview-language-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding: 4px 0;
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: break-word;
  min-width: 0;
}

/* ===== TEXTO OVERFLOW CONSOLIDADO ===== */
.bg-gray-50,
.col-span-2,
#previewContactItems .flex,
#previewName,
#previewTitle,
#previewSummary {
  min-width: 0;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
}

#previewContactItems .flex i {
  flex-shrink: 0;
}

#previewContactItems .flex > *:not(i) {
  max-width: 100%;
  overflow: hidden;
  min-width: 0;
}

/* ===== FOTO PERFIL OPTIMIZADA ===== */
#previewPhotoSection {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin-bottom: 24px;
}

#previewPhotoSection .w-32 {
  width: 8rem !important;
  height: 8rem !important;
  margin: 0 auto;
  display: block;
}

#removePhoto.hidden {
  display: none !important;
}

#removePhoto:not(.hidden) {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

/* ===== ANIMACIONES CONSOLIDADAS ===== */
.form-section {
  animation: slideInUp 0.3s ease-out;
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.export-loading {
  position: relative;
  color: transparent;
}

.export-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2px solid transparent;
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ===== BOTONES HOVER STATES OPTIMIZADOS ===== */
@media (hover: hover) {
  button:hover {
    transform: translateY(-1px);
  }
  
  header button:hover {
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  }
}

/* Prevent button text wrapping */
button {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ===== CORRECCIÓN CV PREVIEW MÓVILES - SOLUCIÓN EXPERTA ===== */
/* Mantener layout del CV SIEMPRE en 2 columnas */
#cvPreview .grid-cols-3 {
  grid-template-columns: 1fr 2fr !important;
  gap: 2rem !important;
}

#cvPreview .col-span-2 {
  grid-column: span 1 !important;
}

/* ===== RESPONSIVE CONSOLIDADO (EXCLUYE CV PREVIEW) ===== */
@media (max-width: 768px) {
  /* Solo aplicar a grid principal, NO al CV preview */
  .grid-cols-3:not(#cvPreview .grid-cols-3) {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }
  
  .col-span-2:not(#cvPreview .col-span-2) {
    grid-column: span 1;
  }
  
  /* Ajustes específicos del CV en móviles */
  #cvPreview {
    padding: 1.5rem !important;
    min-height: auto;
  }
  
  #cvPreview .grid-cols-3 {
    grid-template-columns: 1fr 2fr !important;
    gap: 1.5rem !important;
  }
  
  #cvPreview .col-span-2 {
    grid-column: span 1 !important;
  }
  
  /* Columna gris más estrecha en móviles */
  #cvPreview .bg-gray-50 {
    padding: 1rem !important;
  }
  
  /* Foto más pequeña en móviles */
  #previewPhotoSection .w-32 {
    width: 5rem !important;
    height: 5rem !important;
  }
  
  #previewPhotoPlaceholder i {
    font-size: 1.5rem !important;
  }
}

@media (max-width: 1024px) {
  .lg\:col-span-3,
  .lg\:col-span-2 {
    grid-column: span 1;
  }
}

/* ===== FOCUS STATES ===== */
input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
