/* PWA Clase C Chile - Estilos */

/* Variables CSS */
:root {
  --primary-color: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary-color: #64748b;
  --success-color: #10b981;
  --error-color: #ef4444;
  --warning-color: #f59e0b;
  --background-color: #f8fafc;
  --surface-color: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
}

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

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

/* Layout principal */
#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header */
.header {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 1rem 0;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.progress-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  min-width: 200px;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background-color: var(--success-color);
  transition: width 0.3s ease;
  width: 0%;
}

/* Main content */
.main {
  flex: 1;
  padding: 2rem 0;
}

/* Screens */
.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: fadeIn 0.3s ease-in-out;
}

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

/* Welcome Screen */
.welcome-card {
  background: var(--surface-color);
  border-radius: var(--radius-xl);
  padding: 3rem 2rem;
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 700px;
  margin: 0 auto;
}

.welcome-card h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

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

.total-questions-info {
  margin: 1rem 0;
}

.total-questions-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-lg);
  font-weight: 600;
  font-size: 1.1rem;
  box-shadow: var(--shadow-md);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.manual-download {
  margin: 2rem 0;
  padding: 1.5rem;
  background: var(--background-color);
  border-radius: var(--radius-lg);
  border: 2px solid var(--border-color);
}

.manual-download h4 {
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  font-size: 1.2rem;
}

.manual-download p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.download-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, var(--success-color), #059669);
  color: white;
  text-decoration: none;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-lg);
  font-weight: 600;
  font-size: 1rem;
  box-shadow: var(--shadow-md);
  transition: all 0.2s ease;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.download-button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  background: linear-gradient(135deg, #059669, var(--success-color));
}

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

/* Question Selector */
.question-selector {
  background: var(--background-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin: 2rem 0;
  border: 1px solid var(--border-color);
}

.question-selector h3 {
  font-size: 1.3rem;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

.question-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.question-option {
  background: var(--surface-color);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.question-option:hover {
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.question-option.active {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  border-color: var(--primary-color);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.question-option:active {
  transform: translateY(0);
}

.custom-questions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.custom-questions label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.custom-questions input {
  width: 200px;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  font-size: 1rem;
  text-align: center;
  transition: border-color 0.2s ease;
}

.custom-questions input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.study-info {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--background-color);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.study-info p {
  margin: 0;
  font-weight: 600;
  color: var(--text-primary);
}

#selected-count {
  color: var(--primary-color);
  font-weight: 700;
}

.today-stats {
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: rgba(37, 99, 235, 0.1);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary-color);
}

.today-stats small {
  color: var(--text-secondary);
  font-weight: 500;
}

.today-sessions {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--background-color);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.today-sessions h4 {
  margin-bottom: 1rem;
  color: var(--text-primary);
  font-size: 1.1rem;
}

.session-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--surface-color);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.session-time {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.session-stats {
  font-size: 0.9rem;
  color: var(--text-primary);
  font-weight: 600;
}

.session-accuracy {
  color: var(--success-color);
}

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

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem;
  background: var(--background-color);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.stat-number {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.stat-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: center;
}

/* Question Screen */
.question-card {
  background: var(--surface-color);
  border-radius: var(--radius-xl);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  max-width: 800px;
  margin: 0 auto;
}

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border-color);
}

.question-header span {
  font-weight: 600;
  color: var(--text-secondary);
}

#question-timer {
  color: var(--primary-color);
  font-weight: 700;
}

#question-text {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 2rem;
  line-height: 1.5;
  color: var(--text-primary);
}

.question-image {
  margin: 1.5rem 0;
  text-align: center;
}

.question-image img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.options {
  display: grid;
  gap: 1rem;
  margin-bottom: 2rem;
}

