/* ====== BASE MODERNA ====== */
:root {
  --bg: #0a0a14;
  --bg-gradient: linear-gradient(135deg, #0a0a14 0%, #1a1a2e 100%);
  --text: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.7);
  --text-light: rgba(255, 255, 255, 0.9);
  --card: rgba(18, 18, 30, 0.95);
  --card-border: rgba(255, 255, 255, 0.1);
  --accent: #00d4ff;
  --accent-dark: #0099cc;
  --accent-gradient: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
  --success: #00ff9d;
  --warning: #ffcc00;
  --error: #ff4757;
  --go-color: #00ff9d;
  --nogo-color: #ff4757;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
  --border-radius: 16px;
  --border-radius-sm: 12px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-gradient);
  color: var(--text);
  overflow-x: hidden;
}

/* ====== ESTADO DE CONEXIÓN ====== */
.connection-status {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  gap: 12px;
  align-items: center;
}

.connection-indicator,
.sync-indicator {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  transition: var(--transition);
}

.connection-indicator.online {
  color: var(--success);
  border-color: rgba(0, 255, 157, 0.3);
}

.connection-indicator.offline {
  color: var(--error);
  border-color: rgba(255, 71, 87, 0.3);
}

.sync-indicator {
  color: var(--accent);
  border-color: rgba(0, 212, 255, 0.3);
}

.sync-indicator.syncing i {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ====== NOTIFICACIONES ====== */
.notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: rgba(0, 212, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: var(--border-radius-sm);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 1001;
  box-shadow: var(--shadow);
  transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.notification.show {
  transform: translateX(-50%) translateY(0);
}

.notification i {
  font-size: 20px;
}

.notification.success {
  background: rgba(0, 255, 157, 0.95);
}

.notification.error {
  background: rgba(255, 71, 87, 0.95);
}

.notification.warning {
  background: rgba(255, 204, 0, 0.95);
}

/* ====== UI WRAP ====== */
.ui-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg-gradient);
}

/* ====== TARJETAS ELEGANTES ====== */
.card-elegant {
  width: min(800px, 95vw);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius);
  padding: 32px;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.card-elegant::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent-gradient);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.card-icon {
  width: 60px;
  height: 60px;
  background: rgba(0, 212, 255, 0.1);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--accent);
  border: 2px solid rgba(0, 212, 255, 0.2);
}

.card-icon.success {
  background: rgba(0, 255, 157, 0.1);
  color: var(--success);
  border-color: rgba(0, 255, 157, 0.2);
}

.card-elegant h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 0;
  background: linear-gradient(135deg, #ffffff 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.muted {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 24px;
}

/* ====== FORMULARIO EN GRID ====== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.input-group {
  margin-bottom: 0;
}

.label {
  display: block;
  margin-bottom: 8px;
}

.label span {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon i {
  position: absolute;
  left: 16px;
  color: var(--accent);
  font-size: 18px;
  z-index: 1;
}

.input-with-icon input {
  width: 100%;
  padding: 16px 16px 16px 48px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius-sm);
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  transition: var(--transition);
}

.input-with-icon input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(0, 212, 255, 0.05);
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

.input-hint {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  font-style: italic;
}

/* ====== BOTONES MODERNOS ====== */
.btn-modern {
  padding: 16px 28px;
  border-radius: var(--border-radius-sm);
  border: none;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-modern.primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 4px 15px rgba(0, 212, 255, 0.3);
}

.btn-modern.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 212, 255, 0.4);
}

.btn-modern.primary:active {
  transform: translateY(0);
}

.btn-modern.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.btn-modern.secondary:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
}

.ui-actions {
  display: flex;
  gap: 16px;
  margin-top: 32px;
}

/* ====== INDICADOR DE PASOS ====== */
.step-indicator {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.step {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-muted);
  transition: var(--transition);
}

.step.active {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 4px 12px rgba(0, 212, 255, 0.4);
}

/* ====== INSTRUCCIONES ====== */
.instructions-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin: 24px 0;
}

.instruction-step {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--border-radius-sm);
  border-left: 4px solid transparent;
  transition: var(--transition);
}

.instruction-step:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateX(4px);
}

.instruction-icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  background: rgba(0, 212, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--accent);
  flex-shrink: 0;
}

.instruction-icon.go {
  background: rgba(0, 255, 157, 0.1);
  color: var(--go-color);
}

.instruction-icon.nogo {
  background: rgba(255, 71, 87, 0.1);
  color: var(--nogo-color);
}

.instruction-content h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-light);
}

.instruction-content p {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.highlight {
  color: var(--accent);
  font-weight: 700;
  font-size: 20px;
}

.keyboard-key {
  display: inline-block;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  font-family: monospace;
  font-weight: 700;
  color: var(--accent);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ====== CONSEJO DE RENDIMIENTO ====== */
.performance-tip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: rgba(0, 212, 255, 0.1);
  border-radius: var(--border-radius-sm);
  border-left: 4px solid var(--accent);
  margin: 24px 0;
}

.performance-tip i {
  font-size: 20px;
  color: var(--accent);
  flex-shrink: 0;
}

.performance-tip p {
  color: var(--text-light);
  font-size: 14px;
  line-height: 1.5;
}

/* ====== RESUMEN DE RESULTADOS ====== */
.results-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin: 24px 0;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--border-radius-sm);
  transition: var(--transition);
}

.result-item:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}

