/* Variables CSS */
:root {
  --primary-color: #2196F3;
  --secondary-color: #4CAF50;
  --danger-color: #f44336;
  --warning-color: #FF9800;
  --background: #f5f5f5;
  --card-background: #ffffff;
  --text-primary: #212121;
  --text-secondary: #757575;
  --border-color: #e0e0e0;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.15);
}

/* Reset y estilos base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
  padding: 20px;
  min-height: 100vh;
}

/* Header */
header {
  background: var(--primary-color);
  color: white;
  padding: 30px 20px;
  border-radius: 12px;
  margin-bottom: 30px;
  box-shadow: var(--shadow);
  text-align: center;
}

header h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  font-weight: 700;
}

.subtitle {
  font-size: 1.1rem;
  opacity: 0.9;
  margin-bottom: 15px;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.2);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.9rem;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  animation: blink 2s ease-in-out infinite;
}

.status-dot.online {
  background: var(--secondary-color);
}

.status-dot.offline {
  background: var(--warning-color);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
}

/* Cards */
.card {
  background: var(--card-background);
  border-radius: 12px;
  padding: 30px;
  margin-bottom: 30px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.3s ease;
}

.card:hover {
  box-shadow: var(--shadow-hover);
}

.card h2 {
  color: var(--primary-color);
  font-size: 1.8rem;
  margin-bottom: 15px;
  font-weight: 600;
}

.card h3 {
  color: var(--text-primary);
  font-size: 1.4rem;
  margin: 20px 0 10px;
}

/* Formularios */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text-primary);
}

.form-group input,
.form-select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary-color);
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background: #1976D2;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.btn-secondary {
  background: var(--warning-color);
  color: white;
}

.btn-secondary:hover {
  background: #F57C00;
}

.btn-danger {
  background: var(--danger-color);
  color: white;
}

.btn-danger:hover {
  background: #d32f2f;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.9rem;
}

/* Mensajes de estado */
.status-message {
  margin-top: 15px;
  padding: 12px 16px;
  border-radius: 8px;
  font-weight: 500;
}

.status-message.info {
  background: #E3F2FD;
  color: #1976D2;
}

.status-message.success {
  background: #E8F5E9;
  color: #388E3C;
}

.status-message.error {
  background: #FFEBEE;
  color: #C62828;
}

.help-text {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 15px;
}

/* Tabla de datos */
.data-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 15px;
}

.data-count {
  font-size: 1.1rem;
}

.table-container {
  overflow-x: auto;
  margin-top: 20px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.data-table th,
.data-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  background: #F5F5F5;
  font-weight: 600;
  color: var(--text-primary);
  position: sticky;
  top: 0;
}

.data-table tbody tr:hover {
  background: #F9F9F9;
}

.empty-message {
  text-align: center !important;
  color: var(--text-secondary);
  font-style: italic;
  padding: 30px !important;
}

/* Resultados de regresión */
.results-section {
  margin-top: 20px;
  padding: 20px;
  background: #F9F9F9;
  border-radius: 8px;
}

.results-section.hidden {
  display: none;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin: 20px 0;
}

.result-item {
  background: white;
  padding: 15px;
  border-radius: 8px;
  border-left: 4px solid var(--primary-color);
}

.result-label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.result-value {
  display: block;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--primary-color);
}

/* Gráficos */
.chart-container {
  margin-top: 25px;
  height: 500px;
  background: white;
  border-radius: 8px;
  padding: 15px;
}

#regressionChart {
  width: 100%;
  height: 100%;
}

/* Exportación */
.export-controls {
  display: flex;
  gap: 15px;
  align-items: center;
  flex-wrap: wrap;
}

.export-controls select {
  flex: 1;
  min-width: 200px;
}

/* Footer */
.footer {
  text-align: center;
  padding: 30px 20px;
  color: var(--text-secondary);
  margin-top: 40px;
}

.footer p {
  margin: 5px 0;
}

.app-version {
  font-size: 0.85rem;
}

.app-info {
  color: var(--text-secondary);
}

/* Utilidades */
.hidden {
  display: none !important;
}

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

.card {
  animation: fadeIn 0.5s ease-out;
}

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

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

/* Responsive */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  header h1 {
    font-size: 2rem;
  }

  .subtitle {
    font-size: 1rem;
  }

  .card {
    padding: 20px;
    margin-bottom: 20px;
  }

  .card h2 {
    font-size: 1.3rem;
  }

  .data-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .data-table {
    font-size: 0.85rem;
  }

  .data-table th,
  .data-table td {
    padding: 8px;
  }

  .results-grid {
    grid-template-columns: 1fr;
  }

  .chart-container {
    height: 400px;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }

  .export-controls {
    flex-direction: column;
    width: 100%;
  }

  .export-controls select {
    width: 100%;
  }
}

@media (max-width: 480px) {
  header h1 {
    font-size: 1.5rem;
  }

  .card {
    padding: 15px;
  }

  .chart-container {
    height: 300px;
  }
}

/* Print styles */
@media print {
  body {
    background: white;
  }

  .install-section,
  .capture-section,
  .export-section,
  .footer,
  .btn {
    display: none !important;
  }

  .card {
    box-shadow: none;
    border: 1px solid var(--border-color);
    page-break-inside: avoid;
  }
}

/* PWA específico - ocultar barra de direcciones en iOS */
@supports (-webkit-touch-callout: none) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
}
