/* ==========================================================================
   LAMIM HYBRID AI ASSISTANT — 3D ROBOT MASCOT & ULTRA-PREMIUM UI
   Transparent Glassmorphic Interface with Online / Offline Dynamic Animations
   ========================================================================== */

:root {
  --ai-launcher-size: 52px;
  --ai-accent: #10b981;
  --ai-accent-hover: #059669;
  --ai-accent-glow: rgba(16, 185, 129, 0.32);
  --ai-accent-cyan: #06b6d4;
  --ai-bg-glass: rgba(15, 23, 42, 0.88);
  --ai-bg-card: rgba(30, 41, 59, 0.72);
  --ai-bg-stage: rgba(15, 23, 42, 0.65);
  --ai-border: rgba(255, 255, 255, 0.09);
  --ai-border-hover: rgba(16, 185, 129, 0.45);
  --ai-text-primary: #f8fafc;
  --ai-text-secondary: #cbd5e1;
  --ai-text-muted: #94a3b8;
  --ai-user-bubble: linear-gradient(135deg, #059669 0%, #047857 100%);
  --ai-robot-glow-online: rgba(16, 185, 129, 0.4);
  --ai-robot-glow-offline: rgba(245, 158, 11, 0.3);
}

[data-theme="light"] {
  --ai-bg-glass: rgba(255, 255, 255, 0.94);
  --ai-bg-card: rgba(241, 245, 249, 0.88);
  --ai-bg-stage: rgba(248, 250, 252, 0.85);
  --ai-border: rgba(15, 23, 42, 0.08);
  --ai-border-hover: rgba(16, 185, 129, 0.45);
  --ai-text-primary: #0f172a;
  --ai-text-secondary: #334155;
  --ai-text-muted: #64748b;
  --ai-accent: #059669;
  --ai-accent-glow: rgba(5, 150, 105, 0.22);
  --ai-user-bubble: linear-gradient(135deg, #059669 0%, #047857 100%);
  --ai-robot-glow-online: rgba(5, 150, 105, 0.3);
  --ai-robot-glow-offline: rgba(217, 119, 6, 0.25);
}

/* ==========================================================================
   1. FLOATING 3D ROBOT MASCOT LAUNCHER (PURE ROBOT MASCOT)
   ========================================================================== */

.lamim-ai-launcher {
  position: fixed;
  bottom: 84px;
  right: 20px;
  z-index: 999;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  padding: 0;
  margin: 0;
  cursor: pointer;
  outline: none;
  user-select: none;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  -webkit-tap-highlight-color: transparent;
}

.lamim-ai-launcher:hover {
  transform: translateY(-4px) scale(1.08);
}

.lamim-ai-launcher:active,
.lamim-ai-launcher.active {
  transform: scale(0.94);
}

.lamim-ai-launcher-robot-img {
  width: 58px;
  height: 70px;
  object-fit: contain;
  transition: filter 0.3s ease, opacity 0.3s ease;
  user-select: none;
  pointer-events: none;
}

/* Online State: Vivid, crisp, vibrant mascot shadow */
.lamim-ai-launcher.online .lamim-ai-launcher-robot-img,
.lamim-ai-launcher:not(.offline) .lamim-ai-launcher-robot-img {
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.16));
  opacity: 1;
}

.lamim-ai-launcher.online:hover .lamim-ai-launcher-robot-img,
.lamim-ai-launcher:not(.offline):hover .lamim-ai-launcher-robot-img {
  filter: drop-shadow(0 6px 14px rgba(16, 185, 129, 0.35)) drop-shadow(0 2px 5px rgba(0, 0, 0, 0.18));
}

/* Offline State: Calm, resting/grayscale tint */
.lamim-ai-launcher.offline .lamim-ai-launcher-robot-img {
  filter: grayscale(0.6) brightness(0.92) drop-shadow(0 2px 5px rgba(0, 0, 0, 0.15));
  opacity: 0.85;
}

.lamim-ai-launcher.offline:hover .lamim-ai-launcher-robot-img {
  filter: grayscale(0.25) drop-shadow(0 6px 12px rgba(245, 158, 11, 0.35));
  opacity: 1;
}

/* ==========================================================================
   2. CHAT DRAWER / OVERLAY CONTAINER
   ========================================================================== */

.lamim-ai-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.26s ease;
}

.lamim-ai-drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.lamim-ai-drawer {
  position: relative;
  width: 100%;
  max-width: 440px;
  height: 86vh;
  max-height: 700px;
  margin: 0 18px 20px 0;
  border-radius: 26px;
  background: var(--ai-bg-glass);
  backdrop-filter: blur(36px);
  -webkit-backdrop-filter: blur(36px);
  border: 1px solid var(--ai-border);
  box-shadow: 0 32px 72px -16px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.07);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(24px) scale(0.97);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.lamim-ai-drawer-overlay.open .lamim-ai-drawer {
  transform: translateY(0) scale(1);
}

