/* === CoachVoice — Styles accessibles personne âgée === */

:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #555;
  --gold: #c8960c;
  --gold-light: #e2b04a;
  --blue-dark: #1a1a2e;
  --blue-mid: #0f3460;
  --green: #2d6a4f;
  --red: #c0392b;
  --radius: 20px;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 18px; /* base large pour lisibilité */
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  max-width: 500px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* === Écrans === */
.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 100dvh;
  padding: 16px;
}

.screen.active {
  display: flex;
}

/* === Header === */
.app-header {
  text-align: center;
  padding: 32px 16px 20px;
}

.app-title {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--blue-dark);
  letter-spacing: -0.5px;
}

.app-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* === Gros boutons mode === */
.big-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 8px 0;
}

.btn-mode {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 24px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font);
  transition: transform 0.15s, box-shadow 0.15s;
  min-height: 140px;
  box-shadow: var(--shadow);
}

.btn-mode:active {
  transform: scale(0.97);
}

.btn-conseil {
  background: linear-gradient(135deg, #1a1a2e 0%, #0f3460 100%);
  color: #fff;
}

.btn-roman {
  background: linear-gradient(135deg, #2d6a4f 0%, #1b4332 100%);
  color: #fff;
}

.btn-icon {
  font-size: 3rem;
  margin-bottom: 8px;
}

.btn-label {
  font-size: 1.5rem;
  font-weight: 700;
}

.btn-desc {
  font-size: 0.95rem;
  opacity: 0.8;
  margin-top: 4px;
}

/* === Historique === */
.history-section {
  margin-top: 24px;
  flex: 1;
}

.section-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-state {
  text-align: center;
  color: #999;
  padding: 32px 16px;
  font-style: italic;
}

.note-item {
  background: var(--surface);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.note-item:active {
  background: #f0f0f0;
}

.note-content {
  flex: 1;
  min-width: 0;
}

.note-text {
  font-size: 1rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-meta {
  font-size: 0.8rem;
  color: #999;
  margin-top: 4px;
}

.note-badge {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-conseil { background: #e8f0fe; color: #0f3460; }
.badge-roman { background: #e6f4ea; color: #2d6a4f; }

/* === Écran enregistrement === */
.record-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
}

.btn-back {
  background: none;
  border: 2px solid #ddd;
  padding: 10px 18px;
  border-radius: 30px;
  font-size: 1rem;
  cursor: pointer;
  font-family: var(--font);
  color: var(--text-secondary);
}

.btn-back:active {
  background: #eee;
}

.record-mode {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--blue-dark);
}

.record-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  overflow-y: auto;
}

/* === Bouton micro === */
.btn-mic {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 6px solid #e0e0e0;
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
  position: relative;
}

.btn-mic.recording {
  border-color: var(--red);
  background: #fff5f5;
  animation: pulse-mic 1.5s ease-in-out infinite;
}

@keyframes pulse-mic {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0.4); }
  50% { box-shadow: 0 0 0 24px rgba(192, 57, 43, 0); }
}

.mic-icon {
  font-size: 3.5rem;
  transition: transform 0.2s;
}

.btn-mic.recording .mic-icon {
  animation: mic-bounce 0.6s ease-in-out infinite alternate;
}

@keyframes mic-bounce {
  from { transform: scale(1); }
  to { transform: scale(1.1); }
}

.mic-hint {
  font-size: 1.1rem;
  color: var(--text-secondary);
  text-align: center;
}

.btn-mic.recording + .mic-hint {
  color: var(--red);
  font-weight: 600;
}

/* === Diagnostic dictée === */
.speech-status {
  font-size: 0.85rem;
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 600;
  text-align: center;
}

.speech-supported {
  background: #e6f4ea;
  color: #2d6a4f;
}

.speech-unsupported {
  background: #fdecea;
  color: #c0392b;
}

/* === Zone de texte === */
.transcript-input {
  width: 100%;
  min-height: 150px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 2px solid #ddd;
  font-family: var(--font);
  font-size: 1.2rem;
  line-height: 1.7;
  color: var(--text);
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

.transcript-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(226, 176, 74, 0.15);
}

.transcript-input::placeholder {
  color: #bbb;
  font-style: italic;
}

/* === Actions enregistrement (barre fixe en bas) === */
.record-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 12px 0;
  background: var(--bg);
  z-index: 10;
}

.btn-action {
  padding: 16px 32px;
  border: none;
  border-radius: 30px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  transition: transform 0.1s;
}

.btn-action:active {
  transform: scale(0.95);
}

.btn-stop {
  background: #fdecea;
  color: var(--red);
  border: 2px solid var(--red);
}

.btn-save {
  background: var(--blue-dark);
  color: #fff;
}

/* === Écran résultat === */
.result-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 20px;
}

.result-card {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border-left: 5px solid var(--gold);
}

.result-text {
  font-size: 1.2rem;
  line-height: 1.7;
  white-space: pre-wrap;
}

.result-actions {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 10px;
}

.btn-result {
  padding: 18px 24px;
  border: none;
  border-radius: 16px;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  text-align: center;
  transition: transform 0.1s, opacity 0.15s;
}

.btn-result:active {
  transform: scale(0.97);
}

.btn-video {
  background: linear-gradient(135deg, #e2b04a, #c8960c);
  color: #fff;
  font-size: 1.25rem;
}

.btn-copy {
  background: #e8f0fe;
  color: var(--blue-mid);
}

.btn-share {
  background: #e6f4ea;
  color: var(--green);
}

.btn-new {
  background: #f0f0f0;
  color: var(--text-secondary);
}

/* === Grille partage réseaux === */
.share-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 4px;
}

.share-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  width: 100%;
}

