/* ====== RESET & BASE ====== */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { 
  background: #F5F5F0;
  font-family: -apple-system, 'Segoe UI', 'Helvetica Neue', sans-serif;
  height: 100%;
  width: 100%;
  overflow: hidden;
  color: #1A1A1A;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#root {
  height: 100vh;
  width: 100vw;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 12px 80px 12px;
  -webkit-overflow-scrolling: touch;
  background: #F5F5F0;
}

button { cursor: pointer; border: none; font-family: inherit; background: none; }
button:disabled { cursor: not-allowed; opacity: 0.3; }

/* ====== COULEURS UNIFORMISÉES ====== */
:root {
  --bg: #F5F5F0;
  --card: #FFFFFF;
  --green: #1B7A3D;
  --green-dark: #145C2E;
  --green-light: #E8F5EC;
  --green-soft: #F0F8F2;
  --text: #1A1A1A;
  --text-soft: #333333;
  --text-light: #666666;
  --shadow: 0 4px 20px rgba(27, 122, 61, 0.08);
  --radius: 16px;
}

/* ====== TYPOGRAPHIE ====== */
@import url('https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400&display=swap');
.amiri { font-family: 'Amiri', 'Times New Roman', serif; }

/* ====== COMPOSANTS ====== */
.container { 
  max-width: 480px; 
  margin: 0 auto; 
  width: 100%;
  padding: 0 2px;
}
.text-center { text-align: center; }
.text-green { color: var(--green); }
.text-soft { color: var(--text-soft); }

.card { 
  background: var(--card); 
  border-radius: var(--radius); 
  padding: 16px 14px; 
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  width: 100%;
  border: 1px solid rgba(27, 122, 61, 0.06);
}
.card-green { 
  border-color: var(--green); 
  border-width: 2px;
  background: var(--green-soft);
}
.card-green-light { 
  background: var(--green-soft); 
  border-color: rgba(27, 122, 61, 0.15);
  border-width: 1px;
}

.btn-primary { 
  width: 100%; padding: 13px 0; border-radius: 12px; 
  background: var(--green); 
  color: #FFFFFF; 
  font-weight: 600; font-size: 15px; 
  transition: all 0.3s ease;
  box-shadow: 0 4px 16px rgba(27, 122, 61, 0.25);
  letter-spacing: 0.5px;
}
.btn-primary:hover:not(:disabled) { 
  transform: translateY(-1px);
  background: var(--green-dark);
  box-shadow: 0 6px 24px rgba(27, 122, 61, 0.35);
}
.btn-primary:active:not(:disabled) { transform: scale(0.97); }
.btn-primary:disabled { background: #CCDCCC; color: #88AA88; box-shadow: none; }

.btn-secondary {
  padding: 9px 14px; border-radius: 10px; 
  background: var(--card); color: var(--text-soft);
  border: 1px solid rgba(27, 122, 61, 0.12);
  font-size: 13px; font-weight: 500;
  transition: all 0.3s ease;
}
.btn-secondary:hover:not(:disabled) { 
  background: var(--green-soft); 
  border-color: var(--green);
  color: var(--green);
}
.btn-secondary:active:not(:disabled) { transform: scale(0.97); }

.btn-outline {
  padding: 9px 14px; border-radius: 10px;
  background: transparent; color: var(--green);
  border: 2px solid var(--green);
  font-size: 13px; font-weight: 600;
  transition: all 0.3s ease;
}
.btn-outline:hover { background: var(--green-soft); }
.btn-outline:active { transform: scale(0.97); }

/* ====== HEADER ====== */
.app-header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(27, 122, 61, 0.08);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 48px;
  gap: 6px;
}

.app-header .logo {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.app-header .logo .arabic {
  font-family: 'Amiri', serif;
  font-size: 18px;
  color: var(--green);
  font-weight: 400;
}
.app-header .logo .french {
  font-family: 'Amiri', serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--green);
  letter-spacing: 0.3px;
}
.app-header .logo .divider {
  width: 1px;
  height: 18px;
  background: rgba(27, 122, 61, 0.12);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(27, 122, 61, 0.08);
  color: var(--green);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  touch-action: manipulation;
  border: 1px solid rgba(27, 122, 61, 0.1);
}
.btn-close:hover {
  background: rgba(27, 122, 61, 0.15);
  transform: scale(1.05);
}
.btn-close:active {
  transform: scale(0.9);
  background: rgba(27, 122, 61, 0.2);
}

