/* Variables - Inspiré signalisation routière française */
:root {
  --blue-route: #003399;
  --blue-light: #1a4d9e;
  --white: #ffffff;
  --gray-100: #f5f6f8;
  --gray-200: #e8eaed;
  --gray-400: #9ca3af;
  --gray-600: #4b5563;
  --gray-800: #1f2937;
  --success: #059669;
  --success-bg: #d1fae5;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --error: #dc2626;
  --error-bg: #fee2e2;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.08);
  --radius: 12px;
  --radius-sm: 8px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(145deg, var(--gray-100) 0%, #e2e8f0 100%);
  color: var(--gray-800);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 680px;
  margin: 0 auto;
  padding: 1.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  margin-bottom: 1.5rem;
}

.header-content {
  text-align: center;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--blue-route);
  margin: 0 0 0.25rem;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--gray-600);
  font-size: 0.9rem;
  margin: 0 0 1.25rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.filter-btn {
  padding: 0.4rem 0.9rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid var(--gray-200);
  border-radius: 999px;
  background: var(--white);
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-btn:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}

.filter-btn.active {
  background: var(--blue-route);
  color: var(--white);
  border-color: var(--blue-route);
}

/* Progress */
.progress-bar {
  position: relative;
  height: 6px;
  background: var(--gray-200);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.progress-fill {
  height: 100%;
  background: var(--blue-route);
  border-radius: 999px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-text {
  position: absolute;
  right: 0;
  top: -1.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--gray-500);
}

/* Question card */
.question-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.category-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  background: var(--blue-route);
  color: var(--white);
}

.category-badge.VE { background: #0d9488; }
.category-badge.QSER { background: #7c3aed; }
.category-badge.secours { background: #dc2626; }

.question-text {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--gray-800);
  margin: 0 0 1.25rem;
  line-height: 1.5;
}

.answer-form label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 0.5rem;
}

#answerInput {
  width: 100%;
  padding: 1rem;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  resize: vertical;
  min-height: 100px;
  transition: border-color 0.2s;
}

#answerInput:focus {
  outline: none;
  border-color: var(--blue-route);
}

#answerInput::placeholder {
  color: var(--gray-400);
}

.submit-btn {
  margin-top: 1rem;
  width: 100%;
  padding: 0.85rem 1.25rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--white);
  background: var(--blue-route);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}

.submit-btn:hover {
  background: var(--blue-light);
}

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

.submit-btn.loading {
  cursor: wait;
  animation: submit-pulse 1s ease-in-out infinite;
}

@keyframes submit-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Feedback */
.feedback {
  min-height: 0;
  margin-bottom: 1rem;
  transition: opacity 0.3s;
}

.feedback:empty,
.feedback.hidden {
  display: none;
}

.feedback-content {
  padding: 1.25rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
}

.feedback.success .feedback-content {
  background: var(--success-bg);
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.feedback.partial .feedback-content {
  background: var(--warning-bg);
  color: #92400e;
  border: 1px solid #fde68a;
}

.feedback.error .feedback-content {
  background: var(--error-bg);
  color: #991b1b;
  border: 1px solid #fecaca;
}

.feedback h3 {
  font-size: 1rem;
  margin: 0 0 0.75rem;
  font-weight: 600;
}

.feedback ul {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}

.feedback .expected-answer {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(0,0,0,0.1);
  font-size: 0.9rem;
}

.feedback .expected-answer strong {
  display: block;
  margin-bottom: 0.25rem;
}

/* Nav */
.nav-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.nav-btn {
  padding: 0.6rem 1.25rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--gray-800);
  cursor: pointer;
  transition: all 0.2s;
}

.nav-btn:hover:not(:disabled) {
  background: var(--gray-100);
}

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

.random-btn {
  padding: 0.5rem 1rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px dashed var(--gray-400);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.2s;
}

.random-btn:hover {
  border-color: var(--blue-route);
  color: var(--blue-route);
}

/* Indicateur source d'analyse */
.feedback-source {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.75rem;
  font-weight: 500;
}

.feedback-source.source-gemini {
  background: #dbeafe;
  color: #1e40af;
}

.feedback-source.source-keywords {
  background: var(--gray-200);
  color: var(--gray-600);
}

/* Footer */
.app-footer {
  margin-top: auto;
  padding-top: 2rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--gray-400);
}

/* Responsive */
@media (max-width: 480px) {
  .app { padding: 1rem; }
  h1 { font-size: 1.4rem; }
  .question-card { padding: 1.25rem; }
}
