/* Bert the BudBot — BudMaster Design Language */
/* Hex grills, quantum grid, glassmorphism, green glow */

@import url('https://fonts.googleapis.com/css2?family=Righteous&family=Outfit:wght@400;600;700&display=swap');

:root {
  --bb-bg: #060a06;
  --bb-surface: rgba(10, 18, 10, 0.95);
  --bb-glass: rgba(255, 255, 255, 0.03);
  --bb-border: rgba(78, 204, 163, 0.12);
  --bb-border-hover: rgba(78, 204, 163, 0.3);
  --bb-teal: #4ecca3;
  --bb-green: #00ff88;
  --bb-green-dim: rgba(0, 255, 136, 0.15);
  --bb-text: #d4ddd4;
  --bb-muted: #5a6a5a;
  --bb-input-bg: rgba(10, 20, 10, 0.8);
  --bb-user-bg: rgba(78, 204, 163, 0.08);
  --bb-bot-bg: rgba(255, 255, 255, 0.02);
  --bb-font: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --bb-font-brand: 'Righteous', cursive;
}

/* ── FLOATING BUBBLE — Hexagonal ── */
#bert-bubble-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  filter: drop-shadow(0 4px 12px rgba(0,255,136,0.4)) drop-shadow(0 8px 25px rgba(0,0,0,0.6));
  transition: filter 0.3s;
}
#bert-bubble-wrap:hover {
  filter: drop-shadow(0 4px 16px rgba(0,255,136,0.6)) drop-shadow(0 10px 30px rgba(0,0,0,0.7));
}

#bert-bubble {
  position: relative;
  width: 62px;
  height: 62px;
  background: linear-gradient(135deg, #00cc6a 0%, #4ecca3 50%, #00ff88 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--bb-font-brand);
  font-size: 1.5rem;
  color: #000;
  font-weight: 900;
  letter-spacing: 1px;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  transition: transform 0.2s;
  animation: bertPulse 3s ease-in-out infinite;
}

#bert-bubble:hover {
  transform: scale(1.12);
}

#bert-bubble.open {
  transform: scale(0.85) rotate(60deg);
  animation: none;
}

/* Speech bubble — always visible until clicked */
#bert-bubble-label {
  position: absolute;
  bottom: 8px; right: 72px;
  background: rgba(10,18,10,0.94);
  border: 1px solid rgba(78,204,163,0.3);
  color: #d4ddd4;
  font-family: var(--bb-font);
  font-size: 0.85rem;
  font-weight: 400;
  line-height: 1.4;
  padding: 12px 16px;
  border-radius: 12px 12px 4px 12px;
  white-space: nowrap;
  cursor: pointer;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5), 0 0 15px rgba(0,255,136,0.08);
  animation: labelSlideIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: 1.5s;
  opacity: 0;
  transition: opacity 0.4s, transform 0.3s;
}
#bert-bubble-label:hover {
  border-color: rgba(78,204,163,0.5);
  transform: translateX(-4px);
}
#bert-bubble-label .bert-label-name {
  color: var(--bb-green);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  display: block;
  margin-bottom: 2px;
}
/* Triangle pointer toward hex */
#bert-bubble-label::after {
  content: '';
  position: absolute;
  bottom: 12px; right: -7px;
  width: 12px; height: 12px;
  background: rgba(10,18,10,0.94);
  border-right: 1px solid rgba(78,204,163,0.3);
  border-top: 1px solid rgba(78,204,163,0.3);
  transform: rotate(45deg);
}
@keyframes labelSlideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
#bert-bubble-wrap.label-hidden #bert-bubble-label {
  opacity: 0;
  pointer-events: none;
}

@keyframes bertPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.15); }
}

/* ── TOOLTIP ── */
#bert-tooltip {
  position: fixed;
  bottom: 90px;
  right: 24px;
  background: var(--bb-surface);
  border: 1px solid var(--bb-border);
  border-radius: 10px;
  padding: 10px 16px;
  font-family: var(--bb-font);
  font-size: 0.8rem;
  color: var(--bb-teal);
  z-index: 10000;
  opacity: 0;
  transform: translateY(8px);
  animation: bertTooltipIn 0.3s 5s forwards, bertTooltipOut 0.3s 8s forwards;
  pointer-events: none;
  white-space: nowrap;
}

#bert-tooltip::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 20px;
  width: 12px;
  height: 12px;
  background: var(--bb-surface);
  border-right: 1px solid var(--bb-border);
  border-bottom: 1px solid var(--bb-border);
  transform: rotate(45deg);
}

