/* ============================================================================
   shell.css — Unified stylesheet for Flanders Portales (docs, help, induction)
   Matches the premium look & feel of the Flanders Design System (BRAND.md)
   ============================================================================ */

/* Theme variables fallback if not defined by the page */
:root {
  --fl-font: 'Geist', system-ui, -apple-system, sans-serif;
  --fl-violet: #7a6cff;
  --fl-violet-hover: #6457e6;
  --fl-cta: #2563eb;
  --fl-cta-hover: #1d4ed8;
  --fl-bg-light: #ffffff;
  --fl-bg-dark: #0a0a0a;
  --fl-surface-light: #f9fafb;
  --fl-surface-dark: #111827;
  --fl-border-light: #e5e7eb;
  --fl-border-dark: #374151;
  --fl-text-light: #171717;
  --fl-text-dark: #ededed;
  --fl-text-secondary-light: #6b7280;
  --fl-text-secondary-dark: #9ca3af;
  --fl-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --fl-backdrop: rgba(10, 10, 10, 0.7);
}

/* Loading & Login Screens Wrapper */
.fl-overlay-container {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--fl-font);
  background: var(--fl-bg-light);
  color: var(--fl-text-light);
  transition: opacity 0.3s ease;
}

html[data-theme="dark"] .fl-overlay-container {
  background: var(--fl-bg-dark);
  color: var(--fl-text-dark);
}

/* Loading Screen */
.fl-loading-content {
  text-align: center;
}

.fl-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--fl-border-light);
  border-top-color: var(--fl-violet);
  border-radius: 50%;
  animation: fl-spin 1s linear infinite;
  margin: 0 auto 16px;
}

html[data-theme="dark"] .fl-spinner {
  border-color: var(--fl-border-dark);
  border-top-color: var(--fl-violet);
}

/* Loading mark: Infracommerce isologo inside a spinning ring (Flanders look) */
.fl-loader {
  position: relative;
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
}

.fl-loader .fl-loader-ring {
  position: absolute;
  inset: 0;
  border: 3px solid var(--fl-border-light);
  border-top-color: var(--fl-violet);
  border-radius: 50%;
  animation: fl-spin 1s linear infinite;
}

html[data-theme="dark"] .fl-loader .fl-loader-ring {
  border-color: var(--fl-border-dark);
  border-top-color: var(--fl-violet);
}

.fl-loader .fl-loader-logo {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  display: block;
  object-fit: contain;
}

@keyframes fl-spin {
  to { transform: rotate(360deg); }
}

/* Login Card style */
.fl-login-card {
  width: 100%;
  max-width: 420px;
  padding: 32px;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid var(--fl-border-light);
  box-shadow: var(--fl-shadow);
  text-align: center;
  animation: fl-fade-up 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

html[data-theme="dark"] .fl-login-card {
  background: var(--fl-surface-dark);
  border-color: var(--fl-border-dark);
}

@keyframes fl-fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.fl-logo-glow {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: block;
  object-fit: contain;
  box-shadow: 0 0 16px rgba(122, 108, 255, 0.4);
  margin: 0 auto 24px;
}

.fl-login-card h2 {
  font-size: 24px;
  font-weight: 800;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
  color: var(--fl-text-light);
}

html[data-theme="dark"] .fl-login-card h2 {
  color: var(--fl-text-dark);
}

.fl-login-card p {
  font-size: 14px;
  color: var(--fl-text-secondary-light);
  margin: 0 0 24px;
}

html[data-theme="dark"] .fl-login-card p {
  color: var(--fl-text-secondary-dark);
}

/* Google Sign-in Button */
.fl-btn-google {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 24px;
  border-radius: 12px;
  border: 1px solid var(--fl-border-light);
  background: #ffffff;
  color: #374151;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

html[data-theme="dark"] .fl-btn-google {
  background: #111827;
  border-color: var(--fl-border-dark);
  color: #ededed;
}

.fl-btn-google:hover {
  background: #f9fafb;
  transform: translateY(-1px);
}

html[data-theme="dark"] .fl-btn-google:hover {
  background: #1f2937;
}

.fl-btn-google svg {
  width: 18px;
  height: 18px;
}

/* Blocked screen (e.g. Induction Core Team gate) */
.fl-blocked-card {
  width: 100%;
  max-width: 480px;
  padding: 32px;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid #fee2e2;
  box-shadow: var(--fl-shadow);
  text-align: center;
  animation: fl-fade-up 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

html[data-theme="dark"] .fl-blocked-card {
  background: var(--fl-surface-dark);
  border-color: #7f1d1d;
}

.fl-blocked-card h2 {
  font-size: 22px;
  font-weight: 800;
  color: #dc2626;
  margin: 0 0 12px;
}

html[data-theme="dark"] .fl-blocked-card h2 {
  color: #f87171;
}

/* Blocked-card body copy needs an explicit color: without one it inherits the
   page body color, which on a hardcoded-dark login page (#ededed) collides with
   the card's light surface → invisible. Mirror the .fl-login-card p pattern. */
.fl-blocked-card p {
  color: var(--fl-text-light);
}

html[data-theme="dark"] .fl-blocked-card p {
  color: var(--fl-text-dark);
}

/* Context selector drop-down in topbar */
.fl-context-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
  margin-left: 16px;
}

.fl-context-picker:hover {
  background: var(--border);
}

.fl-context-picker .arrow {
  margin-left: 8px;
  width: 12px;
  height: 12px;
  transition: transform 0.2s ease;
}

.fl-context-picker.open .arrow {
  transform: rotate(180deg);
}

.fl-context-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 100;
  min-width: 260px;
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: var(--sh-lg);
  padding: 8px;
  display: none;
}

.fl-context-menu.show {
  display: block;
}

.fl-context-menu-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  /* Light is the default; --text-faint on the white menu surface is only ~3.4:1
     (below AA for this 11px label), so use the secondary token. Dark overrides below. */
  color: var(--fl-text-secondary-light);
  padding: 6px 8px;
  letter-spacing: 0.05em;
}

