/* ==============================================================================
   GeoCell AI Assist Drawer & Floating Widget
   Matches Aarlika Brewmaster AI architecture drawer with light/dark support,
   next-step links, the console tour and the failover drill demo.
   ============================================================================== */

:root {
  --drawer-width: 470px;
  --drawer-bg-light: #ffffff;
  --drawer-bg-dark: #0f172a;
  --drawer-header-bg: #1e2638;
  --drawer-pills-bg: #f8fafc;
  --drawer-border-light: #e2e8f0;
  --drawer-border-dark: #334155;
  --drawer-text-light: #0f172a;
  --drawer-text-dark: #f8fafc;
  --drawer-card-light: #fcfdfd;
  --drawer-card-border-light: #e2e8f0;
}

[data-theme="dark"] {
  --drawer-pills-bg: #172033;
}

/* Floating Trigger Button (when drawer is closed) */
.geocell-ai-trigger {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 1.25rem;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  font-family: var(--font-sans, system-ui, -apple-system, sans-serif);
  font-size: 0.92rem;
  font-weight: 600;
  box-shadow: 0 10px 28px rgba(2, 132, 199, 0.45);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  letter-spacing: -0.01em;
}

.geocell-ai-trigger:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(2, 132, 199, 0.6);
}

.geocell-ai-trigger.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
}

.geocell-pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 10px #10b981;
  animation: pulse-green 2s infinite ease-in-out;
}

@keyframes pulse-green {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

/* AI Assist Pop-up Drawer Container */
.geocell-ai-drawer {
  position: fixed;
  top: 1.25rem;
  bottom: 1.25rem;
  right: 1.25rem;
  width: var(--drawer-width);
  max-width: calc(100vw - 2.5rem);
  background: var(--drawer-bg-light);
  border: 1px solid var(--drawer-border-light);
  border-radius: 18px;
  box-shadow: 0 25px 65px rgba(15, 23, 42, 0.25), 0 0 1px rgba(15, 23, 42, 0.15);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateX(24px) scale(0.98);
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] .geocell-ai-drawer {
  background: var(--drawer-bg-dark);
  border-color: var(--drawer-border-dark);
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.6), 0 0 1px rgba(255, 255, 255, 0.1);
}

.geocell-ai-drawer.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0) scale(1);
}

/* 1. Header (Navy / Dark Slate matching screenshot) */
.geocell-drawer-header {
  padding: 0.95rem 1.15rem;
  background: var(--drawer-header-bg);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.geocell-header-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.geocell-logo-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.geocell-drawer-title {
  font-family: var(--font-sans, system-ui, sans-serif);
  font-size: 1.02rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.geocell-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.geocell-btn-newchat {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 0.32rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
}

.geocell-btn-newchat:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.4);
}

.geocell-btn-close {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #e2e8f0;
  font-size: 1.15rem;
  line-height: 1;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.geocell-btn-close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.35);
}

/* Backdrop Overlay */
.geocell-ai-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.32);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 995;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.geocell-ai-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* Tablets and desktops: no dimming, the page stays readable beside the panel. */
@media (min-width: 641px) {
  .geocell-ai-backdrop { display: none; }
}

/* Wide screens: the page narrows so the panel sits beside it instead of covering it. */
html.geocell-docked body {
  margin-right: calc(var(--drawer-width) + 2.5rem);
  transition: margin-right 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* The header's breakpoints follow the window, not the narrowed page: until the page
   is wide enough again, fold the menu into the toggle so it can't run into the logo. */
@media (max-width: 1499px) {
  html.geocell-docked .brand { flex-shrink: 0; }
  html.geocell-docked .brand-status { display: none; }
  html.geocell-docked .nav-toggle { display: flex; }
  html.geocell-docked .nav-menu-wrap { display: none; position: absolute; top: 100%; left: 0; right: 0; margin-left: 0; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow); }
  html.geocell-docked .nav-menu-wrap.open { display: block; }
  html.geocell-docked .nav-menu { flex-direction: column; align-items: stretch; gap: 0; padding: 0.5rem 16px 1rem; }
  html.geocell-docked .nav-link { padding: 0.7rem 0; font-size: 0.95rem; }
  html.geocell-docked .nav-actions { margin-left: auto; }
}

/* 2. Top Quick Pills (Horizontal Scroller below Header) */
.geocell-pills-bar {
  padding: 0.6rem 0.95rem;
  background: var(--drawer-pills-bg);
  border-bottom: 1px solid var(--drawer-border-light);
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: thin;
}

[data-theme="dark"] .geocell-pills-bar {
  border-bottom-color: var(--drawer-border-dark);
}

