/* =================================
   GRÁFICOS APP - ESTILOS CSS
   ================================= */

/* Variables CSS personalizadas */
:root {
  --graficos-primary: #3b82f6;
  --graficos-primary-hover: #2563eb;
  --graficos-success: #10b981;
  --graficos-warning: #f59e0b;
  --graficos-error: #ef4444;
  --graficos-border-radius: 12px;
  --graficos-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --graficos-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --graficos-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Contenedor principal */
.graficos-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
  min-height: calc(100vh - 120px);
}

/* Sistema de vistas */
.view {
  display: none;
  opacity: 0;
  transform: translateY(10px);
  transition: var(--graficos-transition);
}

.view.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* =================================
    VISTA DE SELECCIÓN DE FUENTE
    ================================= */

.data-source-section {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 70vh;
  padding: 2rem 0;
}

.source-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 2rem;
  max-width: 800px;
  width: 100%;
}

.source-card {
  background: var(--card-background);
  border: 2px solid var(--border-color);
  border-radius: var(--graficos-border-radius);
  box-shadow: var(--graficos-shadow-lg);
  padding: 2.5rem;
  text-align: center;
  transition: var(--graficos-transition);
  cursor: pointer;
}

.source-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  border-color: var(--graficos-primary);
}

.source-icon {
  margin: 0 auto 1.5rem;
  color: var(--graficos-primary);
}

.source-card h3 {
  color: var(--text-primary);
  margin-bottom: 1rem;
  font-size: 1.5rem;
  font-weight: 600;
}

.source-card p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  font-size: 1rem;
  line-height: 1.5;
}

.source-button {
  font-size: 1rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--graficos-border-radius);
  gap: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--graficos-transition);
  width: 100%;
}

.source-button:hover {
  transform: translateY(-2px);
  box-shadow: var(--graficos-shadow-lg);
}

/* =================================
    VISTA DE CARGA DE ARCHIVOS
    ================================= */

.upload-section {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 70vh;
  padding: 2rem 0;
}

/* =================================
    VISTA DE DATOS DE NOTAS
    ================================= */

.notas-section {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 70vh;
  padding: 2rem 0;
}

.notas-card {
  background: var(--card-background);
  border: 2px solid var(--border-color);
  border-radius: var(--graficos-border-radius);
  box-shadow: var(--graficos-shadow-lg);
  padding: 3rem;
  text-align: center;
  max-width: 500px;
  width: 100%;
  transition: var(--graficos-transition);
}

.notas-header {
  margin-bottom: 2rem;
}

.notas-icon {
  margin: 0 auto 1.5rem;
  color: var(--graficos-primary);
}

.notas-card h2 {
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  font-size: 1.75rem;
  font-weight: 600;
}

.notas-card p {
  color: var(--text-secondary);
  margin-bottom: 0;
  font-size: 1.1rem;
}

.notas-selectors {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.selector-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-align: left;
}

.selector-group label {
  color: var(--text-primary);
  font-weight: 500;
  font-size: 0.875rem;
}

