/* style.css */

/* Variables de couleurs */
:root {
  --blue: #1e40af;
  --green: #059669;
  --red: #dc2626;
  --yellow-light: #fff9c4;
  --bg1: #ffffff;
  --bg2: #f8fafc;
  --text: #1f2937;
}

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

html, body {
  height: 100%;
  direction: rtl;
  font-family: 'Amiri', serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: var(--text);
}

.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

/* Pages */
.page {
  display: none;
  animation: fadeIn 0.25s ease;
}
.page.active {
  display: block;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* En-tête */
.header {
  background: rgba(255,255,255,0.95);
  border-radius: 18px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  margin: 16px 0;
}
.header h1 {
  color: var(--blue);
  font-size: clamp(22px, 5vw, 34px);
  margin-bottom: 8px;
}
.subtitle {
  color: #64748b;
}

/* Cartes */
.card {
  background: rgba(255,255,255,0.95);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  margin: 16px 0;
}
.section {
  background: rgba(248,250,252,0.88);
  border: 2px solid rgba(30,64,175,0.12);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
}
.section h3 {
  color: var(--blue);
  text-align: center;
  margin-bottom: 12px;
}
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
label {
  font-weight: 600;
  color: #374151;
  font-size: 14px;
}
select, input[type=number] {
  padding: 12px 14px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  font-size: 16px;
  direction: rtl;
}
select:focus, input[type=number]:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(30,64,175,0.12);
}
.error {
  display: none;
  margin-top: 4px;
  font-size: 12px;
  color: var(--red);
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 8px 10px;
}
.error.show {
  display: block;
}

/* Stats */
.stats {
  text-align: center;
  margin: 12px 0;
  padding: 14px;
  background: rgba(30,64,175,0.08);
  border: 2px solid rgba(30,64,175,0.18);
  border-radius: 14px;
  color: var(--blue);
  font-weight: 700;
}

/* Boutons */
.btn {
  padding: 14px 22px;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s;
  min-width: 120px;
}
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn-primary { background: linear-gradient(135deg, #1e40af, #3b82f6); color: #fff; }
.btn-neutral { background: #64748b; color: #fff; }
.btn-green   { background: var(--green); color: #fff; }
.btn-red     { background: var(--red); color: #fff; }
.btn-purple  { background: #7c3aed; color: #fff; }
.btn-amber   { background: #f59e0b; color: #fff; }
.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0,0,0,0.18);
}

/* Quiz header */
.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

/* Badges */
.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.badge {
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
  font-weight: 700;
  color: #374151;
}
.badge .ok  { color: var(--green); }
.badge .ko  { color: var(--red); }

/* Question wrap */
.qwrap { min-height: 360px; }
.qcounter {
  text-align: center;
  color: #64748b;
  font-weight: 700;
  margin-bottom: 14px;
}
.qtext {
  text-align: center;
  font-weight: 700;
  line-height: 1.7;
  background: #fff;
  border-radius: 14px;
  padding: 18px;
  border-right: 5px solid var(--blue);
}
/* Fond jaune pour verset dans mode texte */
#textMode .qtext span#vNum,
#textMode .qtext span#sName {
  background-color: var(--yellow-light);
  border-radius: 4px;
  padding: 2px 6px;
  font-weight: 700;
  font-size: 1.4rem;
}

/* Blocs verset & info */
.verset, .info {
  background: var(--bg2);
  font-family: 'Amiri', serif;
  font-size: 1.2rem;
  line-height: 1.8;
  border-right: 5px solid var(--blue);
  padding: 18px;
  border-radius: 14px;
  margin: 14px 0;
  text-align: center;
}
/* Fond jaune pour la ligne du verset dans mode audio */
#info > div:first-child {
  background-color: var(--yellow-light);
  border-radius: 8px;
  padding: 6px 10px;
}
/* Texte coranique en gras */
#info > div:first-child span#tAudio {
  font-weight: 700;
}

/* Flex audio */
.flex-audio {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
}
.flex-audio audio {
  flex-shrink: 0;
  max-width: 70%;
}
.flex-audio button {
  white-space: nowrap;
}

/* Historique */
.history .item {
  background: #fff;
  border-radius: 12px;
  margin: 10px 0;
  padding: 12px;
  border-right: 5px solid;
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
}
.history .item.ok { background: #f0fdf4; border-color: var(--green); }
.history .item.ko { background: #fef2f2; border-color: var(--red); }

/* Vidéo anti-sommeil » */
.nosleep {
  position: fixed;
  top: -9999px;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* Loading spinner */
.loading {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 3px solid #e5e7eb;
  border-top: 3px solid var(--blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsivité */
@media (max-width: 768px) {
  .grid2 { grid-template-columns: 1fr; }
  .quiz-header { flex-direction: column; align-items: stretch; }
}

/* Mode sombre */
@media (prefers-color-scheme: dark) {
  body {
    background: linear-gradient(135deg,#1e293b 0%,#334155 100%);
    color: #e5e7eb;
  }
  .header, .card {
    background: rgba(17,24,39,0.92);
  }
  .section {
    background: rgba(31,41,55,0.88);
  }
  .qtext, .verset, .history .item {
    background: rgba(30,41,59,0.95);
    color: #e5e7eb;
  }
  select, input[type=number] {
    background: #0f172a;
    color: #f8fafc;
    border-color: #334155;
  }
}