/* ====== LANG SELECTOR ====== */
.lang-selector {
  display: flex;
  gap: 2px;
  background: var(--green-soft);
  border-radius: 10px;
  padding: 3px;
  border: 1px solid rgba(27, 122, 61, 0.08);
  flex-shrink: 0;
}
.lang-btn {
  padding: 4px 8px;
  border-radius: 8px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-soft);
  transition: all 0.3s ease;
  cursor: pointer;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 32px;
  justify-content: center;
}
.lang-btn .flag { font-size: 16px; line-height: 1; }
.lang-btn .code { font-size: 9px; font-weight: 600; letter-spacing: 0.5px; color: var(--text-light); }
.lang-btn.active {
  background: var(--green);
  color: #FFFFFF;
  box-shadow: 0 2px 12px rgba(27, 122, 61, 0.2);
}
.lang-btn.active .code { color: #FFFFFF; }
.lang-btn:active:not(.active) { transform: scale(0.92); }

/* ====== ÉCHELLE ====== */
.scale-buttons {
  display: flex;
  justify-content: space-between;
  gap: 4px;
}
.scale-btn {
  flex: 1;
  padding: 8px 2px;
  border-radius: 10px;
  border: 2px solid rgba(27, 122, 61, 0.08);
  background: var(--card);
  font-size: 18px;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  touch-action: manipulation;
  min-height: 48px;
}
.scale-btn .label {
  font-size: 6px;
  color: var(--text-light);
  font-weight: 500;
  letter-spacing: 0.2px;
  line-height: 1.2;
}
.scale-btn.active {
  border-color: var(--green);
  background: var(--green-soft);
  box-shadow: 0 0 20px rgba(27, 122, 61, 0.08);
  transform: scale(1.02);
}
.scale-btn:active:not(.active) { transform: scale(0.92); }

.moon-legend {
  display: flex;
  justify-content: space-between;
  gap: 2px;
  margin: 4px 0 10px 0;
  padding: 4px 2px;
  background: var(--card);
  border-radius: 10px;
  border: 1px solid rgba(27, 122, 61, 0.05);
}
.moon-legend-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  flex: 1;
  font-size: 7px;
  color: var(--text-light);
  font-weight: 500;
}
.moon-legend-item .emoji { font-size: 12px; }
.moon-legend-item .label { font-size: 6px; text-align: center; line-height: 1.2; }

/* ====== PROGRESS ====== */
.progress-dots {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin: 4px 0 12px 0;
}
.dot {
  height: 4px;
  border-radius: 2px;
  transition: all 0.5s ease;
}
.dot-active {
  width: 20px;
  background: var(--green);
  box-shadow: 0 0 12px rgba(27, 122, 61, 0.15);
}
.dot-inactive { width: 4px; background: rgba(27, 122, 61, 0.08); }

/* ====== ROSETTE ====== */
.rosette-container {
  display: flex;
  justify-content: center;
  margin-bottom: 4px;
}
.rosette-container svg {
  width: 64px;
  height: 64px;
  max-width: 80px;
  max-height: 80px;
  filter: drop-shadow(0 0 20px rgba(27, 122, 61, 0.08));
}

/* ====== RADAR ====== */
.radar-container {
  height: 180px;
  margin-bottom: 6px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 4px;
  border: 1px solid rgba(27, 122, 61, 0.05);
  width: 100%;
}
.radar-container svg {
  width: 100%;
  height: 100%;
}

/* ====== QUESTION ====== */
.question-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 12px;
  margin-bottom: 10px;
  border: 1px solid rgba(27, 122, 61, 0.05);
}
.question-card .q-number {
  font-size: 8px;
  font-weight: 600;
  color: var(--green);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.question-card .q-text {
  font-size: 13px;
  line-height: 1.5;
  color: #000000;
  margin-bottom: 8px;
  font-weight: 500;
}

.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.mt-16 { margin-top: 16px; }

/* ====== CHECKBOX ====== */
.check-wrapper {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  cursor: pointer;
  padding: 2px 0;
  margin-bottom: 12px;
}
.check-wrapper input[type="checkbox"] {
  margin-top: 2px;
  accent-color: var(--green);
  width: 16px;
  height: 16px;
  border-radius: 4px;
  flex-shrink: 0;
}
.check-wrapper span {
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.4;
}

/* ====== FOOTER ====== */
.app-footer {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(27, 122, 61, 0.06);
  padding: 6px 12px;
  text-align: center;
  font-size: 8px;
  color: var(--text-light);
  letter-spacing: 0.3px;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
}
.app-footer .footer-green { color: var(--green); font-weight: 500; }

/* ====== CHATBOT ====== */
.chat-toggle {
  position: fixed;
  bottom: 48px;
  right: 12px;
  z-index: 200;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--green);
  color: #FFFFFF;
  font-size: 22px;
  box-shadow: 0 4px 20px rgba(27, 122, 61, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  touch-action: manipulation;
}
.chat-toggle:active { transform: scale(0.9); }

.chat-window {
  position: fixed;
  bottom: 100px;
  right: 12px;
  width: 320px;
  max-width: calc(100vw - 24px);
  max-height: 420px;
  background: #FFFFFF;
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0,0,0,0.15);
  z-index: 199;
  display: none;
  flex-direction: column;
  border: 1px solid rgba(27, 122, 61, 0.06);
  overflow: hidden;
}
.chat-window.open { display: flex; }

