/* ==========================================================================
   SISTEMA DE DISEÑO Y VARIABLES (Estética Dark/Glassmorphic para la UI)
   ========================================================================== */
:root {
  --font-ui: 'Inter', sans-serif;
  
  /* Colores de la Interfaz (Modo Oscuro Elegante) */
  --ui-bg: #090d16;
  --ui-bg-card: rgba(20, 26, 44, 0.6);
  --ui-bg-card-hover: rgba(28, 36, 61, 0.8);
  --ui-border: rgba(255, 255, 255, 0.08);
  --ui-border-focus: #6366f1;
  --ui-text-main: #f8fafc;
  --ui-text-muted: #94a3b8;
  
  /* Gradientes de Acento */
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --accent-hover-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --danger-gradient: linear-gradient(135deg, #ef4444 0%, #f43f5e 100%);
  
  /* Colores de las Hojas de Currículum (Destinados a Impresión) */
  --cv-text-dark: #1e293b;
  --cv-text-muted: #64748b;
  --cv-accent-blue: #1e3a8a;
  --cv-accent-teal: #0d9488;
  --cv-border: #e2e8f0;
}

/* ==========================================================================
   ESTILOS GENERALES Y MAQUETACIÓN
   ========================================================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-ui);
  background-color: var(--ui-bg);
  color: var(--ui-text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Scrollbar Personalizado para la UI */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--ui-border-focus);
}

/* ==========================================================================
   CABECERA DE LA APLICACIÓN
   ========================================================================== */
.app-header {
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--ui-border);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 2rem;
  height: 2rem;
  color: #6366f1;
  filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.5));
}

.header-logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header-logo h1 span {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ==========================================================================
   CONTROLES DE SELECCIÓN Y BOTONES
   ========================================================================== */
.template-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ui-text-muted);
  font-size: 0.9rem;
}

.styled-select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--ui-border);
  color: var(--ui-text-main);
  padding: 0.5rem 1.5rem 0.5rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  outline: none;
  transition: all 0.2s ease;
}

.styled-select:focus {
  border-color: var(--ui-border-focus);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
  font-family: inherit;
}

.btn-icon {
  width: 1.1rem;
  height: 1.1rem;
  stroke-width: 2;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  background: var(--accent-hover-gradient);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--ui-border);
  color: var(--ui-text-main);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--ui-text-muted);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.btn-danger:hover {
  background: var(--danger-gradient);
  color: #fff;
  border-color: transparent;
}

.btn-add {
  background: rgba(99, 102, 241, 0.15);
  color: #c7d2fe;
  border: 1px dashed rgba(99, 102, 241, 0.4);
  font-size: 0.85rem;
  padding: 0.4rem 0.8rem;
}

.btn-add:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: #8b5cf6;
  color: #fff;
}

/* ==========================================================================
   DISTRIBUCIÓN PRINCIPAL DE LA SPA
   ========================================================================== */
.app-container {
  display: flex;
  flex: 1;
  height: calc(100vh - 65px);
  overflow: hidden;
}

/* ==========================================================================
   PANEL IZQUIERDO: FORMULARIO Y CONTROL
   ========================================================================== */
.control-panel {
  width: 42%;
  min-width: 480px;
  background: rgba(12, 17, 30, 0.4);
  border-right: 1px solid var(--ui-border);
  display: flex;
  flex-direction: column;
}

/* Navegación por pestañas */
.form-tabs {
  display: flex;
  border-bottom: 1px solid var(--ui-border);
  overflow-x: auto;
  background: rgba(9, 13, 22, 0.5);
}

.tab-btn {
  flex: 1;
  min-width: 90px;
  padding: 0.9rem 0.5rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--ui-text-muted);
  font-family: inherit;
  font-weight: 500;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--ui-text-main);
  background: rgba(255, 255, 255, 0.02);
}

.tab-btn.active {
  color: #6366f1;
  border-bottom-color: #6366f1;
  background: rgba(99, 102, 241, 0.05);
}

.tab-icon {
  width: 1.25rem;
  height: 1.25rem;
  opacity: 0.7;
}

.tab-btn.active .tab-icon {
  opacity: 1;
}

/* Contenido de pestañas */
.form-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

.pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ui-text-main);
}

.tab-desc {
  color: var(--ui-text-muted);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

/* Form Grid */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.col-span-2 {
  grid-column: span 2;
}

/* Grupos de entrada */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ui-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group textarea,
.form-group select {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--ui-border);
  color: var(--ui-text-main);
  padding: 0.65rem 0.85rem;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: all 0.2s ease;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: rgba(255, 255, 255, 0.2);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--ui-border-focus);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.form-group textarea {
  resize: vertical;
}

