/* ========================================================= */
/* 🌀 COMPONENT: PRELOADER                                   */
/* --------------------------------------------------------- */
/* Evita que es vegi el contingut abans de la càrrega,       */
/* assegura compatibilitat amb navegadors i Instagram App.   */
/* ========================================================= */


/* === 1️⃣ FIX GLOBAL (Instagram + navegadors mòbils) === */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden; /* Evita veure la web per sota mentre carrega */
}

/* 🔒 Estat de càrrega actiu */
body.loading {
  overflow: hidden;
  height: 100vh;
}


/* === 2️⃣ COMPORTAMENT ASSOCIAT === */

/* Oculta la imatge del banner mentre el preloader és visible */
#preloader:not(.hidden) ~ * .banner-regal .regal-img {
  visibility: hidden;
}

/* Estil per vídeos mentre carreguen (fons segur) */
.video-container video {
  min-height: 300px;
  background: #0b1b2b;
}

/* Insígnia d’ofertes externes o destacades */
.badge-external {
  display: inline-block;
  background-color: #1e3a8a;
  color: #fff;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 4px;
}




/* === 3️⃣ COS PRINCIPAL DEL PRELOADER === */
#preloader {
  position: fixed;
  inset: 0; /* top:0; right:0; bottom:0; left:0 */
  display: flex;
  flex-direction: column; /* logo + barra */
  align-items: center;
  justify-content: center;
  background: #fff;
  width: 100%;
  height: 100%;
  z-index: 99999;
  transition: opacity 0.8s ease, visibility 0.8s ease;
  overscroll-behavior: contain; /* Evita scroll fantasma (Instagram) */
}

/* Estat ocult: transició de sortida */
#preloader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Contingut intern */
.preloader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}


/* === 4️⃣ LOGO === */
.logo-preload {
  width: 140px;
  max-width: 140px; /* evita zoom rar a navegadors integrats */
  height: auto;
  margin: 0 auto 24px;
  display: block;
}


/* === 5️⃣ BARRA DE PROGRÉS === */
.progress-bar {
  width: 200px;
  max-width: 70%;
  height: 8px;
  background: #eee;
  border-radius: 5px;
  overflow: hidden;
  margin: 0 auto;
}

.progress {
  width: 0%;
  height: 100%;
  background: #d4af37; /* daurat corporatiu */
  animation: fillProgress 4s forwards;
}

@keyframes fillProgress {
  from { width: 0%; }
  to   { width: 100%; }
}


/* === 6️⃣ RESPONSIVE === */
@media (max-width: 768px) {
  .logo-preload {
    width: 130px;
    max-width: 130px;
    margin-bottom: 20px;
  }

  .progress-bar {
    width: 180px;
    height: 7px;
  }
}

@media (max-width: 480px) {
  .logo-preload {
    width: 110px;
    max-width: 110px;
  }

  .progress-bar {
    width: 150px;
    height: 6px;
  }
}

/* ========================================================= */
/* 🦉 ANIMACIÓ MUSSOL PRELOADER + BOTÓ LATERAL               */
/* ========================================================= */

/* 1️⃣ Guinyada (blink) */
@keyframes mussolBlink {
  0%, 92%, 100% { opacity: 1; }
  94%, 96% { opacity: 0.35; }
}

/* 2️⃣ Salt lateral + desaparició */
@keyframes mussolJumpToSide {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  20% {
    transform: translateY(-14px) scale(1.05);
  }
  45% {
    transform: translateY(0) scale(0.96);
  }
  70% {
    transform: translateX(-32vw) translateY(-6px) scale(1.02);
  }
  100% {
    transform: translateX(-40vw) translateY(0);
    opacity: 0;
    scale: 1;
  }
}

/* 🎨 Assignem la guinyada al logo del preloader */
#mussol-preloader {
  animation: mussolBlink 3s infinite;
}