.option {
  background: var(--surface-color);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.option:hover {
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.option:active {
  transform: translateY(0);
}

.option.correct {
  background-color: #dcfce7;
  border-color: var(--success-color);
  color: #166534;
}

.option.incorrect {
  background-color: #fef2f2;
  border-color: var(--error-color);
  color: #991b1b;
}

.option:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

/* Estilos para opciones de múltiples respuestas */
.option-multiple {
  position: relative;
  padding-left: 3rem;
}

.option-multiple::before {
  content: '';
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--surface-color);
  transition: all 0.2s ease;
}

.option-multiple:hover::before {
  border-color: var(--primary-color);
}

.option-multiple.selected::before {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.option-multiple.selected::after {
  content: '✓';
  position: absolute;
  left: 1.125rem;
  top: 50%;
  transform: translateY(-50%);
  color: white;
  font-size: 0.875rem;
  font-weight: bold;
}

.option-multiple.selected {
  background-color: #eff6ff;
  border-color: var(--primary-color);
  color: var(--primary-dark);
}

.option-multiple.selected:hover {
  background-color: #dbeafe;
}

/* Instrucciones para preguntas múltiples */
.multiple-instruction {
  margin-bottom: 1rem;
  padding: 1rem;
  background: #f0f9ff;
  border: 1px solid #0ea5e9;
  border-radius: var(--radius-lg);
  color: #0c4a6e;
}

.multiple-instruction p {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
}

.explanation {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: var(--background-color);
  border-radius: var(--radius-lg);
  border-left: 4px solid var(--primary-color);
}

.explanation h4 {
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.explanation p {
  color: var(--text-secondary);
  line-height: 1.6;
}

.question-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

/* Results Screen */
.results-card {
  background: var(--surface-color);
  border-radius: var(--radius-xl);
  padding: 3rem 2rem;
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  margin: 0 auto;
}

.results-card h2 {
  font-size: 2rem;
  margin-bottom: 2rem;
  color: var(--text-primary);
}

.results-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.result-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem;
  background: var(--background-color);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.result-number {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.result-stat:nth-child(1) .result-number {
  color: var(--success-color);
}

.result-stat:nth-child(2) .result-number {
  color: var(--error-color);
}

.result-stat:nth-child(3) .result-number {
  color: var(--primary-color);
}

.result-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: center;
}

.results-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 2rem;
}

/* Review Screen */
.review-card {
  background: var(--surface-color);
  border-radius: var(--radius-xl);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  max-width: 800px;
  margin: 0 auto;
}

.review-card h2 {
  font-size: 1.8rem;
  margin-bottom: 2rem;
  text-align: center;
  color: var(--text-primary);
}

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

.review-item {
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: var(--background-color);
}

.review-item.correct {
  border-left: 4px solid var(--success-color);
}

.review-item.incorrect {
  border-left: 4px solid var(--error-color);
}

.review-question h4 {
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.review-question p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-weight: 500;
}

.review-answers {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.user-answer {
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.user-answer.correct {
  background-color: #dcfce7;
  color: #166534;
}

.user-answer.incorrect {
  background-color: #fef2f2;
  color: #991b1b;
}

.correct-answer {
  padding: 0.5rem;
  background-color: #dcfce7;
  color: #166534;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.review-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 48px;
  gap: 0.5rem;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--surface-color);
  color: var(--text-primary);
  border: 2px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--primary-color);
  color: var(--primary-color);
  transform: translateY(-2px);
}

.btn-continue {
  background: linear-gradient(135deg, var(--success-color) 0%, #059669 100%);
}

.install-btn {
  margin-top: 1rem;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* Footer */
.footer {
  background: var(--surface-color);
  border-top: 1px solid var(--border-color);
  padding: 1.5rem 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Modals */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease-in-out;
}

.modal-content {
  background: var(--surface-color);
  border-radius: var(--radius-xl);
  padding: 2rem;
  max-width: 500px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease-in-out;
}

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

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

.modal p {
  color: var(--text-secondary);
  margin-bottom: 2rem;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.error-modal .modal-content {
  border-left: 4px solid var(--error-color);
}

.update-modal .modal-content {
  border-left: 4px solid var(--warning-color);
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 0 0.75rem;
  }
  
  .header .container {
    flex-direction: column;
    text-align: center;
  }
  
  .progress-info {
    align-items: center;
    min-width: auto;
  }
  
  .welcome-card,
  .question-card,
  .results-card,
  .review-card {
    padding: 1.5rem;
    margin: 0 0.5rem;
  }
  
  .welcome-card h2 {
    font-size: 1.5rem;
  }
  
  .question-selector {
    padding: 1.5rem;
  }
  
  .question-options {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  
  .question-option {
    padding: 0.75rem;
    font-size: 0.9rem;
  }
  
  .custom-questions input {
    width: 150px;
  }
  
  .stats {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .results-stats {
    grid-template-columns: 1fr;
  }
  
  .question-header {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }
  
  .options {
    gap: 0.75rem;
  }
  
  .option {
    padding: 0.875rem 1rem;
    font-size: 0.95rem;
  }
  
  .results-actions,
  .review-actions {
    flex-direction: column;
  }
  
  .btn {
    width: 100%;
    justify-content: center;
  }
  
  .modal-content {
    padding: 1.5rem;
    margin: 1rem;
  }
  
  .modal-actions {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .welcome-card,
  .question-card,
  .results-card,
  .review-card {
    padding: 1rem;
    margin: 0 0.25rem;
  }
  
  .logo {
    font-size: 1.25rem;
  }
  
  .stat-number,
  .result-number {
    font-size: 2rem;
  }
  
  .question-header {
    font-size: 0.9rem;
  }
  
  #question-text {
    font-size: 1.1rem;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
  }
  
  .option {
    background: var(--surface-color);
    color: var(--text-primary);
  }
  
  .option:hover {
    background: #334155;
  }
}

/* Print styles */
@media print {
  .header,
  .footer,
  .btn,
  .modal {
    display: none !important;
  }
  
  .screen {
    display: block !important;
  }
  
  body {
    background: white !important;
    color: black !important;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles for accessibility */
.btn:focus,
.option:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
  :root {
    --border-color: #000000;
    --text-secondary: #000000;
  }
  
  .option {
    border-width: 3px;
  }
}