/* ==========================================================================
   ELEMENTOS DE LISTA DINÁMICA (Accordion / Cards)
   ========================================================================== */
.dynamic-list {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card-item {
  background: var(--ui-bg-card);
  border: 1px solid var(--ui-border);
  border-radius: 10px;
  padding: 1.25rem;
  position: relative;
  transition: all 0.2s ease;
}

.card-item:hover {
  background: var(--ui-bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

/* Encabezado del Card de Item */
.card-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.06);
}

.card-item-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: #c7d2fe;
}

.card-controls {
  display: flex;
  gap: 0.25rem;
}

/* Botones de Control del Card (Subir, Bajar, Eliminar) */
.btn-control {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--ui-border);
  color: var(--ui-text-muted);
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-control:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--ui-text-main);
}

.btn-control.delete:hover {
  background: #ef4444;
  color: #fff;
  border-color: transparent;
}

.btn-control svg {
  width: 0.9rem;
  height: 0.9rem;
  stroke-width: 2.5;
}

/* Checkbox actual */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.checkbox-group input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  cursor: pointer;
}

.checkbox-group label {
  font-size: 0.8rem;
  text-transform: none;
  cursor: pointer;
}

/* ==========================================================================
   PANEL DERECHO: PREVISUALIZACIÓN DE HOJA A4
   ========================================================================== */
.preview-panel {
  flex: 1;
  background: #0f172a;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.preview-toolbar {
  background: rgba(15, 23, 42, 0.8);
  border-bottom: 1px solid var(--ui-border);
  padding: 0.75rem 1.5rem;
  font-size: 0.8rem;
  color: var(--ui-text-muted);
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.paper-container {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: radial-gradient(circle at top, #1e293b 0%, #0f172a 100%);
}

/* Simulación de Hoja A4 con Proporciones Exactas */
.cv-preview-sheet {
  width: 210mm;
  min-height: 297mm;
  background: #ffffff;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  color: var(--cv-text-dark);
  box-sizing: border-box;
  padding: 20mm;
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: left;
}

/* ==========================================================================
   ESTILOS COMPARTIDOS DEL DOCUMENTO CV (Preview)
   ========================================================================== */
.cv-preview-sheet h1,
.cv-preview-sheet h2,
.cv-preview-sheet h3 {
  color: var(--cv-text-dark);
  margin: 0;
  padding: 0;
}

.cv-preview-sheet p,
.cv-preview-sheet li {
  font-size: 9.5pt;
  line-height: 1.4;
  color: var(--cv-text-dark);
}

.cv-preview-sheet ul {
  padding-left: 1.2rem;
  margin-top: 0.25rem;
}

.cv-preview-sheet li {
  margin-bottom: 0.25rem;
}

.cv-section-title {
  font-size: 13pt;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1.5px solid var(--cv-border);
  padding-bottom: 3px;
  margin-bottom: 0.75rem;
  margin-top: 1.25rem;
}

/* Contenedores de Listas de Datos en el CV */
.cv-item {
  margin-bottom: 0.85rem;
}

.cv-item-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.15rem;
}

.cv-item-title {
  font-weight: 700;
  font-size: 10pt;
}

.cv-item-subtitle {
  font-style: italic;
  font-size: 9.5pt;
  color: var(--cv-text-muted);
}

.cv-item-date {
  font-size: 9pt;
  font-weight: 500;
  color: var(--cv-text-muted);
}

.cv-item-desc {
  margin-top: 0.25rem;
  white-space: pre-line; /* Mantiene saltos de línea */
}

/* Chips de habilidades / Tags */
.cv-skills-category {
  margin-bottom: 0.5rem;
  font-size: 9.5pt;
}

.cv-skills-category strong {
  font-weight: 700;
}

.cv-skills-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

.cv-tag {
  background: #f1f5f9;
  color: #334155;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 8.5pt;
  font-weight: 500;
}

/* Idiomas */
.cv-languages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem;
}

/* ==========================================================================
   PLANTILLA 1: MINIMALISTA PROFESIONAL
   ========================================================================== */
.template-minimalist {
  font-family: 'Inter', sans-serif;
}