/* ========================================================= */
/* 🦉 BOTÓ FINAL DEL MUSSOL (APAREIX DESPRÉS DEL PRELOADER)  */
/* ========================================================= */

#mussol-boto {
  position: fixed;
  left: 22px;
  top: 42%;
  width: 88px;       /* abans 72px → ara més gran */
  height: 88px;      /* abans 72px */
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 6px 16px rgba(0,0,0,0.20);
  padding: 12px;     /* lleugerament més gran perquè l’svg respiri */
  cursor: pointer;
  display: none;
  z-index: 9999;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

#mussol-boto:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 20px rgba(0,0,0,0.28);
}


#mussol-boto img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Responsive */
@media (max-width: 768px) {
  #mussol-boto {
    left: 12px;
    width: 72px;     /* abans 60px */
    height: 72px;    /* abans 60px */
    padding: 10px;
  }
}

/*Barra lateral - ha danar a index*/

/* ========================================================= */
/* 🧩 MENÚ LATERAL BORSA DOCENT                              */
/* ========================================================= */

#sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 15, 34, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  z-index: 9998;
}

#sidebar-menu {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 280px;
  max-width: 80%;
  background: #ffffff;
  box-shadow: 3px 0 16px rgba(0,0,0,0.12);
  padding: 18px 18px 24px;
  transform: translateX(-100%);
  transition: transform 0.28s ease;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.badge-preu-eines {
  background: #1a237e;
  color: #fff;
  padding: 2px 6px;
  font-size: 0.7rem;
  border-radius: 6px;
  margin-left: 6px;
  font-weight: 600;
  white-space: nowrap;
}


.badge-alertes {
  background: #d4af37;       /* daurat corporatiu */
  color: #0e1628;            /* blau fosc */
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  min-width: 22px;
  text-align: center;
  display: inline-block;
  box-shadow: 0 2px 5px rgba(0,0,0,0.15);
  transform: translateY(-1px);
}

.badge-alertes.hidden {
  display: none !important;
}

/* === OFERTES RECOMANADES (relacionades amb especialitat) === */

.oferta-recomanada {
  border: 2px solid #d4af37 !important;
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.45);
  position: relative;
  background: linear-gradient(
    180deg,
    rgba(212, 175, 55, 0.12) 0%,
    rgba(255, 255, 255, 0.9) 45%
  );
}

/* Badge Recomanada */
.oferta-recomanada .badge-recomanada {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #1a237e; /* blau corporatiu */
  color: white;
  padding: 4px 8px;
  font-size: 0.72rem;
  border-radius: 6px;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  z-index: 20;
  display: inline-flex;
  align-items: center;
}

/* Icona + text */
.badge-recomanada::before {
  content: "⭐";
  margin-right: 4px;
  font-size: 0.85rem;
}


/* Estat obert (es posa via JS a <body>) */
body.sidebar-open #sidebar-menu {
  transform: translateX(0);
}

body.sidebar-open #sidebar-overlay {
  opacity: 1;
  visibility: visible;
}

/* Header del sidebar */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo img {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  box-shadow: 0 3px 8px rgba(0,0,0,0.15);
}

.sidebar-title {
  display: flex;
  flex-direction: column;
}

.bd-nom {
  font-weight: 700;
  font-size: 1rem;
  color: #1a237e;
}

.bd-sub {
  font-size: 0.8rem;
  color: #6b7280;
}

/* Botó tancar */
.sidebar-close {
  background: transparent;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: #111827;
}

/* Targeta regal del mes */
.sidebar-card-regal {
  background: #fef7e8;
  border-radius: 14px;
  padding: 10px 12px;
  border: 1px solid #fbbf24;
}

.regal-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #92400e;
  margin-bottom: 4px;
}

.regal-text {
  font-size: 0.86rem;
  color: #78350f;
  margin: 0;
}

.regal-cta {
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

/* Navegació */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.sidebar-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9ca3af;
  margin: 16px 0 6px;
}

