/* ==========================================
   HEARO - JOIN ROOM CSS (VERSION ULTRA-COMPACTE)
   Optimisé spécifiquement pour Galaxy S3 360x640
   ========================================== */

/* ==========================================
   1. VARIABLES & RESET
   ========================================== */
:root {
  --primary-color: #ffbe4d;
  --secondary-color: #e6a927;
  --tertiary-color: #b37700;
  --accent-color: #ffdb84;
  --neon-glow: 0 0 5px var(--primary-color), 0 0 15px var(--primary-color);
  --text-color: #ffffff;
  --bg-color: #0a0a12;
  --panel-bg: #12121f;
  --home-bg: #ffd8a6;
  --nav-height: 100px;
}

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

html {
  height: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================
   2. BODY - Layout principal
   ========================================== */
body {
  background-color: var(--home-bg);
  color: var(--text-color);
  font-family: 'Montserrat', 'Segoe UI', sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 15px 15px calc(var(--nav-height) + 15px);
  overflow-x: hidden;
  position: relative;
}

/* ==========================================
   3. PANEL HEADER - Conteneur principal
   ========================================== */
.panel-header {
  background: rgba(23, 25, 35, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 20px 25px;
  width: 100%;
  max-width: 420px; 
  max-height: calc(100vh - var(--nav-height) - 40px);
  max-height: calc(100dvh - var(--nav-height) - 40px);
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 15px;
  animation: panelSlideIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  margin: auto;
}

.panel-header::-webkit-scrollbar {
  width: 6px;
}

.panel-header::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
}

.panel-header::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 10px;
}

.panel-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
  opacity: 0.6;
}

@keyframes panelSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.panel-header h1 {
  font-size: clamp(1.4rem, 5vw, 1.8rem);
  font-weight: 600;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color), var(--tertiary-color), var(--accent-color));
  background-size: 300%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-align: center;
  width: 100%;
  animation: gradientShift 6s ease infinite;
  user-select: none;
  margin-bottom: 5px;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.scene-toggle {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.scene-toggle label {
  color: var(--text-color);
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: -8px;
}

.input {
  width: 100%;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  color: white;
  font-size: 0.95rem;
  outline: none;
  transition: all 0.3s ease;
}

.input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 12px rgba(255, 190, 77, 0.4);
  background: rgba(255, 255, 255, 0.12);
}

#avatarDisplay {
  font-size: 60px;
  cursor: pointer;
  margin: 8px auto;
  width: 85px;
  height: 85px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 3px solid var(--primary-color);
  transition: all 0.3s ease;
}

#avatarDisplay:hover {
  transform: scale(1.08);
  box-shadow: 0 0 20px rgba(255, 190, 77, 0.6);
  border-color: var(--accent-color);
}

#avatarDisplay:active {
  transform: scale(1.02);
}

.scene-btn,
#joinBtn,
#chooseTeamBtn {
  background: linear-gradient(145deg, var(--primary-color), var(--secondary-color));
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  color: white;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  box-shadow: 
    0 6px 0 var(--tertiary-color), 
    0 10px 20px rgba(0, 0, 0, 0.3);
  transition: all 0.15s ease;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  position: relative;
}

.scene-btn:hover,
#joinBtn:hover,
#chooseTeamBtn:hover {
  box-shadow: 
    0 4px 0 var(--tertiary-color), 
    0 8px 16px rgba(0, 0, 0, 0.3);
  transform: translateY(2px);
}

.scene-btn:active,
#joinBtn:active,
#chooseTeamBtn:active {
  box-shadow: 
    0 2px 0 var(--tertiary-color), 
    0 4px 8px rgba(0, 0, 0, 0.3);
  transform: translateY(4px);
}

.scene-btn:disabled,
#chooseTeamBtn:disabled {
  background: linear-gradient(145deg, #666, #555);
  box-shadow: 0 4px 0 #333, 0 8px 16px rgba(0, 0, 0, 0.2);
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

.scene-btn:disabled:hover,
#chooseTeamBtn:disabled:hover {
  transform: none;
}

/* ==========================================
   12. MODALS (Avatar, Edit Profile, Create Room)
   ========================================== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
  overflow-y: auto;
}

.modal-content {
  background: rgba(26, 26, 46, 0.95);
  border-radius: 20px;
  padding: 25px;
  width: 100%;
  max-width: 450px;
  max-height: 85vh;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6);
  position: relative;
  animation: modalPop 0.3s ease-out;
}

@keyframes modalPop {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-content h2 {
  font-size: 1.6rem;
  font-weight: 600;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color), var(--tertiary-color), var(--accent-color));
  background-size: 300%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-align: center;
  width: 100%;
  margin-bottom: 20px;
  animation: gradientShift 6s ease infinite;
}

/* Inputs dans les modales */
.modal-content input.input {
  width: 100%;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  color: white;
  font-size: 0.95rem;
  outline: none;
  margin-bottom: 15px;
  transition: all 0.3s ease;
}