.geocell-quick-pill {
  background: #ffffff;
  border: 1px solid var(--drawer-border-light);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

[data-theme="dark"] .geocell-quick-pill {
  background: #1e293b;
  border-color: #334155;
  color: #cbd5e1;
}

.geocell-quick-pill:hover {
  background: #f1f5f9;
  border-color: #0284c7;
  color: #0284c7;
}

[data-theme="dark"] .geocell-quick-pill:hover {
  background: #334155;
  color: #38bdf8;
  border-color: #38bdf8;
}

/* 3. Messages List Area */
.geocell-messages-body {
  flex: 1;
  padding: 1.15rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: #fafaf9;
}

[data-theme="dark"] .geocell-messages-body {
  background: #090d16;
}

/* Welcome Card (Matching the exact card in screenshot) */
.geocell-welcome-card {
  background: #ffffff;
  border: 1px solid var(--drawer-border-light);
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: 0 3px 12px rgba(15, 23, 42, 0.04);
  color: #1e293b;
  font-size: 0.9rem;
  line-height: 1.55;
}

[data-theme="dark"] .geocell-welcome-card {
  background: #131c2e;
  border-color: #24324d;
  color: #e2e8f0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.geocell-card-intro {
  margin-bottom: 0.85rem;
}

.geocell-card-intro strong {
  font-weight: 700;
  color: #0f172a;
}

[data-theme="dark"] .geocell-card-intro strong {
  color: #ffffff;
}

/* Epistemic Badges inside Welcome Card */
/* Example Prompts List */
.geocell-example-label {
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.5rem;
}

[data-theme="dark"] .geocell-example-label {
  color: #cbd5e1;
}

.geocell-example-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.geocell-example-item {
  color: #0284c7;
  cursor: pointer;
  font-size: 0.86rem;
  line-height: 1.45;
  transition: color 0.15s ease;
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
}

[data-theme="dark"] .geocell-example-item {
  color: #38bdf8;
}

.geocell-example-item:hover {
  color: #0369a1;
  text-decoration: underline;
}

[data-theme="dark"] .geocell-example-item:hover {
  color: #7dd3fc;
}

.geocell-example-item::before {
  content: "•";
  color: #64748b;
  font-weight: bold;
}

/* Card Action Buttons (at bottom of card) */
.geocell-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid #f1f5f9;
}

[data-theme="dark"] .geocell-card-actions {
  border-top-color: #24324d;
}

.geocell-card-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #1e293b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
  text-decoration: none;
}