@media (max-width: 640px) {
  .lamim-ai-drawer {
    max-width: 100%;
    margin: 0;
    height: 92vh;
    max-height: 92vh;
    border-radius: 28px 28px 0 0;
    border-bottom: none;
  }
}

/* ==========================================================================
   3. CHAT DRAWER HEADER WITH MINI ROBOT
   ========================================================================== */

.lamim-ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--ai-border);
  background: rgba(255, 255, 255, 0.02);
}

.lamim-ai-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lamim-ai-header-robot {
  position: relative;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.lamim-ai-header-robot-img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  animation: robotSubtleFloat 3s ease-in-out infinite;
}

.lamim-ai-header-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--ai-text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.01em;
}

.lamim-ai-mode-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.lamim-ai-mode-badge.online {
  background: rgba(16, 185, 129, 0.14);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.28);
}

.lamim-ai-mode-badge.offline {
  background: rgba(245, 158, 11, 0.14);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.28);
}

.lamim-ai-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: aiBadgePulse 2s infinite ease-in-out;
}

.lamim-ai-badge-dot.offline {
  background: #f59e0b;
  box-shadow: 0 0 6px #f59e0b;
  animation: none;
}

.lamim-ai-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lamim-ai-btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--ai-border);
  color: var(--ai-text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.lamim-ai-btn-icon:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--ai-text-primary);
  transform: scale(1.05);
}

.lamim-ai-lang-toggle {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--ai-border);
  color: var(--ai-text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.lamim-ai-lang-toggle:hover {
  background: var(--ai-accent-glow);
  border-color: var(--ai-accent);
  color: var(--ai-accent);
}

/* ==========================================================================
   4. WELCOME 3D ROBOT MASCOT HERO STAGE
   ========================================================================== */

.lamim-ai-mascot-hero-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16px 14px 6px;
  margin-bottom: 8px;
}

.lamim-ai-robot-stage-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lamim-ai-robot-3d-img {
  width: 90px;
  height: 110px;
  object-fit: contain;
  transition: filter 0.3s ease, opacity 0.3s ease;
  user-select: none;
  pointer-events: none;
}

.lamim-ai-mascot-hero-stage.online .lamim-ai-robot-3d-img,
.lamim-ai-mascot-hero-stage:not(.offline) .lamim-ai-robot-3d-img {
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.45));
  opacity: 1;
}

.lamim-ai-mascot-hero-stage.offline .lamim-ai-robot-3d-img {
  filter: grayscale(0.6) brightness(0.92) drop-shadow(0 6px 14px rgba(0, 0, 0, 0.3));
  opacity: 0.85;
}

.lamim-ai-robot-greeting {
  font-size: 0.85rem;
  color: var(--ai-text-secondary);
  line-height: 1.45;
  margin-top: 12px;
  max-width: 320px;
}

.lamim-ai-robot-greeting strong {
  color: var(--ai-text-primary);
}

/* ==========================================================================
   5. CHAT MESSAGE AREA & BUBBLES WITH AVATARS
   ========================================================================== */

.lamim-ai-messages {
  flex: 1;
  padding: 14px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.lamim-ai-messages::-webkit-scrollbar {
  width: 5px;
}

.lamim-ai-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}

.lamim-ai-msg {
  display: flex;
  max-width: 96%;
  animation: aiMsgFadeIn 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

.lamim-ai-msg.user {
  align-self: flex-end;
  justify-content: flex-end;
}

.lamim-ai-msg.assistant {
  align-self: flex-start;
  align-items: flex-start;
  gap: 10px;
}

/* Mini robot avatar beside assistant messages */
.lamim-ai-msg-avatar {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--ai-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  overflow: visible;
}

.lamim-ai-msg-avatar-img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.35));
}

.lamim-ai-msg-avatar-dot {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  border: 1px solid #0f172a;
}

.lamim-ai-msg-avatar-dot.offline {
  background: #f59e0b;
}

.lamim-ai-msg-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 100%;
}

.lamim-ai-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.88rem;
  line-height: 1.54;
  word-break: break-word;
}

.lamim-ai-heading {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--ai-accent);
  margin: 10px 0 4px;
  line-height: 1.35;
}

.lamim-ai-heading-lg {
  font-size: 1rem;
  font-weight: 800;
  color: var(--ai-text-primary);
  margin: 12px 0 6px;
  line-height: 1.35;
}