/* Dark theme keeps the faint de-emphasis (--text-faint clears AA on the dark surface). */
html[data-theme="dark"] .fl-context-menu-title {
  color: var(--text-faint);
}

.fl-context-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-soft);
  text-align: left;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.fl-context-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.fl-context-item.active {
  color: var(--violet);
  background: color-mix(in srgb, var(--violet) 8%, transparent);
  font-weight: 700;
}

/* User avatar button / menu */
.fl-user-profile {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  margin-left: 8px;
}

.fl-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--fl-violet);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  border: 2px solid var(--border);
  transition: border-color 0.2s ease;
}

.fl-user-profile:hover .fl-avatar {
  border-color: var(--fl-violet);
}

.fl-user-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 100;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: var(--sh-lg);
  padding: 8px;
  display: none;
}

.fl-user-menu.show {
  display: block;
}

.fl-user-info {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.fl-user-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fl-user-email {
  font-size: 12px;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fl-menu-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  text-align: left;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.fl-menu-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.fl-menu-btn.logout-btn {
  color: var(--error);
}

.fl-menu-btn.logout-btn:hover {
  background: color-mix(in srgb, var(--error) 8%, transparent);
}

/* Redirect alert banner styled for Flanders Portales */
.fl-redirect-alert {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: color-mix(in srgb, var(--fl-violet) 10%, #fff7ed);
  border-bottom: 1px solid #ffedd5;
  color: #c2410c;
  font-family: var(--fl-font);
  font-size: 13px;
  font-weight: 500;
  animation: fl-slide-down 0.3s ease;
  z-index: 40;
}

html[data-theme="dark"] .fl-redirect-alert {
  background: #2a1b10;
  border-bottom-color: #432b18;
  color: #ff9d43;
}

/* Shared-link fallback banners (Cases 2 & 3). Reuse .fl-redirect-alert layout but
   re-tint: 'info' (Case 2 — shown in another Espacio) reads as informative (violet/
   blue); 'blocked' (Case 3 — tema not enabled anywhere) reads as a soft block (red). */
.fl-shared-link-alert.fl-alert-info {
  background: color-mix(in srgb, var(--fl-cta) 10%, #eff6ff);
  border-bottom-color: color-mix(in srgb, var(--fl-cta) 25%, transparent);
  color: #1d4ed8;
}
html[data-theme="dark"] .fl-shared-link-alert.fl-alert-info {
  background: #101a2e;
  border-bottom-color: #1e3a5f;
  color: #93c5fd;
}
.fl-shared-link-alert.fl-alert-blocked {
  background: color-mix(in srgb, var(--fl-cta) 4%, #fef2f2);
  border-bottom-color: color-mix(in srgb, #dc2626 25%, transparent);
  color: #b91c1c;
}
html[data-theme="dark"] .fl-shared-link-alert.fl-alert-blocked {
  background: #2a1212;
  border-bottom-color: #4a1e1e;
  color: #f87171;
}

.fl-alert-icon {
  font-size: 16px;
}

.fl-alert-text {
  flex: 1;
}

.fl-alert-close {
  background: transparent;
  border: none;
  color: currentColor;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.fl-alert-close:hover {
  opacity: 1;
}

@keyframes fl-slide-down {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Scroll container and favorites styles for Space Picker */
.fl-context-list {
  max-height: min(60vh, 480px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 4px;
}

.fl-context-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 8px;
  transition: all 0.15s ease;
  margin-bottom: 2px;
}

.fl-context-row:hover {
  background: var(--surface-2);
}

.fl-context-row.active {
  background: color-mix(in srgb, var(--fl-violet) 8%, transparent);
}

.fl-context-item-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  color: var(--text-soft);
  text-align: left;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: var(--fl-font);
  font-size: 13px;
  font-weight: 500;
}

html[data-theme="dark"] .fl-context-item-btn {
  color: #c5c5d2;
}

.fl-context-row.active .fl-context-item-btn {
  color: var(--fl-violet);
  font-weight: 700;
}

.fl-context-row:hover .fl-context-item-btn {
  color: var(--text);
}

.fl-context-fav-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 8px 12px;
  color: var(--text-faint);
  transition: color 0.15s ease, transform 0.1s ease;
}

.fl-context-fav-btn:hover {
  color: #fbbf24;
  transform: scale(1.15);
}

.fl-context-fav-btn.fav {
  color: #f59e0b;
}

/* Mobile responsive collapsing for top nav-bar */
.fl-mobile-ctrls {
  display: none;
  padding: 8px 4px;
}

.fl-mobile-ctrls .fl-menu-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 6px 8px;
  letter-spacing: 0.05em;
}

.fl-mobile-lang {
  display: flex;
  gap: 4px;
  padding: 4px 8px;
}

.fl-mobile-lang button {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.fl-mobile-lang button:hover {
  background: var(--border);
  color: var(--text);
}

.fl-mobile-lang button.active {
  background: var(--fl-violet);
  color: #fff;
  border-color: var(--fl-violet);
}

/* Banderas del selector mobile: SVG inline del sprite (#fl-flag-*), NO emoji —
   Windows no trae los glifos de bandera y el emoji degradaba a las 2 letras del
   país (help-#207). Los portales repiten esta regla en su <style> inline porque
   shell.css lo inyecta shell.js en runtime y el topbar no puede esperarlo.
   Ver web/shared/flags.js. */
.fl-mobile-lang .fl-flag {
  width: 1.5em;
  height: 1em;
  flex: 0 0 auto;
  display: block;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
}

.fl-mobile-font-ctrls {
  display: flex;
  gap: 4px;
  padding: 4px 8px;
}

.fl-mobile-font-ctrls button {
  flex: 1;
}

.fl-mobile-only {
  display: none;
}

/* Breakpoint "chrome/mobile" compartido = 760px. Colapsa idioma/tema/fuente al menú del
   avatar a la MISMA medida que los portales ya compactan el topbar (web/help + web/induction
   @media 760). Antes era 680 → en la banda 681–760px idioma/tema quedaban visibles y
   desbordaban la barra angosta. MANTENER EN SYNC con el 760 de help/induction. */
@media (max-width: 760px) {
  .brand-name {
    display: none !important;
  }
  
  .topbar-spacer,
  .progress-wrap {
    display: none !important;
  }

  .search-box {
    flex: 1 !important;
    min-width: 80px !important;
    max-width: 160px !important;
    margin-left: 8px !important;
    margin-right: 8px !important;
  }
  
  .ctrl-group > .lang-switch,
  .ctrl-group > #theme-toggle,
  .ctrl-group > .fontsize-ctrl {
    display: none !important;
  }

  .fl-context-picker {
    margin-left: 8px !important;
    max-width: 140px;
  }

  .fl-context-picker > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100px;
  }

  .fl-mobile-ctrls,
  .fl-mobile-only {
    display: block;
  }
}
