/* ============================================================
   TABIFLOW — CSS principal
   ============================================================ */

/* --- Reset & base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 16px; -webkit-tap-highlight-color: transparent; }

/* --- Variables thème Tabiflow (défaut) --- */
body.theme-tabiflow {
  --bg:        #FFFDF8;
  --bg2:       #FAEEDA;
  --bg3:       #FAECE7;
  --accent:    #993C1D;
  --accent2:   #BA7517;
  --accent3:   #993556;
  --green:     #0F6E56;
  --green-bg:  #E1F5EE;
  --red:       #A32D2D;
  --red-bg:    #FCEBEB;
  --text:      #412402;
  --text2:     #854F0B;
  --text3:     #B4B2A9;
  --border:    #F0997B33;
  --border2:   #F0997B;
  --shadow:    rgba(65,36,2,0.12);
  --radius:    10px;
  --radius-lg: 16px;
  --nav-h:     68px;
}

body.theme-sombre {
  --bg:        #1C1C1E;
  --bg2:       #2C2C2E;
  --bg3:       #3A3A3C;
  --accent:    #FF6B4A;
  --accent2:   #FFB340;
  --accent3:   #FF375F;
  --green:     #30D158;
  --green-bg:  #1C3A28;
  --red:       #FF453A;
  --red-bg:    #3A1C1C;
  --text:      #F2F2F7;
  --text2:     #AEAEB2;
  --text3:     #636366;
  --border:    rgba(255,255,255,0.08);
  --border2:   rgba(255,255,255,0.2);
  --shadow:    rgba(0,0,0,0.3);
  --radius:    10px;
  --radius-lg: 16px;
  --nav-h:     68px;
}

/* --- Structure --- */
body { background: var(--bg); color: var(--text); }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); transition: opacity .25s; }
.screen.hidden { display: none; }
.screen.active { display: flex; }

/* --- Splash --- */
.splash {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg2) 0%, #FBEAF0 100%);
  flex-direction: column;
  gap: 12px;
}
.splash-title {
  font-family: 'Playfair Display', serif;
  font-size: 36px;
  font-weight: 700;
  color: var(--text);
}
.splash-tagline {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 15px;
  color: var(--accent);
}

/* --- Auth --- */
.auth-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.auth-header { text-align: center; margin-bottom: 24px; }
.auth-logo-small {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.auth-tabs {
  display: flex;
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1;
  padding: 9px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text2);
  cursor: pointer;
  transition: all .2s;
}
.auth-tab.active {
  background: var(--bg);
  color: var(--accent);
  font-weight: 500;
  box-shadow: 0 1px 4px var(--shadow);
}

.auth-form { display: flex; flex-direction: column; gap: 4px; }
.auth-form.hidden { display: none; }

/* --- Formulaires --- */
.form-group { display: flex; flex-direction: column; margin-bottom: 14px; }
.form-label { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 5px; }
.form-input {
  padding: 12px 14px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color .2s;
  -webkit-appearance: none;
}
.form-input:focus { border-color: var(--accent); }
.input-with-icon { position: relative; }
.input-with-icon .form-input { padding-right: 44px; }
.input-icon-btn {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text3); cursor: pointer; font-size: 18px; padding: 4px;
}

/* Force mot de passe */
.mdp-force { margin-top: 6px; display: flex; align-items: center; gap: 8px; }
.mdp-barre { flex: 1; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
#mdp-barre-fill { height: 100%; width: 0; border-radius: 2px; transition: width .3s, background .3s; }
#mdp-force-label { font-size: 11px; color: var(--text3); }

.form-error { background: var(--red-bg); color: var(--red); font-size: 13px; padding: 10px 12px; border-radius: var(--radius); margin-bottom: 10px; }
.form-success { background: var(--green-bg); color: var(--green); font-size: 13px; padding: 10px 12px; border-radius: var(--radius); margin-bottom: 10px; }
.form-hint { font-size: 13px; color: var(--text2); line-height: 1.5; margin-bottom: 16px; }
.form-legal { font-size: 11px; color: var(--text3); text-align: center; margin-top: 8px; line-height: 1.5; }
.form-legal a { color: var(--accent); text-decoration: none; }

/* --- Boutons --- */
.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #FFFDF8;
  border: none;
  border-radius: var(--radius);
  padding: 14px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 4px;
  transition: opacity .15s;
}
.btn-primary:active { opacity: .85; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
  width: 100%;
  background: var(--bg2);
  color: var(--accent);
  border: none;
  border-radius: var(--radius);
  padding: 13px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 6px;
}
.btn-link {
  background: none; border: none; color: var(--accent);
  font-size: 13px; cursor: pointer; padding: 8px; width: 100%; margin-top: 4px;
}

/* --- Onboarding pays --- */
.onb-container { padding: 32px 20px 40px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 16px; }
.onb-header { display: flex; flex-direction: column; gap: 6px; }
.onb-step-label { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: .5px; }
.onb-title { font-size: 22px; font-weight: 500; color: var(--text); }
.onb-desc { font-size: 13px; color: var(--text2); line-height: 1.6; }