[data-theme="dark"] .geocell-card-btn {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

.geocell-card-btn:hover {
  background: #f8fafc;
  border-color: #0284c7;
  color: #0284c7;
}

[data-theme="dark"] .geocell-card-btn:hover {
  background: #27354f;
  color: #38bdf8;
  border-color: #38bdf8;
}

.geocell-card-btn.primary {
  background: #0284c7;
  border-color: #0284c7;
  color: #ffffff;
}

.geocell-card-btn.primary:hover {
  background: #0369a1;
  color: #ffffff;
}

/* Chat Message Bubbles */
.geocell-msg {
  max-width: 92%;
  padding: 0.85rem 1.05rem;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.55;
  word-break: break-word;
}

.geocell-msg.user {
  align-self: flex-end;
  background: #0284c7;
  color: #ffffff;
  border-bottom-right-radius: 3px;
}

.geocell-msg.assistant {
  align-self: flex-start;
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 3px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .geocell-msg.assistant {
  background: #172033;
  color: #f1f5f9;
  border-color: #334155;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* Typing Dots */
.geocell-typing {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  padding: 0.65rem 0.95rem;
  border-radius: 12px;
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

[data-theme="dark"] .geocell-typing {
  background: #172033;
  border-color: #334155;
}

.geocell-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: typing-dots 1.4s infinite ease-in-out both;
}

.geocell-typing span:nth-child(1) { animation-delay: -0.32s; }
.geocell-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing-dots {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* 4. Footer & Input Form */
.geocell-drawer-footer {
  padding: 0.9rem 1.15rem 0.75rem;
  background: #ffffff;
  border-top: 1px solid var(--drawer-border-light);
}

[data-theme="dark"] .geocell-drawer-footer {
  background: #0f172a;
  border-top-color: var(--drawer-border-dark);
}

.geocell-form {
  display: flex;
  gap: 0.55rem;
}

.geocell-input {
  flex: 1;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  padding: 0.75rem 0.95rem;
  font-family: var(--font-sans, system-ui, sans-serif);
  font-size: 0.88rem;
  color: #0f172a;
  outline: none;
  transition: border-color 0.15s ease;
}

[data-theme="dark"] .geocell-input {
  background: #1e293b;
  border-color: #334155;
  color: #ffffff;
}

.geocell-input:focus {
  border-color: #0284c7;
}

.geocell-btn-send {
  background: #1e2638;
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.geocell-btn-send:hover {
  background: #0f172a;
}

[data-theme="dark"] .geocell-btn-send {
  background: #0284c7;
}

[data-theme="dark"] .geocell-btn-send:hover {
  background: #0369a1;
}

.geocell-disclaimer {
  font-size: 0.72rem;
  color: #94a3b8;
  text-align: center;
  margin-top: 0.55rem;
  line-height: 1.4;
}

/* Contextual Page CTA Styles (matching aarlika.com) */
.hero-ai-entry {
  margin-top: 1.1rem;
  font-size: 0.94rem;
  color: var(--text-2, #475569);
  line-height: 1.5;
}

.hero-ai-entry a,
.hero-ai-entry button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: #0284c7;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

[data-theme="dark"] .hero-ai-entry a,
[data-theme="dark"] .hero-ai-entry button {
  color: #38bdf8;
}

.hero-ai-entry a:hover,
.hero-ai-entry button:hover {
  text-decoration: underline;
}

.pillar-cta-link {
  margin-top: 0.9rem;
  padding: 0.45rem 0.8rem;
  background: rgba(2, 132, 199, 0.08);
  border: 1px solid rgba(2, 132, 199, 0.22);
  border-radius: 8px;
  color: #0284c7;
  font-size: 0.82rem;
  font-weight: 650;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  transition: all 0.15s ease;
  text-align: left;
  width: fit-content;
}

[data-theme="dark"] .pillar-cta-link {
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.25);
  color: #38bdf8;
}

.pillar-cta-link:hover {
  background: #0284c7;
  border-color: #0284c7;
  color: #ffffff;
  transform: translateY(-1px);
}

[data-theme="dark"] .pillar-cta-link:hover {
  background: #0284c7;
  border-color: #38bdf8;
  color: #ffffff;
}

.nav-ai-assist-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.85rem;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 650;
  background: rgba(2, 132, 199, 0.1);
  color: #0284c7;
  border: 1px solid rgba(2, 132, 199, 0.3);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

[data-theme="dark"] .nav-ai-assist-btn {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.3);
}

.nav-ai-assist-btn:hover {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

/* Mobile responsive drawer adjustments */
@media (max-width: 640px) {
  .geocell-ai-drawer {
    top: 0;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100vw;
    border-radius: 0;
  }
  .nav-ai-assist-btn span.nav-ai-text {
    display: none;
  }
}

/* Answer formatting */
.geocell-msg.assistant p { margin: 0 0 0.55rem; }
.geocell-msg.assistant p:last-of-type { margin-bottom: 0; }
.geocell-msg.assistant ul,
.geocell-msg.assistant ol { margin: 0.35rem 0 0.6rem; padding-left: 1.2rem; }
.geocell-msg.assistant li { margin: 0.2rem 0; }
.geocell-msg.assistant a { color: #0284c7; font-weight: 600; }
[data-theme="dark"] .geocell-msg.assistant a { color: #7dd3fc; }
.geocell-msg.assistant code { font-size: 0.82em; padding: 0.05rem 0.3rem; border-radius: 4px; background: rgba(148, 163, 184, 0.18); }

/* Next steps under every answer */
.geocell-next-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.8rem;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
}
.geocell-msg.assistant .geocell-next-step {
  display: inline-flex;
  align-items: center;
  padding: 0.38rem 0.75rem;
  border-radius: 999px;
  border: 1px solid #bae6fd;
  background: #f0f9ff;
  color: #0369a1;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
}
.geocell-msg.assistant .geocell-next-step:hover { border-color: #0284c7; }
.geocell-msg.assistant .geocell-next-step.primary { background: #0284c7; border-color: #0284c7; color: #ffffff; }
.geocell-msg.assistant .geocell-next-step.primary:hover { background: #0369a1; }
[data-theme="dark"] .geocell-msg.assistant .geocell-next-step { background: rgba(14, 165, 233, 0.12); border-color: rgba(56, 189, 248, 0.35); color: #7dd3fc; }
[data-theme="dark"] .geocell-msg.assistant .geocell-next-step.primary { background: #0284c7; color: #ffffff; }

/* Demo cards: failover drill illustration and console tour */
.geocell-demo-card {
  align-self: stretch;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: 0.85rem;
  line-height: 1.45;
  color: #334155;
}
[data-theme="dark"] .geocell-demo-card { background: #111a2b; border-color: #334155; color: #cbd5e1; }
.geocell-demo-title { font-weight: 700; color: #0f172a; margin-bottom: 0.3rem; }
[data-theme="dark"] .geocell-demo-title { color: #f1f5f9; }
.geocell-demo-card p { margin: 0 0 0.65rem; }
.geocell-demo-btn {
  border: 0;
  border-radius: 8px;
  padding: 0.5rem 0.95rem;
  background: #e11d48;
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
}
.geocell-demo-btn:disabled { background: #64748b; cursor: default; }
.geocell-demo-steps { margin: 0.7rem 0 0; padding-left: 1.2rem; }
.geocell-demo-steps li { margin: 0.2rem 0; }
.geocell-story-meta { display: flex; justify-content: space-between; font-size: 0.76rem; font-weight: 700; color: #64748b; margin-bottom: 0.35rem; }
.geocell-story-title { font-weight: 700; color: #0f172a; margin-bottom: 0.5rem; }
[data-theme="dark"] .geocell-story-title { color: #f1f5f9; }
.geocell-story-img { display: block; width: 100%; padding: 0; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; background: #000; cursor: zoom-in; }
.geocell-story-img img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.geocell-story-caption { margin: 0.6rem 0; }
.geocell-story-nav { display: flex; justify-content: space-between; gap: 0.5rem; }