.result-icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  background: rgba(0, 212, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--accent);
  flex-shrink: 0;
}

.result-info {
  display: flex;
  flex-direction: column;
}

.result-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.result-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-light);
  background: linear-gradient(135deg, #ffffff 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ====== ESTADO DE GUARDADO ====== */
.save-status-container {
  margin: 32px 0;
}

.save-status {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px;
  background: rgba(0, 212, 255, 0.1);
  border-radius: var(--border-radius-sm);
  border: 2px solid rgba(0, 212, 255, 0.2);
}

.save-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(0, 212, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--accent);
  flex-shrink: 0;
}

.save-content {
  flex: 1;
}

.save-content h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-light);
}

.save-content p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 12px;
}

.progress-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-gradient);
  border-radius: 3px;
  animation: progress-load 2s ease-in-out infinite;
}

@keyframes progress-load {
  0% { width: 0%; }
  50% { width: 70%; }
  100% { width: 100%; }
}

/* ====== ERROR UI ====== */
.ui-error {
  width: min(800px, 95vw);
  margin: 0 auto 20px;
  padding: 20px;
  border-radius: var(--border-radius-sm);
  background: rgba(255, 71, 87, 0.1);
  border: 2px solid rgba(255, 71, 87, 0.3);
  color: #ffdede;
  font-size: 14px;
  line-height: 1.5;
}

.ui-error::before {
  content: '⚠️ ';
  margin-right: 8px;
}

.hidden {
  display: none !important;
}

/* ====== PANTALLA DE TAREA FULLSCREEN ====== */
.task-screen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: #000;
  overflow: hidden;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.task-area {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ====== CONTADOR DE ENSAYOS ====== */
.trial-counter {
  position: absolute;
  top: 20px;
  left: 20px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  z-index: 100;
  border: 2px solid rgba(0, 212, 255, 0.3);
}

.counter-separator {
  color: var(--text-muted);
  margin: 0 4px;
}

/* ====== FIJACIÓN CENTRAL ====== */
.fixation {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 72px;
  color: var(--accent);
  opacity: 0.9;
  z-index: 10;
  user-select: none;
  pointer-events: none;
  text-shadow: 0 0 20px rgba(0, 212, 255, 0.5);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 0.7; }
}

/* ====== ESTÍMULOS MEJORADOS ====== */
.stimulus {
  position: absolute;
  width: 70px;
  height: 70px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 9;
  opacity: 1;
  transition: transform 0.2s ease, opacity 0.2s ease;
  border-radius: 4px;
}

.stimulus.go {
  border-radius: 50%;
  background: var(--go-color);
  box-shadow: 
    0 0 30px rgba(0, 255, 157, 0.5),
    0 0 60px rgba(0, 255, 157, 0.3),
    inset 0 0 20px rgba(255, 255, 255, 0.8);
  animation: pulse-go 1.5s ease-in-out infinite;
}

.stimulus.nogo {
  background: var(--nogo-color);
  box-shadow: 
    0 0 30px rgba(255, 71, 87, 0.5),
    0 0 60px rgba(255, 71, 87, 0.3),
    inset 0 0 20px rgba(255, 255, 255, 0.8);
  animation: pulse-nogo 1.5s ease-in-out infinite;
}

@keyframes pulse-go {
  0%, 100% { box-shadow: 0 0 30px rgba(0, 255, 157, 0.5), 0 0 60px rgba(0, 255, 157, 0.3), inset 0 0 20px rgba(255, 255, 255, 0.8); }
  50% { box-shadow: 0 0 40px rgba(0, 255, 157, 0.7), 0 0 80px rgba(0, 255, 157, 0.4), inset 0 0 25px rgba(255, 255, 255, 0.9); }
}

@keyframes pulse-nogo {
  0%, 100% { box-shadow: 0 0 30px rgba(255, 71, 87, 0.5), 0 0 60px rgba(255, 71, 87, 0.3), inset 0 0 20px rgba(255, 255, 255, 0.8); }
  50% { box-shadow: 0 0 40px rgba(255, 71, 87, 0.7), 0 0 80px rgba(255, 71, 87, 0.4), inset 0 0 25px rgba(255, 255, 255, 0.9); }
}

/* ====== INDICADOR DE RESPUESTA ====== */
.response-indicator {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  background: rgba(0, 255, 157, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--success);
  z-index: 100;
  opacity: 0;
  transform: scale(0);
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.response-indicator.show {
  opacity: 1;
  transform: scale(1);
}

.response-indicator.error {
  background: rgba(255, 71, 87, 0.2);
  color: var(--error);
}

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
  .card-elegant {
    padding: 24px;
  }
  
  .card-header {
    flex-direction: column;
    text-align: center;
    gap: 12px;
  }
  
  .card-elegant h1 {
    font-size: 24px;
  }
  
  .form-grid {
    grid-template-columns: 1fr;
  }
  
  .ui-actions {
    flex-direction: column;
  }
  
  .btn-modern {
    width: 100%;
  }
  
  .results-summary {
    grid-template-columns: 1fr;
  }
  
  .instruction-step {
    flex-direction: column;
    text-align: center;
  }
  
  .instruction-icon {
    margin-bottom: 12px;
  }
  
  .trial-counter {
    top: 10px;
    left: 10px;
    padding: 8px 16px;
    font-size: 14px;
  }
  
  .fixation {
    font-size: 56px;
  }
  
  .stimulus {
    width: 60px;
    height: 60px;
  }
}