.lamim-ai-heading-xl {
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--ai-text-primary);
  margin: 14px 0 8px;
}

.lamim-ai-list-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 4px 0;
  line-height: 1.48;
}

.lamim-ai-num {
  font-weight: 700;
  color: var(--ai-accent);
  flex-shrink: 0;
}

.lamim-ai-bullet {
  color: var(--ai-accent);
  font-weight: 900;
  flex-shrink: 0;
}

.lamim-ai-spacer {
  height: 8px;
}

.lamim-ai-msg.user .lamim-ai-bubble {
  background: var(--ai-user-bubble);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 16px rgba(5, 150, 105, 0.28);
}

.lamim-ai-msg.assistant .lamim-ai-bubble {
  background: var(--ai-bg-card);
  color: var(--ai-text-primary);
  border: 1px solid var(--ai-border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

.lamim-ai-msg-meta {
  font-size: 0.68rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 999px;
  margin-top: 2px;
}

.lamim-ai-msg-meta.online {
  color: #10b981;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.lamim-ai-msg-meta.offline {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Deep Action Link Buttons inside AI bubbles */
.lamim-ai-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 6px 12px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #10b981;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.lamim-ai-action-btn:hover {
  background: #10b981;
  color: #ffffff;
  transform: translateY(-1px);
}

/* Suggestion Chips */
.lamim-ai-suggestions {
  display: flex;
  gap: 8px;
  padding: 8px 16px 10px;
  overflow-x: auto;
  scrollbar-width: none;
  user-select: none;
}

.lamim-ai-suggestions::-webkit-scrollbar {
  display: none;
}

.lamim-ai-chip {
  white-space: nowrap;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--ai-border);
  color: var(--ai-text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.lamim-ai-chip svg {
  color: var(--ai-accent);
}

.lamim-ai-chip:hover {
  background: var(--ai-accent-glow);
  border-color: var(--ai-accent);
  color: var(--ai-text-primary);
  transform: translateY(-1px);
}

/* ==========================================================================
   6. INPUT COMPOSER
   ========================================================================== */

.lamim-ai-composer {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--ai-border);
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  gap: 10px;
  align-items: center;
}

.lamim-ai-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--ai-border);
  border-radius: 999px;
  padding: 10px 16px;
  color: var(--ai-text-primary);
  font-size: 0.88rem;
  outline: none;
  transition: all 0.2s ease;
  font-family: inherit;
}

.lamim-ai-input:focus {
  border-color: var(--ai-accent);
  box-shadow: 0 0 0 3px var(--ai-accent-glow);
  background: rgba(255, 255, 255, 0.09);
}

.lamim-ai-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981, #059669);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px var(--ai-accent-glow);
  flex-shrink: 0;
}

.lamim-ai-send-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 16px var(--ai-accent-glow);
}

.lamim-ai-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Loading Dots with Thinking Robot Pulse */
.lamim-ai-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 4px 8px;
}

.lamim-ai-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ai-accent);
  animation: aiDotBounce 1.4s infinite ease-in-out both;
}

.lamim-ai-dot:nth-child(1) { animation-delay: -0.32s; }
.lamim-ai-dot:nth-child(2) { animation-delay: -0.16s; }
.lamim-ai-dot:nth-child(3) { animation-delay: 0s; }

/* ==========================================================================
   7. 60FPS KEYFRAME ANIMATION SYSTEM (AURA & PULSE)
   ========================================================================== */

@keyframes auraPulseOnline {
  0%, 100% {
    transform: scale(0.95);
    opacity: 0.55;
  }
  50% {
    transform: scale(1.2);
    opacity: 0.85;
  }
}

@keyframes auraPulseOffline {
  0%, 100% {
    transform: scale(0.95);
    opacity: 0.4;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.65;
  }
}

@keyframes heroAuraPulseOnline {
  0%, 100% {
    transform: scale(0.92);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.18);
    opacity: 0.85;
  }
}

@keyframes heroAuraPulseOffline {
  0%, 100% {
    transform: scale(0.92);
    opacity: 0.35;
  }
  50% {
    transform: scale(1.08);
    opacity: 0.6;
  }
}

@keyframes aiBadgePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

@keyframes aiMsgFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes aiDotBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}

/* Accessibility: respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .lamim-ai-launcher-robot-img,
  .lamim-ai-header-robot-img,
  .lamim-ai-robot-3d-img,
  .lamim-ai-robot-3d-shadow,
  .lamim-ai-launcher-aura,
  .lamim-ai-robot-aura-main,
  .lamim-ai-badge-dot {
    animation: none !important;
  }
}
