/* ============================================================
    QIBLA – MODULE PREMIUM (Ajusté pour Leaflet)
    Thème : Emerald / Gold | Version Intégrale Optimisée
============================================================ */

/* ============================================================
    HEADER : STYLE GLASS PANEL (HARMONISÉ)
============================================================ */
.glass-panel.main-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 70px;
  background: rgba(6, 34, 24, 0.95);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border-bottom: 2px solid var(--mp-gold, #b08d57);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 2000;
  box-sizing: border-box;
}

.header-spacer {
  height: 70px; /* Aligné sur la hauteur du header */
}

.navigation-top,
.header-actions-right {
  flex: 1;
  display: flex;
  align-items: center;
}

.header-actions-right {
  justify-content: flex-end;
}

.header-center-content {
  flex: 0 1 auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ============================================================
    BOUTONS : MAISON ET REFRESH (SYMÉTRIE)
============================================================ */
.floating-back-btn,
.action-icon-btn {
  width: 45px;
  height: 45px;
  background: rgba(176, 141, 87, 0.1);
  border: 1px solid rgba(176, 141, 87, 0.3);
  border-radius: 12px;
  color: #f1d5a9;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.floating-back-btn:hover,
.action-icon-btn:hover {
  background: #b08d57;
  color: #062218 !important;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(176, 141, 87, 0.4);
}

.floating-back-btn span {
  display: none;
}

/* ============================================================
    EN-TÊTE : TITRE ET LOGO BOUSSOLE
============================================================ */
.hero-intro-section {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

.header-main-title {
  font-family: "Poppins", sans-serif;
  font-size: clamp(1.3rem, 5vw, 1.9rem);
  font-weight: 800;
  margin: 0;
  color: #ffffff;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.moon-logo {
  font-size: 2.2rem;
  background: linear-gradient(180deg, #f1d388 20%, #b08d57 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 15px rgba(176, 141, 87, 0.5));
  display: flex;
  align-items: center;
}

/* ============================================================
    CONTENU : TEXTE SACRÉ ET TRADUCTION
============================================================ */
.header-subtext {
  text-align: center;
  margin: 5px auto 25px;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.arabic-title {
  font-family: "Amiri", serif;
  font-size: clamp(2.5rem, 10vw, 3.5rem);
  color: #f1d5a9;
  margin: 0;
  filter: drop-shadow(0 0 15px rgba(176, 141, 87, 0.4));
  line-height: 1.2;
}

.sub-divider {
  width: 100px;
  height: 1px;
  background: linear-gradient(90deg, transparent, #b08d57, transparent);
  margin: 5px 0 12px;
}

.french-translation {
  font-family: "Poppins", sans-serif;
  font-size: clamp(1rem, 3vw, 1.2rem);
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 15px;
  max-width: 90%;
  line-height: 1.4;
}

/* =========================
    STRUCTURE GÉNÉRALE
========================= */
.qibla-content-wrapper {
  max-width: 520px;
  margin: 0 auto;
  padding-bottom: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

/* =========================
    CARTES ANGLES
========================= */
.qibla-info-grid {
  width: 100%;
  padding: 25px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(176, 141, 87, 0.2);
  border-radius: 24px;
  backdrop-filter: blur(12px);
  box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.02);
}

.info-card {
  flex: 1;
  text-align: center;
}

.card-icon {
  font-size: 1.3rem;
  color: #b08d57;
  margin-bottom: 8px;
  opacity: 0.9;
}

.card-data .value {
  font-size: 2.8rem;
  font-weight: 900;
  color: #b08d57;
  line-height: 1;
  text-shadow: 0 0 15px rgba(176, 141, 87, 0.3);
}

.card-data .label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 5px;
  display: block;
}

.divider-gold {
  width: 1px;
  height: 60px;
  background: linear-gradient(to bottom, transparent, #b08d57, transparent);
  opacity: 0.5;
}

/* =========================
    MAP QIBLA & MARQUEURS
========================= */
.qibla-map-container {
  width: 100%;
  height: 250px;
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid rgba(176, 141, 87, 0.3);
  background: #062218;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

#qibla-map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* AGRANDISSEMENT LOGO KAABA DANS LA MAP */
.kaaba-marker-icon {
  font-size: 2.5rem !important; /* Taille augmentée */
  color: #b08d57;
  text-shadow: 0 0 15px rgba(176, 141, 87, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
}

.map-header {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.loc-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  padding: 8px 16px;
  border-radius: 100px;
  background: rgba(6, 34, 24, 0.85);
  border: 1px solid #b08d57;
  color: #fff;
  backdrop-filter: blur(6px);
}

/* ============================================================
    BOUTON D'ACTIVATION / CALIBRATION (ÉDITION LUXE)
============================================================ */
.mini-calibrate-btn {
  width: 55px; /* Un peu plus grand pour l'aspect "instrument" */
  height: 55px;
  /* Fond dégradé imitant le métal précieux */
  background: radial-gradient(
    circle at center,
    #1a4a35 0%,
    var(--emerald-dark) 100%
  );
  border: 2px solid var(--gold);
  border-radius: 50%;
  color: var(--gold);
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5),
    inset 0 0 10px rgba(176, 141, 87, 0.3);
  overflow: hidden;
  z-index: 10;
}

/* Effet de reflet rotatif (Simule l'or brossé) */
.mini-calibrate-btn::after {
  content: "";
  position: absolute;
  inset: -50%;
  background: conic-gradient(
    from 0deg,
    transparent 0%,
    rgba(255, 215, 0, 0.1) 15%,
    transparent 30%,
    transparent 100%
  );
  animation: rotateReflet 4s linear infinite;
  pointer-events: none;
}

/* Style de l'icône */
.mini-calibrate-btn i {
  z-index: 2;
  filter: drop-shadow(0 0 8px var(--gold-glow));
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- INTERACTIONS --- */

.mini-calibrate-btn:hover {
  transform: scale(1.1);
  border-color: var(--gold-bright);
  box-shadow: 0 12px 25px rgba(0, 0, 0, 0.6), 0 0 15px var(--gold-glow);
}

/* Effet de clic physique */
.mini-calibrate-btn:active {
  transform: scale(0.92);
  background: var(--emerald-dark);
}

/* Animation de rotation de l'icône au clic */
.mini-calibrate-btn:active i {
  transform: rotate(180deg);
}

/* --- NOUVELLES ANIMATIONS --- */

@keyframes rotateReflet {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Animation optionnelle si tu ajoutes .loading via JS */
.mini-calibrate-btn.loading i {
  animation: spinIcon 1s infinite linear;
}

@keyframes spinIcon {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* =========================
    BOUSSOLE PREMIUM
========================= */
.compass-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
  padding: 20px 0;
}

#qibla-display {
  /* Taille adaptative : min 240px, idéal 60vw, max 380px */
  width: clamp(240px, 60vw, 380px);
  height: clamp(240px, 60vw, 380px);
  border-radius: 50%;
  position: relative;
  background: radial-gradient(
      circle,
      rgba(20, 80, 55, 0.4),
      rgba(5, 20, 15, 0.9)
    ),
    url("../image/Qibla_img.jpg");
  background-size: cover;
  background-position: center;
  border: 8px solid #05140f;
  box-shadow: 0 0 0 2px rgba(176, 141, 87, 0.5),
    inset 0 0 80px rgba(0, 0, 0, 0.8), 0 25px 50px rgba(0, 0, 0, 0.6);
  /* Suppression de transition "all" pour éviter les lags JS */
  transition: transform 0.1s cubic-bezier(0.1, 0, 0.2, 1);
  will-change: transform;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate3d(0, 0, 0); /* Force GPU */
}

/* Points Cardinaux */
.cardinal-points span {
  position: absolute;
  font-weight: 900;
  font-size: clamp(1rem, 4vw, 1.3rem);
  color: #ffffff;
  text-shadow: 0 0 10px rgba(0, 0, 0, 1);
  z-index: 2;
}

.cardinal-points .n {
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  color: #ff4d4d;
}
.cardinal-points .s {
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
}
.cardinal-points .e {
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
}
.cardinal-points .w {
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
}

/* Groupe Aiguille - Optimisé pour la réactivité */
.qibla-pointer-group {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  pointer-events: none;
  /* Réduction à 0.15s pour que l'aiguille suive ton mouvement en temps réel */
  transition: transform 0.15s cubic-bezier(0.1, 0, 0.2, 1);
  will-change: transform;
}

.arrow-gold {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  /* Taille de l'aiguille proportionnelle */
  transform: translate(-50%, -100%);
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-bottom: clamp(100px, 25vw, 140px) solid #b08d57;
  filter: drop-shadow(0 0 10px rgba(176, 141, 87, 0.8));
  transition: border-bottom-color 0.4s ease, filter 0.4s ease;
}

/* Alignement Réussi (JS ajoute .aligned au badge) */
.status-badge-premium.aligned ~ .compass-section .arrow-gold {
  border-bottom-color: #2ecc71 !important;
  filter: drop-shadow(0 0 20px rgba(46, 204, 113, 0.9));
}

.kaaba-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 55px;
  height: 55px;
  background: #b08d57;
  border: 4px solid #062218;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(176, 141, 87, 0.6);
  z-index: 10;
  color: #062218;
  font-size: 1.4rem;
}

/* =========================
    STATUT & FOOTER
========================= */
.status-badge-premium {
  margin: 20px auto;
  padding: 12px 28px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  background: rgba(6, 34, 24, 0.8);
  border: 1px solid rgba(176, 141, 87, 0.4);
  border-radius: 100px;
  color: #fff;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
  display: inline-block;
  transition: all 0.3s ease;
}

.status-badge-premium.aligned {
  background: rgba(46, 204, 113, 0.2);
  border-color: #2ecc71;
  color: #2ecc71;
  box-shadow: 0 0 20px rgba(46, 204, 113, 0.3);
}

.qibla-nav-footer {
  width: 95%;
  max-width: 500px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 20px auto;
}

.nav-btn {
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.nav-btn.active {
  background: rgba(176, 141, 87, 0.15);
  border-color: #b08d57;
  color: #b08d57;
  transform: translateY(-2px);
}

/* ============================================================
    AR MODE (RÉALITÉ AUGMENTÉE - ÉDITION PROFESSIONNELLE)
============================================================ */

/* 1. LA VIDÉO (Arrière-plan) */
#ar-video {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -1;
  display: none;
  /* Effet de filtre pour faire ressortir l'UI Gold */
  filter: brightness(0.7) contrast(1.2);
}

/* 2. LE HUD (Interface de visée) */
#ar-controls {
  position: fixed;
  inset: 0;
  z-index: 2001;
  pointer-events: none;
  display: none;
  /* Grille de scan subtile */
  background: radial-gradient(circle, transparent 20%, rgba(0, 0, 0, 0.3) 100%);
}

/* VISEUR CENTRAL HI-TECH */
#ar-controls::after,
#ar-controls::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
}

/* Cercle extérieur pulsant */
#ar-controls::after {
  width: 120px;
  height: 120px;
  border: 1px solid var(--gold);
  border-style: dashed;
  animation: ar-spin 10s linear infinite;
  opacity: 0.5;
}

/* Point central de précision */
#ar-controls::before {
  width: 10px;
  height: 10px;
  background: var(--gold-bright);
  box-shadow: 0 0 15px var(--gold-glow);
  animation: ar-blink 1s infinite alternate;
}

/* CROIX DE VISÉE (Lignes horizontales et verticales) */
.ar-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 250px;
  height: 250px;
  pointer-events: none;
}

.ar-crosshair::before,
.ar-crosshair::after {
  content: "";
  position: absolute;
  background: var(--gold);
  opacity: 0.3;
}

.ar-crosshair::before {
  top: 50%;
  left: 0;
  width: 100%;
  height: 1px;
} /* Ligne H */
.ar-crosshair::after {
  left: 50%;
  top: 0;
  width: 1px;
  height: 100%;
} /* Ligne V */

/* 3. BOUTON FERMER (REPOSITIONNÉ ET PREMIUM) */
.close-ar-btn {
  position: absolute;
  top: 100px; /* Descendu pour éviter la barre de tâche */
  right: 20px;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.6);
  color: var(--gold);
  border: 1px solid var(--gold);
  padding: 10px 20px;
  border-radius: 30px;
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
  z-index: 2100;
}

.close-ar-btn:hover {
  background: var(--gold);
  color: #062218; /* Emerald dark pour le contraste au survol */
  transform: translateY(-2px);
}

.close-ar-btn i {
  font-size: 1rem;
}

/* 4. ANIMATIONS */
@keyframes ar-spin {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

@keyframes ar-blink {
  from {
    opacity: 0.4;
    transform: translate(-50%, -50%) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
  }
}

/* TEXTE D'INSTRUCTION AR */
.ar-instruction {
  position: absolute;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 0.75rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  text-align: center;
  width: 85%;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
  opacity: 0.9;
  font-weight: 600;
}

/* ============================================================ */
/* RESPONSIVE UNIFIÉ (ADAPTATION TOUS ÉCRANS)                   */
/* ============================================================ */

/* --- Tablettes et écrans larges --- */
@media (min-width: 1024px) {
  .qibla-content-wrapper {
    max-width: 800px;
    gap: 40px;
  }
}

/* --- Mobile Standard (iPhone, Android) --- */
@media (max-width: 600px) {
  .compass-section {
    padding: 10px 0;
  }

  .status-badge-premium {
    padding: 10px 20px;
    font-size: 0.65rem;
    margin-top: 15px;
  }

  .nav-btn {
    padding: 12px;
    font-size: 0.8rem;
  }

  /* Positionnement ajusté pour le header mobile */
  .close-ar-btn {
    top: 90px;
    right: 15px;
    padding: 10px 18px;
  }

  .header-main-title {
    font-size: 1.4rem;
  }

  .arabic-title {
    font-size: 2.8rem;
  }
}

/* --- Petits Mobiles (iPhone SE, etc.) --- */
@media (max-width: 360px) {
  .qibla-nav-footer {
    gap: 10px;
  }

  .nav-btn span {
    font-size: 0.7rem;
  }

  .qibla-info-grid {
    padding: 15px 10px;
  }

  .card-data .value {
    font-size: 2.2rem;
  }

  #qibla-display {
    width: 230px;
    height: 230px;
  }
}

/* --- Mode Paysage (Landscape) - Optimisation de l'espace vertical --- */
@media (max-height: 550px) and (orientation: landscape) {
  .header-spacer,
  .glass-panel.main-header {
    height: 60px;
  }

  .compass-section {
    padding: 0;
  }

  #qibla-display {
    width: 180px;
    height: 180px;
  }

  .status-badge-premium {
    margin: 10px auto;
    padding: 5px 15px;
  }

  .french-translation {
    margin-bottom: 5px;
    font-size: 0.9rem;
  }

  .close-ar-btn {
    top: 20px;
    padding: 8px 16px;
  }

  .ar-instruction {
    bottom: 20px;
  }
}

/* --- Gestion des encoches (Notch) pour iPhone X et + --- */
@supports (padding: env(safe-area-inset-top)) {
  .glass-panel.main-header {
    padding-top: env(safe-area-inset-top);
    height: calc(70px + env(safe-area-inset-top));
  }

  .header-spacer {
    height: calc(70px + env(safe-area-inset-top));
  }

  .close-ar-btn {
    top: calc(100px + env(safe-area-inset-top));
  }
}