.template-minimalist .cv-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.template-minimalist .cv-name {
  font-size: 24pt;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.template-minimalist .cv-title {
  font-size: 12pt;
  color: var(--cv-accent-blue);
  font-weight: 600;
  margin-top: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.template-minimalist .cv-contact {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-top: 0.75rem;
  font-size: 8.5pt;
  color: var(--cv-text-muted);
  border-bottom: 1px solid var(--cv-border);
  padding-bottom: 0.75rem;
}

.template-minimalist .cv-contact span {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.template-minimalist .cv-section-title {
  color: var(--cv-accent-blue);
  border-bottom-color: var(--cv-accent-blue);
}

/* ==========================================================================
   PLANTILLA 2: MODERNO CON BARRA LATERAL (Asimétrico)
   ========================================================================== */
.template-modern {
  font-family: 'Inter', sans-serif;
  padding: 0 !important; /* Elimina padding general para barra lateral */
  display: flex;
  min-height: 297mm;
}

/* Barra lateral izquierda */
.template-modern .cv-sidebar {
  width: 32%;
  background: #1e293b;
  color: #f8fafc;
  padding: 20mm 6mm 20mm 8mm;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.template-modern .cv-sidebar p,
.template-modern .cv-sidebar li,
.template-modern .cv-sidebar span {
  color: #cbd5e1;
  font-size: 9pt;
}

.template-modern .cv-sidebar h2.cv-section-title {
  color: #f1f5f9;
  border-bottom: 1.5px solid rgba(255, 255, 255, 0.2);
  font-size: 11pt;
}

.template-modern .cv-sidebar-contact {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.template-modern .cv-sidebar-contact span {
  word-break: break-all;
}

.template-modern .cv-sidebar .cv-tag {
  background: rgba(255, 255, 255, 0.1);
  color: #f1f5f9;
}

/* Columna de contenido principal derecha */
.template-modern .cv-main {
  width: 68%;
  padding: 20mm 8mm 20mm 8mm;
  display: flex;
  flex-direction: column;
}

.template-modern .cv-header {
  margin-bottom: 1rem;
}

.template-modern .cv-name {
  font-size: 22pt;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.1;
}

.template-modern .cv-title {
  font-size: 11pt;
  color: var(--cv-accent-teal);
  font-weight: 600;
  margin-top: 0.25rem;
  text-transform: uppercase;
}

.template-modern .cv-section-title {
  color: var(--cv-accent-teal);
  border-bottom-color: var(--cv-accent-teal);
}

/* ==========================================================================
   PLANTILLA 3: EJECUTIVO CLÁSICO (Serif Elegante)
   ========================================================================== */
.template-executive {
  font-family: 'Merriweather', serif;
  padding: 22mm 22mm;
}

.template-executive .cv-header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.template-executive .cv-name {
  font-family: 'Playfair Display', serif;
  font-size: 26pt;
  font-weight: 700;
  color: #0f172a;
}

.template-executive .cv-title {
  font-family: 'Merriweather', serif;
  font-size: 11pt;
  font-style: italic;
  color: #475569;
  margin-top: 0.35rem;
  font-weight: 400;
  letter-spacing: 0.5px;
}

.template-executive .cv-contact {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 0.85rem;
  font-size: 8.5pt;
  border-top: 1px solid #94a3b8;
  border-bottom: 1px solid #94a3b8;
  padding: 0.5rem 0;
  font-family: 'Inter', sans-serif;
  color: #475569;
}

.template-executive .cv-section-title {
  font-family: 'Playfair Display', serif;
  color: #0f172a;
  border-bottom: 1px solid #334155;
  text-transform: uppercase;
  font-size: 12pt;
  letter-spacing: 1px;
  font-weight: 700;
  margin-top: 1.5rem;
}

.template-executive .cv-item-title {
  font-family: 'Merriweather', serif;
  font-weight: 700;
}

.template-executive p,
.template-executive li {
  font-family: 'Merriweather', serif;
  font-weight: 300;
  font-size: 9pt;
  line-height: 1.5;
}

.template-executive .cv-tag {
  font-family: 'Inter', sans-serif;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #334155;
}

/* ==========================================================================
   ANIMACIONES Y RESPONSIVIDAD
   ========================================================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Adaptación para pantallas pequeñas */
@media (max-width: 1200px) {
  .app-container {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }
  
  .control-panel {
    width: 100%;
    min-width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--ui-border);
  }
  
  .preview-panel {
    width: 100%;
    height: auto;
    padding: 1rem 0;
  }
  
  .paper-container {
    padding: 1rem;
    overflow-x: auto;
    justify-content: flex-start;
  }
  
  .cv-preview-sheet {
    transform: scale(0.9);
    transform-origin: top left;
  }
}

@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
  }
  
  .header-actions {
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
  }
  
  .cv-preview-sheet {
    transform: scale(0.7);
  }
}