@keyframes bertTooltipIn {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes bertTooltipOut {
  to { opacity: 0; transform: translateY(-4px); }
}

/* ── CHAT WINDOW ── */
#bert-chat {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 400px;
  max-height: 560px;
  background: var(--bb-bg);
  background-image:
    linear-gradient(rgba(78, 204, 163, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(78, 204, 163, 0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  border: 1px solid var(--bb-border);
  border-radius: 16px;
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.7), 0 0 30px rgba(0, 255, 136, 0.05);
  z-index: 10001;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--bb-font);
  transform-origin: bottom right;
}

#bert-chat.open {
  display: flex;
  animation: bertChatOpen 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes bertChatOpen {
  from { opacity: 0; transform: scale(0.4); }
  to { opacity: 1; transform: scale(1); }
}

/* ── HEADER — scan line effect ── */
.bert-header {
  padding: 18px 20px;
  background: var(--bb-surface);
  border-bottom: 1px solid var(--bb-border);
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  overflow: hidden;
}

.bert-header::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0, 255, 136, 0.03), transparent);
  animation: bertScanline 4s linear infinite;
}

@keyframes bertScanline {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* ── AVATAR — hex shape ── */
.bert-avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #00cc6a, #4ecca3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--bb-font-brand);
  font-weight: 900;
  font-size: 1rem;
  color: #000;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  flex-shrink: 0;
}

.bert-header-text h3 {
  margin: 0;
  font-family: var(--bb-font-brand);
  font-size: 1rem;
  color: var(--bb-green);
  letter-spacing: 0.5px;
}

.bert-header-text p {
  margin: 3px 0 0;
  font-size: 0.7rem;
  color: var(--bb-muted);
  letter-spacing: 0.5px;
}

.bert-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bb-green);
  box-shadow: 0 0 8px var(--bb-green);
  animation: bertStatusPulse 2s ease-in-out infinite;
  margin-left: auto;
}

@keyframes bertStatusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── MESSAGES ── */
.bert-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 220px;
  max-height: 360px;
}

.bert-msg {
  max-width: 88%;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 0.84rem;
  line-height: 1.6;
  color: var(--bb-text);
  word-wrap: break-word;
}

.bert-msg.bot {
  align-self: flex-start;
  background: var(--bb-glass);
  border: 1px solid var(--bb-border);
  backdrop-filter: blur(4px);
}

.bert-msg.user {
  align-self: flex-end;
  background: var(--bb-user-bg);
  border: 1px solid rgba(78, 204, 163, 0.2);
}

.bert-msg.typing {
  align-self: flex-start;
  background: var(--bb-glass);
  border: 1px solid var(--bb-border);
  color: var(--bb-muted);
  font-style: italic;
}

.bert-msg strong { color: var(--bb-teal); }

/* ── INPUT ── */
.bert-input-area {
  padding: 14px 18px;
  border-top: 1px solid var(--bb-border);
  display: flex;
  gap: 10px;
  background: var(--bb-surface);
}

.bert-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--bb-border);
  border-radius: 10px;
  background: var(--bb-input-bg);
  color: var(--bb-text);
  font-size: 0.84rem;
  font-family: var(--bb-font);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.bert-input:focus {
  border-color: var(--bb-teal);
  box-shadow: 0 0 12px rgba(78, 204, 163, 0.15);
}

.bert-input::placeholder {
  color: var(--bb-muted);
}

.bert-send {
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #00cc6a, #4ecca3);
  color: #000;
  font-weight: 700;
  font-size: 0.84rem;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  font-family: var(--bb-font);
  letter-spacing: 0.5px;
}

.bert-send:hover { opacity: 0.9; }
.bert-send:active { transform: scale(0.95); }
.bert-send:disabled { opacity: 0.3; cursor: default; transform: none; }

/* ── POWERED BY ── */
.bert-footer {
  text-align: center;
  padding: 6px;
  font-size: 0.6rem;
  color: var(--bb-muted);
  letter-spacing: 0.5px;
  border-top: 1px solid rgba(78, 204, 163, 0.05);
}

/* ── SCROLLBAR ── */
.bert-messages::-webkit-scrollbar { width: 3px; }
.bert-messages::-webkit-scrollbar-track { background: transparent; }
.bert-messages::-webkit-scrollbar-thumb { background: rgba(78, 204, 163, 0.2); border-radius: 3px; }
.bert-messages::-webkit-scrollbar-thumb:hover { background: rgba(78, 204, 163, 0.4); }

/* ── MOBILE ── */
@media (max-width: 480px) {
  #bert-chat {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
  }
  #bert-bubble { bottom: 16px; right: 16px; width: 52px; height: 52px; }
  #bert-tooltip { display: none; }
}