.pays-selector { display: flex; flex-direction: column; gap: 0; border: 1px solid var(--border2); border-radius: var(--radius); overflow: hidden; }
.pays-search-wrap { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--bg); border-bottom: 1px solid var(--border); }
.pays-search-wrap i { font-size: 18px; color: var(--text3); flex-shrink: 0; }
.pays-search-input { flex: 1; border: none; outline: none; font-size: 15px; color: var(--text); background: transparent; }
.pays-liste { max-height: 260px; overflow-y: auto; background: var(--bg); }
.pays-section-title { padding: 6px 14px; font-size: 10px; color: var(--text2); text-transform: uppercase; letter-spacing: .5px; background: var(--bg2); }
.pays-item { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .15s; }
.pays-item:last-child { border-bottom: none; }
.pays-item:active, .pays-item.selected { background: var(--bg3); }
.pays-flag { font-size: 20px; }
.pays-nom { flex: 1; font-size: 14px; color: var(--text); }
.pays-check { font-size: 18px; color: var(--accent); }

.pays-preview { background: var(--green-bg); border-radius: var(--radius); padding: 12px 14px; }
.pays-preview-titre { font-size: 11px; color: var(--green); font-weight: 500; text-transform: uppercase; letter-spacing: .4px; margin-bottom: 6px; }
.pays-preview-item { font-size: 13px; color: var(--text); margin-bottom: 3px; }

/* --- App principale --- */
#screen-app { padding-bottom: var(--nav-h); }
#app-content { flex: 1; overflow-y: auto; }

.tab-content { display: none !important; min-height: 100%; }
.tab-content.active { display: block !important; }

.tab-header { background: var(--bg2); padding: 16px 16px 12px; }
.tab-title { font-size: 20px; font-weight: 500; color: var(--text); }
.tab-subtitle { font-size: 12px; color: var(--text2); margin-top: 3px; }
.tab-body { padding: 14px 14px 20px; }

/* --- Barre de navigation --- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  padding-top: 8px;
  z-index: 100;
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 10px;
  padding: 0 4px;
  transition: color .15s;
}
.nav-btn i { font-size: 22px; }
.nav-btn.active { color: var(--accent); }

/* --- Modale --- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(65,36,2,0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  width: 100%;
  max-width: 600px;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  max-height: 90vh;
  overflow-y: auto;
  padding: 0 0 24px;
}
.modal-handle { width: 36px; height: 4px; background: var(--border2); border-radius: 2px; margin: 10px auto 14px; }

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 300;
  white-space: nowrap;
  opacity: 1;
  transition: opacity .3s;
}
.toast.hidden { display: none; }

/* --- Utilitaires --- */
.hidden { display: none !important; }
.card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px; margin-bottom: 10px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 5px; font-size: 11px; font-weight: 500; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-accent { background: var(--bg3); color: var(--accent); }

/* --- Thème Système (suit les préférences OS) --- */
body.theme-systeme {
  --bg:        #FFFDF8;
  --bg2:       #FAEEDA;
  --bg3:       #FAECE7;
  --accent:    #993C1D;
  --accent2:   #BA7517;
  --accent3:   #993556;
  --green:     #0F6E56;
  --green-bg:  #E1F5EE;
  --red:       #A32D2D;
  --red-bg:    #FCEBEB;
  --text:      #412402;
  --text2:     #854F0B;
  --text3:     #B4B2A9;
  --border:    #F0997B33;
  --border2:   #F0997B;
  --shadow:    rgba(65,36,2,0.12);
  --radius:    10px;
  --radius-lg: 16px;
  --nav-h:     68px;
}

@media (prefers-color-scheme: dark) {
  body.theme-systeme {
    --bg:        #1C1C1E;
    --bg2:       #2C2C2E;
    --bg3:       #3A3A3C;
    --accent:    #FF6B4A;
    --accent2:   #FFB340;
    --accent3:   #FF375F;
    --green:     #30D158;
    --green-bg:  #1C3A28;
    --red:       #FF453A;
    --red-bg:    #3A1C1C;
    --text:      #F2F2F7;
    --text2:     #AEAEB2;
    --text3:     #636366;
    --border:    rgba(255,255,255,0.08);
    --border2:   rgba(255,255,255,0.2);
    --shadow:    rgba(0,0,0,0.3);
    --radius:    10px;
    --radius-lg: 16px;
    --nav-h:     68px;
  }
}

/* --- Modale plein écran (fiches de lieu) --- */
.modal-box.plein { height: 90vh; max-height: 90vh; padding-bottom: 0; }
.fiche-hero { position: relative; width: 100%; height: 220px; background: linear-gradient(135deg, #993C1D, #BA7517); border-radius: 20px 20px 0 0; overflow: hidden; flex-shrink: 0; }
.fiche-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fiche-skeleton { background: linear-gradient(90deg, var(--bg2) 25%, var(--bg3) 50%, var(--bg2) 75%); background-size: 200% 100%; animation: fiche-shimmer 1.2s infinite; border-radius: 8px; }
@keyframes fiche-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