.btn-share-network {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px;
  border: none;
  border-radius: 14px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  transition: transform 0.1s, opacity 0.15s;
  color: #fff;
  min-height: 72px;
  justify-content: center;
}

.btn-share-network:active {
  transform: scale(0.94);
}

.share-icon {
  font-size: 1.5rem;
}

.btn-whatsapp  { background: #25D366; }
.btn-telegram  { background: #0088cc; }
.btn-facebook  { background: #1877F2; }
.btn-tiktok    { background: #000000; border: 1px solid #333; }
.btn-instagram { background: radial-gradient(circle at 30% 110%, #FDF497 0%, #FD5949 50%, #D6249F 100%); }
.btn-copy      { background: #555; }

.btn-download {
  background: var(--blue-mid);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px;
  border: none;
  border-radius: 14px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  min-height: 72px;
  justify-content: center;
}

.btn-download {
  background: var(--blue-mid);
  color: #fff;
}

/* === Génération vidéo === */
.video-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 20px;
}

.theme-picker {
  width: 100%;
}

.theme-label {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-secondary);
}

.theme-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.theme-btn {
  padding: 14px 12px;
  border: 2px solid #ddd;
  border-radius: 14px;
  background: var(--surface);
  font-size: 1rem;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
}

.theme-btn.active {
  border-color: var(--gold);
  background: #fff8e7;
  font-weight: 700;
}

.progress-area {
  width: 100%;
  text-align: center;
}

.progress-bar {
  width: 100%;
  height: 12px;
  background: #eee;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  border-radius: 6px;
  width: 0%;
  transition: width 0.1s linear;
}

.progress-text {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.video-preview {
  width: 100%;
  max-width: 300px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.video-actions {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 10px;
}

/* === Roman — Livre complet === */

.book-title-input {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid #ddd;
  border-radius: var(--radius);
  font-size: 1.3rem;
  font-weight: 700;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  outline: none;
  text-align: center;
  transition: border-color 0.2s;
}

.book-title-input:focus {
  border-color: var(--gold);
}

.book-stats {
  display: flex;
  gap: 16px;
  justify-content: center;
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.toc-section {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.toc-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.book-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.btn-roman-add {
  background: var(--blue-mid);
  color: #fff;
  padding: 18px 24px;
  border: none;
  border-radius: 16px;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  text-align: center;
}

.btn-roman-add:active {
  transform: scale(0.97);
}

/* === Lecture livre complet === */
.reader-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
}

.book-full-text {
  font-size: 1.1rem;
  line-height: 1.9;
  white-space: pre-wrap;
  color: var(--text);
  padding: 24px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.book-full-text h2 {
  font-size: 1.3rem;
  margin: 24px 0 8px;
  color: var(--blue-dark);
  border-bottom: 2px solid var(--gold);
  padding-bottom: 4px;
}

/* === Roman === */
.roman-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 0;
}

.roman-chapters {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.chapter-item {
  background: var(--surface);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
}

.chapter-item:active {
  background: #f0f0f0;
}

.chapter-num {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--gold);
  min-width: 48px;
  text-align: center;
}

.chapter-info {
  flex: 1;
  min-width: 0;
}

.chapter-title {
  font-weight: 700;
  font-size: 1.05rem;
}

.chapter-preview {
  font-size: 0.9rem;
  color: #999;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* === Toast === */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #333;
  color: #fff;
  padding: 14px 28px;
  border-radius: 30px;
  font-size: 1rem;
  font-weight: 600;
  z-index: 1000;
  transition: transform 0.3s ease;
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* === Responsive === */
@media (max-width: 380px) {
  .btn-mode {
    min-height: 120px;
    padding: 22px 18px;
  }
  .btn-icon { font-size: 2.5rem; }
  .btn-label { font-size: 1.3rem; }
  .btn-mic {
    width: 110px;
    height: 110px;
  }
  .mic-icon { font-size: 2.8rem; }
  .transcript-input { min-height: 100px; font-size: 1.05rem; }
  .record-area { gap: 10px; padding: 8px 0; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111119;
    --surface: #1c1c2a;
    --text: #eee;
    --text-secondary: #aaa;
  }
  .btn-mode { box-shadow: 0 4px 24px rgba(0,0,0,0.3); }
  .note-item { background: #1c1c2a; }
  .transcript-box { background: #1c1c2a; border-color: #333; }
  .btn-mic { background: #1c1c2a; border-color: #333; }
  .btn-mic.recording { background: #2a1515; }
  .result-card { background: #1c1c2a; }
  .chapter-item { background: #1c1c2a; }
  .theme-btn { background: #1c1c2a; border-color: #333; color: #eee; }
  .theme-btn.active { background: #2a2210; }
  .btn-back { border-color: #444; color: #aaa; }
  .btn-new { background: #2a2a2a; color: #aaa; }
  .btn-copy { background: #444; }
  .share-label { color: #aaa; }
  .btn-tiktok { border-color: #444; }
  .transcript-input { background: #1c1c2a; border-color: #333; color: #eee; }
  .transcript-input:focus { border-color: var(--gold); }
  .transcript-input::placeholder { color: #666; }
  .speech-supported { background: #1a3028; color: #4caf50; }
  .speech-unsupported { background: #2a1515; color: #ef5350; }
  .record-actions { background: #111119; }
  .book-title-input { background: #1c1c2a; border-color: #333; color: #eee; }
  .book-title-input:focus { border-color: var(--gold); }
  .book-full-text { background: #1c1c2a; color: #eee; }
  .book-full-text h2 { color: #e2b04a; }
  .btn-roman-add { background: #0f3460; }
  .btn-copy { background: #1a2540; }
  .btn-share { background: #1a3028; }
}
