:root {
  --ai4-shell-height: 74px;
  --ai4-shell-bg: #ffffff;
  --ai4-shell-surface: #ffffff;
  --ai4-shell-ink: #101827;
  --ai4-shell-muted: #617183;
  --ai4-shell-line: rgba(48, 20, 102, .14);
  --ai4-shell-hover: rgba(44, 11, 105, .08);
  --ai4-shell-active: rgba(44, 11, 105, .1);
  --ai4-shell-brand-purple: #2c0b69;
  --ai4-shell-brand-blue: #1967ff;
  --ai4-shell-brand-cyan: #11b8d7;
  --ai4-shell-brand-teal: #0fa7a5;
  --ai4-shell-glow: rgba(25, 103, 255, .22);
}

body.ai4-shell-ready {
  padding-top: var(--ai4-shell-height) !important;
}

html[data-ai4-theme="dark"] {
  --ai4-shell-bg: #030813;
  --ai4-shell-surface: #07101f;
  --ai4-shell-ink: #f7fbff;
  --ai4-shell-muted: #aec0d2;
  --ai4-shell-line: rgba(190, 212, 255, .16);
  --ai4-shell-hover: rgba(255, 255, 255, .08);
  --ai4-shell-active: rgba(255, 255, 255, .11);
  --ai4-shell-glow: rgba(17, 184, 215, .25);
  color-scheme: dark;
}

.ai4-shell {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 2147483000;
  height: var(--ai4-shell-height);
  background:
    linear-gradient(90deg, rgba(44, 11, 105, .09), transparent 24%, transparent 76%, rgba(17, 184, 215, .08)),
    var(--ai4-shell-bg);
  border-bottom: 1px solid var(--ai4-shell-line);
  box-shadow: 0 10px 28px rgba(3, 8, 19, .12);
  backdrop-filter: blur(18px);
  color: var(--ai4-shell-ink);
  font-family: Inter, Segoe UI, Tahoma, Arial, sans-serif;
  box-sizing: border-box;
  overflow: visible;
}

.ai4-shell *,
.ai4-shell *::before,
.ai4-shell *::after {
  box-sizing: border-box;
}

.ai4-shell__inner {
  position: relative;
  width: 100%;
  max-width: 1500px;
  height: var(--ai4-shell-height);
  margin: 0 auto;
  padding: 0 clamp(18px, 2.4vw, 46px);
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto minmax(300px, 1fr);
  align-items: center;
  gap: 18px;
}

.ai4-shell__brand {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ai4-shell-ink);
  text-decoration: none;
  font-weight: 900;
  letter-spacing: 0;
  white-space: nowrap;
  min-width: 0;
}

.ai4-shell__mark {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 22%, rgba(255,255,255,.42), transparent 30%),
    linear-gradient(135deg, var(--ai4-shell-brand-purple), var(--ai4-shell-brand-blue) 56%, var(--ai4-shell-brand-cyan));
  box-shadow: 0 10px 24px var(--ai4-shell-glow), inset 0 0 0 1px rgba(255,255,255,.18);
}

.ai4-shell__logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ai4-shell__brandText {
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.ai4-shell__brandName {
  font-size: 20px;
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: 0;
}

.ai4-shell__tagline {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ai4-shell-muted);
  font-size: 11px;
  line-height: 1.2;
  font-weight: 700;
  white-space: nowrap;
}

.ai4-shell__nav {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}

.ai4-shell__actions {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.ai4-shell__link,
.ai4-shell__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0 14px;
  color: var(--ai4-shell-ink);
  background: transparent;
  text-decoration: none;
  font: inherit;
  font-size: 15px;
  font-weight: 750;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}

.ai4-shell__link:hover,
.ai4-shell__button:hover {
  background: var(--ai4-shell-hover);
  transform: translateY(-1px);
}

.ai4-shell__link.is-active {
  background: var(--ai4-shell-active);
  border-color: var(--ai4-shell-line);
}

.ai4-shell__theme {
  width: 42px;
  min-width: 42px;
  padding: 0;
  font-size: 19px;
}

.ai4-shell__language {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--ai4-shell-line);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255,255,255,.04);
}