.modal-content input.input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.modal-content input.input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 15px rgba(94, 155, 255, 0.4);
  background: rgba(255, 255, 255, 0.12);
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr); /* ← Changé de 6 à 5 colonnes par défaut pour mobile */
  gap: 10px; /* ← Réduit de 12px à 10px */
  width: 100%;
  margin: 15px 0;
  padding: 0 5px; /* ← Ajouté pour éviter le débordement */
}

.avatar-option {
  font-size: 32px; /* ← Réduit de 36px */
  width: 50px; /* ← Réduit de 55px */
  height: 50px; /* ← Réduit de 55px */
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid transparent;
  transition: all 0.3s ease;
}

.avatar-option:hover {
  transform: scale(1.15);
  background: rgba(94, 155, 255, 0.2);
  border-color: var(--primary-color);
  box-shadow: 0 0 15px rgba(94, 155, 255, 0.4);
}

.avatar-option.selected {
  background: rgba(94, 155, 255, 0.3);
  border-color: var(--primary-color);
  box-shadow: 0 0 12px rgba(94, 155, 255, 0.5);
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--nav-height);
  background: #0d0d1c;
  display: flex;
  justify-content: center;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom, 5px);
  z-index: 999;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
}

.nav-group {
  display: flex;
  gap: 40px;
  align-items: center;
}

.nav-item {
  text-decoration: none;
  text-align: center;
  font-size: 13px;
  color: #cdd2ff;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
}

.nav-item:active {
  transform: scale(0.95);
}

.buzzer {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: white;
  box-shadow: 
    0 6px 0 rgba(0, 0, 0, 0.4), 
    0 8px 16px rgba(0, 0, 0, 0.6), 
    inset 0 3px 8px rgba(255, 255, 255, 0.3);
  transition: all 0.1s ease;
  border: 3px solid rgba(255, 255, 255, 0.5);
}

.buzzer:active {
  transform: translateY(4px);
  box-shadow: 
    0 2px 0 rgba(0, 0, 0, 0.4), 
    0 4px 10px rgba(0, 0, 0, 0.6), 
    inset 0 2px 4px rgba(255, 255, 255, 0.3);
}

.buzzer-logout { background: linear-gradient(145deg, #ff5c8a, #e04670); }
.buzzer-join { background: linear-gradient(145deg, #ffbe4d, #e6a927); }
.buzzer-create { background: linear-gradient(145deg, #45d67f, #3bc06b); }
.buzzer-prof { background: linear-gradient(145deg, #5e9bff, #4a87eb); }

.nav-item.active {
  color: #FFD700;
}

.nav-item.active .buzzer {
  border-color: #FFD700;
  box-shadow: 
    0 6px 0 rgba(0, 0, 0, 0.4), 
    0 8px 20px rgba(255, 215, 0, 0.4), 
    inset 0 3px 8px rgba(255, 255, 255, 0.4);
}

/* ==========================================
   MEDIA QUERIES - GALAXY S3 OPTIMIZED
   ========================================== */

/* Galaxy S3 360x640 - ULTRA COMPACT */
@media (max-width: 360px) {
  :root {
    --nav-height: 95px;  /* ← Réduit de 105px */
  }

  body {
    padding: 5px 10px calc(var(--nav-height) + 5px);  /* ← Réduit de 10px */
    justify-content: flex-start;
  }

  .panel-header {
    padding: 15px 18px;  /* ← Réduit de 18px 20px */
    border-radius: 18px;
    gap: 8px;  /* ← Réduit de 10px */
    max-height: calc(100vh - var(--nav-height) - 15px);  /* ← Changé de 25px */
    max-height: calc(100dvh - var(--nav-height) - 15px);
    margin-top: 0;  /* ← Supprimé les 5px */
  }

  .panel-header h1 {
    font-size: 1.35rem;
    margin-bottom: 2px;
  }

  .scene-toggle {
    gap: 8px;  /* ← Réduit de 10px */
  }

  .scene-toggle label {
    font-size: 0.85rem;
    margin-bottom: -6px;
  }

  .input {
    padding: 9px 11px;
    font-size: 0.9rem;
  }

  #avatarDisplay {
    width: 70px;  /* ← Réduit de 75px */
    height: 70px;
    font-size: 48px;  /* ← Réduit de 50px */
    margin: 5px auto;  /* ← Réduit de 6px */
  }

  .scene-btn,
  #joinBtn,
  #chooseTeamBtn {
    padding: 10px 15px;  /* ← Réduit de 11px 16px */
    font-size: 0.9rem;
    box-shadow: 
      0 5px 0 var(--tertiary-color), 
      0 8px 16px rgba(0, 0, 0, 0.3);
  }

  .avatar-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 9px;
    padding: 0 4px;
  }
  
  .avatar-option {
    width: 42px;
    height: 42px;
    font-size: 26px;
  }
  .team-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .team-palette {
    width: 55px;
    height: 55px;
  }

  .nav-group {
    gap: 22px;  /* ← Réduit de 28px */
  }

  .buzzer {
    width: 48px;  /* ← Réduit de 52px */
    height: 48px;
    font-size: 17px;  /* ← Réduit de 19px */
  }

  .nav-item {
    font-size: 11px;
  }
}

/* iPhone SE 320px */
@media (max-width: 320px) {
  :root {
    --nav-height: 90px;
  }

  body {
    padding: 3px 8px calc(var(--nav-height) + 3px);
  }

  .panel-header {
    padding: 12px 15px;
    gap: 6px;
  }

  .panel-header h1 {
    font-size: 1.25rem;
  }

  .scene-toggle {
    gap: 6px;
  }

  .input {
    padding: 8px 10px;
    font-size: 0.85rem;
  }

  #avatarDisplay {
    width: 65px;
    height: 65px;
    font-size: 42px;
  }

  .scene-btn,
  #joinBtn,
  #chooseTeamBtn {
    padding: 9px 14px;
    font-size: 0.85rem;
  }

  .nav-group {
    gap: 18px;
  }

  .buzzer {
    width: 45px;
    height: 45px;
    font-size: 16px;
  }

  .nav-item {
    font-size: 10px;
  }

  .avatar-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 0 3px;
  }
  
  .avatar-option {
    width: 38px;
    height: 38px;
    font-size: 24px;
  }
}

/* Petits mobiles 361-428px */
@media (min-width: 361px) and (max-width: 428px) {
  .panel-header {
    max-width: 92%;
  }
  
  .avatar-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    padding: 0 5px;
  }
  
  .avatar-option {
    width: 48px;
    height: 48px;
    font-size: 30px;
  }  
}

/* Écrans bas */
@media (max-height: 700px) {
  body {
    padding-top: 12px;
  }

  .panel-header {
    padding: 18px 22px;
    gap: 12px;
  }
  
  .avatar-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 15px;
    padding: 0;
  }
  
  .avatar-option {
    width: 60px;
    height: 60px;
    font-size: 38px;
  } 

  #avatarDisplay {
    margin: 6px auto;
  }
}