.chat-header {
  padding: 10px 14px;
  background: var(--green);
  color: #FFFFFF;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.chat-header .title {
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat-header .close-btn {
  color: #FFFFFF;
  font-size: 18px;
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.7;
  touch-action: manipulation;
}
.chat-header .close-btn:active { opacity: 1; }

.chat-messages {
  flex: 1;
  padding: 10px 12px;
  overflow-y: auto;
  max-height: 280px;
  min-height: 120px;
  background: #FAFAF8;
}
.chat-message {
  margin-bottom: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  max-width: 85%;
  font-size: 12px;
  line-height: 1.5;
  color: #000000;
}
.chat-message.bot {
  background: var(--green-soft);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.chat-message.user {
  background: #E8E5DE;
  align-self: flex-end;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.chat-input-area {
  display: flex;
  padding: 8px 10px;
  gap: 6px;
  border-top: 1px solid rgba(27, 122, 61, 0.06);
  background: #FFFFFF;
  flex-shrink: 0;
}
.chat-input-area input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid rgba(27, 122, 61, 0.08);
  border-radius: 10px;
  font-size: 12px;
  outline: none;
  color: #000000;
  background: #FAFAF8;
}
.chat-input-area input:focus { border-color: var(--green); }
.chat-input-area button {
  padding: 8px 14px;
  background: var(--green);
  color: #FFFFFF;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  touch-action: manipulation;
}
.chat-input-area button:active { transform: scale(0.95); }

/* ====== PROTECTION ====== */
.protection-notice {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.92);
  color: #fff;
  padding: 24px 32px;
  border-radius: 12px;
  z-index: 99999;
  text-align: center;
  font-size: 14px;
  backdrop-filter: blur(8px);
  border: 2px solid var(--green);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  pointer-events: none;
  max-width: 90%;
}
.protection-notice.show { display: block; animation: fadeIn 0.3s ease; }
.protection-notice .title { font-weight: 700; font-size: 18px; margin-bottom: 6px; color: var(--green); }
.protection-notice .sub { font-size: 12px; color: #aaa; }
@keyframes fadeIn { from { opacity: 0; transform: translate(-50%, -50%) scale(0.92); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
.protection-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.15); z-index: 99998; display: none; pointer-events: none; }
.protection-overlay.active { display: block; }

/* ====== RESPONSIVE ====== */
@media (max-width: 480px) {
  .app-header { padding: 6px 10px; min-height: 42px; }
  .app-header .logo .arabic { font-size: 15px; }
  .app-header .logo .french { font-size: 12px; }
  .app-header .logo .divider { height: 14px; }
  .lang-btn { padding: 3px 5px; font-size: 11px; min-width: 26px; }
  .lang-btn .flag { font-size: 13px; }
  .lang-btn .code { font-size: 7px; }
  .btn-close { width: 28px; height: 28px; font-size: 12px; }
  #root { padding: 6px 10px 72px 10px; }
  .card { padding: 12px 10px; margin-bottom: 8px; border-radius: 14px; }
  .scale-btn { font-size: 15px; padding: 6px 2px; min-height: 40px; border-radius: 8px; }
  .scale-btn .label { font-size: 5px; }
  .scale-buttons { gap: 3px; }
  .moon-legend { padding: 3px 2px; margin: 2px 0 8px 0; }
  .moon-legend-item .emoji { font-size: 10px; }
  .moon-legend-item .label { font-size: 5px; }
  .btn-primary { padding: 11px 0; font-size: 13px; border-radius: 10px; }
  .radar-container { height: 150px; padding: 4px; }
  .rosette-container svg { width: 50px; height: 50px; }
  .question-card { padding: 10px 10px; }
  .question-card .q-text { font-size: 12px; }
  .question-card .q-number { font-size: 7px; }
  .btn-secondary { padding: 7px 10px; font-size: 11px; }
  .btn-outline { padding: 7px 10px; font-size: 11px; }
  .app-footer { font-size: 7px; padding: 4px 10px; }
  .chat-window { width: calc(100vw - 24px); right: 12px; bottom: 90px; max-height: 360px; }
  .chat-toggle { width: 44px; height: 44px; font-size: 20px; bottom: 44px; right: 10px; }
}

@media (max-width: 360px) {
  .app-header .logo .arabic { font-size: 13px; }
  .app-header .logo .french { font-size: 10px; }
  .lang-btn { padding: 2px 4px; font-size: 9px; min-width: 22px; }
  .lang-btn .flag { font-size: 11px; }
  .lang-btn .code { font-size: 6px; }
  .btn-close { width: 24px; height: 24px; font-size: 10px; }
  .scale-btn { font-size: 13px; padding: 4px 1px; min-height: 34px; }
  .card { padding: 8px 8px; }
  #root { padding: 4px 6px 68px 6px; }
  .question-card .q-text { font-size: 11px; }
}