.notas-info {
  background: var(--background-secondary);
  border-radius: var(--graficos-border-radius);
  border: 1px solid var(--border-color);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.info-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.info-label {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

.info-value {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 1.25rem;
}

.upload-card {
  background: var(--card-background);
  border: 2px solid var(--border-color);
  border-radius: var(--graficos-border-radius);
  box-shadow: var(--graficos-shadow-lg);
  padding: 3rem;
  text-align: center;
  max-width: 500px;
  width: 100%;
  transition: var(--graficos-transition);
}

.upload-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.upload-icon {
  margin: 0 auto 1.5rem;
  color: var(--graficos-primary);
}

.upload-card h2 {
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  font-size: 1.75rem;
  font-weight: 600;
}

.upload-card p {
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-size: 1.1rem;
}

.supported-formats {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.format-tag {
  background: var(--graficos-primary);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
}

.upload-button {
  font-size: 1.1rem;
  padding: 0.875rem 2rem;
  border-radius: var(--graficos-border-radius);
  gap: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--graficos-transition);
}

.upload-button:hover {
  transform: translateY(-2px);
  box-shadow: var(--graficos-shadow-lg);
}

/* Información del archivo */
.file-info {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--background-secondary);
  border-radius: var(--graficos-border-radius);
  border: 1px solid var(--border-color);
}

.file-details {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.file-details svg {
  color: var(--graficos-success);
  flex-shrink: 0;
}

.file-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 1rem;
}

.file-size {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* =================================
   VISTA DE GRÁFICOS
   ================================= */

.charts-header {
  background: #ffffffc9;
  border: 1px solid var(--border-color);
  border-radius: var(--graficos-border-radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--graficos-shadow);
}

.header-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--background-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  transition: var(--graficos-transition);
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-back:hover {
  background: var(--button-hover);
  transform: translateY(-1px);
}

.data-summary {
  display: flex;
  gap: 1.5rem;
}

.summary-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--background-secondary);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.summary-label {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.summary-value {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 1rem;
}

/* Filtros */
.filters-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  align-items: end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.filter-group label {
  color: var(--text-primary);
  font-weight: 500;
  font-size: 0.875rem;
}

.form-input {
  background: #fcffff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.625rem 0.75rem;
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: var(--graficos-transition);
}

.form-input:focus {
  outline: none;
  border-color: var(--graficos-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Contenedor del gráfico */
.chart-container {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--graficos-border-radius);
  padding: 2rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--graficos-shadow);
  min-height: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#main-chart {
  max-width: 100%;
  max-height: 500px;
}

/* Panel de estadísticas */
.statistics-panel {
  background: #1d1c47;
  border: 1px solid var(--border-color);
  border-radius: var(--graficos-border-radius);
  padding: 1.5rem;
  box-shadow: var(--graficos-shadow);
}

.statistics-panel h3 {
  color: #ffffffb2;
  margin-bottom: 1rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--background-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: #ffd900;
  margin-bottom: 0.25rem;
}

.stat-label {
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 500;
}

/* =================================
   DRAG & DROP
   ================================= */

.upload-card.drag-over {
  border-color: var(--graficos-primary);
  background: rgba(59, 130, 246, 0.05);
  transform: scale(1.02);
}

.upload-card.drag-over .upload-icon {
  transform: scale(1.1);
}

/* =================================
   RESPONSIVE DESIGN
   ================================= */

/* Tablet */
@media (max-width: 1024px) {
  .graficos-container {
    padding: 0.75rem;
  }
  
  .upload-card {
    padding: 2rem;
    margin: 0 1rem;
  }
  
  .charts-header {
    padding: 1rem;
  }
  
  .header-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }
  
  .data-summary {
    justify-content: center;
  }
  
  .filters-section {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  
  .chart-container {
    padding: 1rem;
    min-height: 400px;
  }
}

/* Móvil */
@media (max-width: 768px) {
  .graficos-container {
    padding: 0.5rem;
  }
  
  /* Vista de selección de fuente */
  .source-options {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .source-card {
    padding: 2rem;
    margin: 0 0.5rem;
  }
  
  .source-card h3 {
    font-size: 1.25rem;
  }
  
  /* Vista de upload */
  .upload-card {
    padding: 1.5rem;
    margin: 0 0.5rem;
  }
  
  .upload-card h2 {
    font-size: 1.5rem;
  }
  
  .upload-card p {
    font-size: 1rem;
  }
  
  .supported-formats {
    flex-direction: column;
    align-items: center;
  }
  
  /* Vista de Notas */
  .notas-card {
    padding: 2rem;
    margin: 0 0.5rem;
  }
  
  .notas-card h2 {
    font-size: 1.5rem;
  }
  
  .info-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  /* Vista de gráficos */
  .filters-section {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  .data-summary {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .file-details {
    flex-direction: column;
    text-align: center;
    gap: 0.75rem;
  }
  
  .chart-container {
    padding: 0.75rem;
    min-height: 350px;
  }
  
  .statistics-panel {
    padding: 1rem;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
}

/* Móvil pequeño */
@media (max-width: 480px) {
  .upload-card {
    padding: 1rem;
    margin: 0;
  }
  
  .upload-card h2 {
    font-size: 1.25rem;
  }
  
  .chart-container {
    min-height: 300px;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* =================================
   LOADING Y ESTADOS
   ================================= */

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(59, 130, 246, 0.3);
  border-top: 3px solid var(--graficos-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

.loading-overlay p {
  color: white;
  font-size: 1.1rem;
  font-weight: 500;
}

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

/* =================================
   NOTIFICACIONES
   ================================= */

.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 1rem 1.5rem;
  border-radius: var(--graficos-border-radius);
  box-shadow: var(--graficos-shadow-lg);
  z-index: 1000;
  max-width: 400px;
  animation: slideInRight 0.3s ease;
}

.notification.success {
  background: var(--graficos-success);
  color: white;
}

.notification.error {
  background: var(--graficos-error);
  color: white;
}

.notification.warning {
  background: var(--graficos-warning);
  color: white;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* =================================
   ACCESIBILIDAD
   ================================= */

/* Focus visible para navegación por teclado */
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--graficos-primary);
  outline-offset: 2px;
}

/* Reducir animaciones si el usuario lo prefiere */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Alto contraste */
@media (prefers-contrast: high) {
  .upload-card {
    border-width: 3px;
  }
  
  .format-tag {
    border: 2px solid white;
  }
}

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

.button-43 {
  background-image: linear-gradient(-180deg, #37AEE2 0%, #1E96C8 100%);
  border-radius: .5rem;
  box-sizing: border-box;
  color: #FFFFFF;
  display: flex;
  font-size: 16px;
  justify-content: center;
  padding: 1rem 1.75rem;
  text-decoration: none;
  width: 100%;
  border: 0;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  transition: all 0.3s ease;
}

.button-43:hover {
  background-image: linear-gradient(-180deg, #1D95C9 0%, #17759C 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(30, 150, 200, 0.3);
}

.button-43:active {
  transform: translateY(0);
}

@media (min-width: 768px) {
  .button-43 {
    padding: 1rem 2rem;
  }
}

/* =================================
    UTILIDADES
    ================================= */

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.hidden { display: none !important; }
.visible { display: block !important; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }

.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }

/* ================================
   AUTH REQUIRED SECTION
   ================================ */

.auth-required {
  margin-top: 2rem;
  padding: 2rem;
  text-align: center;
  background: var(--card-bg);
  border-radius: 12px;
  border: 2px dashed var(--border-color);
}

.auth-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.auth-message svg {
  color: var(--accent-color);
  opacity: 0.7;
}

.auth-message h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: 1.25rem;
  font-weight: 600;
}

.auth-message p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
  max-width: 400px;
}

.auth-message .btn-primary {
  margin-top: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Upload card auth locked state */
.upload-card.auth-locked {
  opacity: 0.8;
  pointer-events: auto; /* Permitir interacción con el botón de login */
}

.upload-card.auth-locked .upload-button {
  background: var(--bg-secondary);
  color: var(--text-tertiary);
  cursor: not-allowed;
}

.upload-card.auth-locked .upload-button:hover {
  background: var(--bg-secondary);
  transform: none;
}

/* Asegurar que el botón de login sea clickeable */
.auth-required {
  pointer-events: auto;
  z-index: 10;
}

.auth-required * {
  pointer-events: auto;
}

/* Print styles */
@media print {
  .upload-section,
  .charts-header,
  .statistics-panel {
    break-inside: avoid;
  }
  
  .chart-container {
    min-height: auto;
  }
}