/* Paysage mobile */
@media (max-height: 500px) and (orientation: landscape) {
  :root {
    --nav-height: 85px;
  }

  body {
    padding: 8px 15px calc(var(--nav-height) + 8px);
  }

  .panel-header {
    padding: 12px 18px;
    gap: 8px;
    max-height: calc(100vh - var(--nav-height) - 20px);
  }

  .scene-toggle {
    gap: 8px;
  }

  #avatarDisplay {
    width: 65px;
    height: 65px;
    font-size: 40px;
    margin: 4px auto;
  }

  .avatar-grid {
    grid-template-columns: repeat(8, 1fr); /* Plus de colonnes en mode paysage */
    gap: 8px;
    padding: 0 5px;
  }
  
  .avatar-option {
    width: 38px;
    height: 38px;
    font-size: 22px;
  }

  .nav-group {
    gap: 30px;
  }

  .buzzer {
    width: 45px;
    height: 45px;
    font-size: 16px;
  }

  .nav-item {
    font-size: 10px;
  }

  .scene-btn,
  #joinBtn,
  #chooseTeamBtn {
    padding: 9px 14px;
    font-size: 0.85rem;
  }
}

/* Tablettes et grands écrans */
@media (min-width: 768px) {
  body {
    padding: 30px 30px calc(var(--nav-height) + 30px);
  }

  .panel-header {
    max-width: 420px;
    padding: 30px 35px;
    gap: 18px;
  }

  .scene-toggle {
    gap: 15px;
  }

  #avatarDisplay {
    width: 100px;
    height: 100px;
    font-size: 70px;
  }

  .input {
    padding: 12px 15px;
    font-size: 1rem;
  }

  .scene-btn,
  #joinBtn,
  #chooseTeamBtn {
    padding: 14px 20px;
    font-size: 1rem;
  }

   .modal-content {
        max-width: 540px !important;
    }
	
  .avatar-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 15px;
    padding: 0;
  }
  
  .avatar-option {
    width: 60px;
    height: 60px;
    font-size: 38px;
  }
}

/* Grands écrans Desktop */
@media (min-width: 1024px) {
    .panel-header {
        max-width: 540px;
    }

    .modal-content {
        max-width: 600px !important;
    }
}

@supports not (backdrop-filter: blur(10px)) {
  .panel-header {
    background: rgba(23, 25, 35, 0.98);
  }

  .modal {
    background: rgba(0, 0, 0, 0.9);
  }
}

@media (display-mode: fullscreen), (display-mode: standalone) {
  body {
    padding-top: max(15px, env(safe-area-inset-top));
  }

  .bottom-nav {
    padding-bottom: max(5px, env(safe-area-inset-bottom));
  }
}