.ai4-shell__lang {
  min-width: 44px;
  min-height: 42px;
  border: 0;
  border-radius: 0;
  padding: 0 10px;
}

.ai4-shell__lang + .ai4-shell__lang {
  border-inline-start: 1px solid var(--ai4-shell-line);
}

.ai4-shell__lang.is-active {
  background: linear-gradient(135deg, rgba(25,103,255,.14), rgba(17,184,215,.12));
  color: var(--ai4-shell-brand-blue);
}

.ai4-shell__user {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ai4-shell-ink);
  font-weight: 750;
  white-space: nowrap;
}

.ai4-shell__logout {
  border-color: var(--ai4-shell-line);
  background: var(--ai4-shell-active);
}

.ai4-shell__login {
  border-color: var(--ai4-shell-line);
  background: linear-gradient(135deg, rgba(44,11,105,.1), rgba(17,184,215,.1));
}

.ai4-shell__credits {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 800;
  color: var(--ai4-shell-brand-blue);
  background: var(--ai4-shell-hover);
  border: 1px solid var(--ai4-shell-line);
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

html[data-ai4-theme="dark"] .ai4-shell__credits {
  color: var(--ai4-shell-brand-cyan);
}

/* ============ DROPDOWN MENU ============ */
.ai4-shell__dropdown {
  position: relative;
  display: inline-block;
}

.ai4-shell__dropdown-btn {
  cursor: pointer;
}

.ai4-shell__dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  min-width: 140px;
  background-color: var(--ai4-shell-surface);
  border: 1px solid var(--ai4-shell-line);
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  padding: 6px;
  margin-top: 4px;
}

/* Show the dropdown menu on hover */
.ai4-shell__dropdown:hover .ai4-shell__dropdown-content {
  display: block;
}

.ai4-shell__dropdown-link {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  color: var(--ai4-shell-ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 750;
  border-radius: 8px;
  white-space: nowrap;
  transition: background-color .16s ease, color .16s ease;
}

.ai4-shell__dropdown-link:hover {
  background: var(--ai4-shell-hover);
}

.ai4-shell__dropdown-link.is-active {
  background: var(--ai4-shell-active);
  color: var(--ai4-shell-brand-blue);
}

@media (max-width: 1180px) {
  .ai4-shell__inner {
    grid-template-columns: auto 1fr auto;
  }

  .ai4-shell__tagline {
    display: none;
  }

  .ai4-shell__link,
  .ai4-shell__button {
    padding: 0 10px;
    font-size: 14px;
  }
}

@media (max-width: 900px) {
  body.ai4-shell-ready {
    padding-top: var(--ai4-shell-height) !important;
    padding-bottom: 64px;
  }

  .ai4-shell {
    overflow: visible;
  }

  .ai4-shell__inner {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 0 12px;
  }

  .ai4-shell__brandName {
    font-size: 17px;
  }

  .ai4-shell__mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
  }

  .ai4-shell__nav {
    position: fixed;
    inset: auto 0 0 0;
    min-height: 64px;
    padding: 7px 8px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--ai4-shell-bg);
    border-top: 1px solid var(--ai4-shell-line);
    box-shadow: 0 -10px 28px rgba(3, 8, 19, .12);
  }

  .ai4-shell__nav .ai4-shell__dropdown {
    display: none; /* Hide dropdown container on mobile bottom nav */
  }

  .ai4-shell__nav .ai4-shell__link {
    flex: 1;
    min-height: 46px;
    padding: 0 6px;
    font-size: 12px;
    text-align: center;
  }

  .ai4-shell__actions {
    gap: 6px;
  }

  .ai4-shell__user {
    display: none;
  }

  .ai4-shell__lang {
    min-width: 38px;
    padding: 0 8px;
  }

  .ai4-shell__logout {
    padding: 0 10px;
  }
}

@media (max-width: 560px) {
  .ai4-shell__brandName {
    display: none;
  }

  .ai4-shell__language {
    display: none;
  }

  .ai4-shell__logout {
    font-size: 13px;
  }
}

/* Hide standalone app controls when shell is ready */
body.ai4-shell-ready .controls-bar {
  display: none !important;
}