.sidebar-link {
  width: 100%;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  border-radius: 10px;
  font-size: 0.92rem;
  cursor: pointer;
  color: #111827;
  text-align: left;
  transition: background 0.18s ease, transform 0.1s ease;
}

.sidebar-link span {
  flex: 1;
}

.sidebar-link:hover {
  background: #eff6ff;
  transform: translateX(2px);
}

.sidebar-link.danger {
  color: #b91c1c;
}

/* Scroll suau en mòbil */
#sidebar-menu::-webkit-scrollbar {
  width: 4px;
}
#sidebar-menu::-webkit-scrollbar-thumb {
  background: #e5e7eb;
  border-radius: 999px;
}

@media (max-width: 768px) {
  #sidebar-menu {
    width: 260px;
  }
}

/* 🔒 Estat bloquejat (usuari no logat) */
.sidebar-link.locked {
  opacity: 0.45;
  cursor: not-allowed;
  position: relative;
}

.sidebar-link.locked:hover {
  background: transparent;
  transform: none;
}

/* Icon candau 
.sidebar-link.locked::after {
  content: "🔒";
  position: absolute;
  right: 10px;
  font-size: 1rem;
}

*/

/* Tooltip “Has d’iniciar sessió” */
.sidebar-link.locked:hover::before {
  content: "Has d’iniciar sessió";
  position: absolute;
  left: 0;
  top: -22px;
  font-size: 0.75rem;
  padding: 2px 6px;
  background: #111827;
  color: #fff;
  border-radius: 4px;
  white-space: nowrap;
}

/* 🟡 ESTIL "AVIAT" (coming soon) */
.sidebar-link.coming-soon {
  opacity: 0.5;
  cursor: not-allowed;
  position: relative;
}

.sidebar-link.coming-soon:hover {
  background: transparent;
  transform: none;
}

/* Etiqueta "Aviat" */
.sidebar-link.coming-soon::after {
  content: "Aviat";
  position: absolute;
  right: 10px;
  font-size: 0.75rem;
  background: #fef3c7;
  color: #92400e;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 600;
}

/* Tooltip quan passa el ratolí */
.sidebar-link.coming-soon:hover::before {
  content: "Encara no disponible";
  position: absolute;
  left: 0;
  top: -22px;
  font-size: 0.75rem;
  padding: 2px 6px;
  background: #111827;
  color: #fff;
  border-radius: 4px;
  white-space: nowrap;
}


.hidden {
  display: none !important;
}

/* Evitem que TOTS els spans s’estirin */
.sidebar-link span {
  flex: unset !important;
}

/* Alineació professional: esquerra = icona + text, dreta = puntet */
.sidebar-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Part esquerra */
.sidebar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Part dreta (candau / puntet / aviat / buit) */
.sidebar-right {
  min-width: 20px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

/* Puntet */
.dot {
  width: 8px;
  height: 8px;
  background-color: #d4af37;
  border-radius: 50%;
  display: none;
}

.dot.visible {
  display: inline-block;
}

.sidebar-link.coming-soon::after {
  content: none !important;
}


/*Preloader*/

.preloader-branding {
  margin-top: 18px;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;

}

.preloader-branding {
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.preloader-branding.hide {
  opacity: 0;
  transform: translateY(6px);
}


/* Paraula que canvia */
#preload-action {
  color: #b8932f;              /* daurat corporatiu */
  display: inline-block;
  width: 9.5ch;                /* 🔑 clau: ample fix */
  text-align: center;           /* alinea cap a Docent */
  transition: opacity 0.35s ease, transform 0.35s ease;
}


.preload-fixed {
  color: #1a237e; /* blau BorsaDocent */
  white-space: nowrap;

}


.preloader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.preloader-branding {
  position: relative;
  z-index: 10;
}

.logo-preload {
  position: relative;
  z-index: 5;
}

.preload-fixed {
  opacity: 1 !important;
  visibility: visible !important;
}


