/**
 * EFOUR GLOBAL — AI Agent Clean Antigravity White UI & Stylesheet
 * Ultra-clean modern white aesthetic, subtle borders, unified input bar, and elegant typography.
 */

:root {
  --efour-primary: #007D71;
  --efour-primary-hover: #006359;
  --efour-primary-light: #f0fdf9;
  --efour-primary-subtle: #e6f4f1;
  --efour-gold: #c59b27;
  --efour-bg-white: #ffffff;
  --efour-bg-body: #f8fafc;
  --efour-border: #e2e8f0;
  --efour-border-subtle: #edf2f7;
  --efour-text-dark: #0f172a;
  --efour-text-body: #334155;
  --efour-text-muted: #64748b;
  --efour-shadow-window: 0 20px 45px -10px rgba(15, 23, 42, 0.15), 0 0 1px 1px rgba(0, 0, 0, 0.04);
  --efour-shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --efour-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Floating Launcher Button */
#efour-ai-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-family: var(--efour-font);
  user-select: none;
}

.efour-ai-bubble-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #007D71 0%, #00564d 100%);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 24px rgba(0, 125, 113, 0.38);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.efour-ai-bubble-btn:hover {
  transform: scale(1.06) translateY(-2px);
  box-shadow: 0 12px 28px rgba(0, 125, 113, 0.5);
}

.efour-ai-bubble-btn svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

.efour-ai-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 1.5px solid #007D71;
  animation: efourPulse 2.4s infinite;
  pointer-events: none;
}

@keyframes efourPulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.35); opacity: 0; }
}

.efour-ai-badge {
  background: #ffffff;
  color: var(--efour-text-dark);
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  border: 1px solid var(--efour-border);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.efour-ai-badge span.sparkle {
  color: var(--efour-gold);
}

/* Chat Container Window */
#efour-ai-container {
  position: fixed;
  bottom: 94px;
  right: 24px;
  width: 410px;
  height: 610px;
  max-height: calc(100vh - 114px);
  background: var(--efour-bg-white);
  border: 1px solid var(--efour-border);
  border-radius: 18px;
  box-shadow: var(--efour-shadow-window);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999999;
  font-family: var(--efour-font);
  opacity: 0;
  visibility: hidden;
  transform: translateY(18px) scale(0.97);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#efour-ai-container.efour-active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Fullscreen Mode */
#efour-ai-container.efour-fullscreen {
  width: min(1160px, calc(100vw - 32px)) !important;
  height: calc(100vh - 32px) !important;
  max-height: calc(100vh - 32px) !important;
  top: 16px !important;
  left: 50% !important;
  right: auto !important;
  bottom: auto !important;
  transform: translateX(-50%) !important;
  border-radius: 16px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2);
}

/* Header */
.efour-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: #ffffff;
  border-bottom: 1px solid var(--efour-border-subtle);
}

.efour-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.efour-avatar-wrapper {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--efour-primary-light);
  color: var(--efour-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  border: 1.5px solid rgba(0, 125, 113, 0.25);
}

.efour-avatar-online {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid #ffffff;
}

.efour-header-title {
  display: flex;
  flex-direction: column;
}

.efour-header-title h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--efour-text-dark);
  letter-spacing: -0.01em;
}

.efour-header-title span {
  font-size: 11px;
  color: var(--efour-text-muted);
}

.efour-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.efour-btn-icon {
  background: transparent;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--efour-text-muted);
  transition: all 0.18s ease;
}

.efour-btn-icon:hover {
  background: #f1f5f9;
  color: var(--efour-text-dark);
}

/* Messages Body Area */
.efour-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  background: var(--efour-bg-body);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.efour-chat-body::-webkit-scrollbar {
  width: 5px;
}
.efour-chat-body::-webkit-scrollbar-thumb {
  background: #e2e8f0;
  border-radius: 3px;
}

/* Message Bubbles */
.efour-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: efourFadeIn 0.22s ease-out;
}

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

.efour-msg.user {
  align-self: flex-end;
}

.efour-msg.user .efour-bubble {
  background: var(--efour-primary);
  color: #ffffff;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 2px 8px rgba(0, 125, 113, 0.15);
}

.efour-msg.user .efour-bubble a {
  color: #ffffff;
  text-decoration: underline;
}

.efour-msg.model {
  align-self: flex-start;
}

.efour-msg.model .efour-bubble {
  background: #ffffff;
  color: var(--efour-text-body);
  border: 1px solid var(--efour-border-subtle);
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.efour-bubble {
  padding: 12px 15px;
  font-size: 13.5px;
  line-height: 1.6;
  word-break: break-word;
}

.efour-bubble p {
  margin: 0 0 8px 0;
}
.efour-bubble p:last-child {
  margin-bottom: 0;
}

/* Clean Markdown Typography */
.efour-bubble h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--efour-text-dark);
  margin: 12px 0 6px 0;
  line-height: 1.4;
}
.efour-bubble h4:first-child {
  margin-top: 0;
}

.efour-bubble hr {
  border: none;
  border-top: 1px solid var(--efour-border);
  margin: 10px 0;
}

.efour-bubble ul, .efour-bubble ol {
  margin: 4px 0 8px 18px;
  padding: 0;
}

.efour-bubble li {
  margin-bottom: 4px;
  line-height: 1.5;
}

.efour-bubble strong {
  font-weight: 600;
  color: var(--efour-text-dark);
}

.efour-bubble a {
  color: var(--efour-primary);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 2.5px;
  font-weight: 600;
  transition: all 0.15s ease;
}
.efour-bubble a:hover {
  color: var(--efour-primary-hover);
  text-decoration-color: var(--efour-primary-hover);
}

.efour-time {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 4px;
  padding: 0 4px;
}
.efour-msg.user .efour-time {
  text-align: right;
}

/* Product Cards Container */
.efour-products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 10px;
  width: 100%;
}

.efour-fullscreen .efour-products-grid {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.efour-product-card {
  background: #ffffff;
  border: 1px solid var(--efour-border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.22s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.efour-product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.06);
  border-color: #cbd5e1;
}

.efour-product-img-box {
  width: 100%;
  height: 120px;
  background: #f1f5f9;
  position: relative;
  overflow: hidden;
}

.efour-fullscreen .efour-product-img-box {
  height: 160px;
}

.efour-product-img-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.efour-product-card:hover .efour-product-img-box img {
  transform: scale(1.04);
}

.efour-product-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: var(--efour-primary);
  color: #fff;
  font-size: 9px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.efour-product-details {
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.efour-product-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--efour-text-dark);
  margin: 0 0 5px 0;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: 34px;
  text-decoration: none;
}
.efour-product-title:hover {
  color: var(--efour-primary);
}

.efour-product-price {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--efour-primary);
  margin-bottom: 7px;
}

.efour-product-price .reg-price {
  font-size: 10.5px;
  color: var(--efour-text-muted);
  text-decoration: line-through;
  margin-left: 4px;
  font-weight: 400;
}

.efour-product-action {
  margin-top: auto;
  display: block;
  text-align: center;
  background: var(--efour-primary-light);
  color: var(--efour-primary);
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.18s ease;
}

.efour-product-action:hover {
  background: var(--efour-primary);
  color: #ffffff;
}

/* Order Status Card */
.efour-order-card {
  background: #ffffff;
  border: 1px solid var(--efour-border);
  border-left: 3.5px solid var(--efour-primary);
  border-radius: 10px;
  padding: 12px;
  margin-top: 8px;
  font-size: 12.5px;
}

.efour-order-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-weight: 600;
}

.efour-order-status-pill {
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 600;
  background: #e0f2fe;
  color: #0369a1;
}

.efour-order-status-pill.processing { background: #fef3c7; color: #b45309; }
.efour-order-status-pill.completed { background: #dcfce7; color: #15803d; }
.efour-order-status-pill.cancelled { background: #fee2e2; color: #b91c1c; }

/* Quick Action Chips */
.efour-chips-container {
  padding: 8px 14px;
  background: #ffffff;
  border-top: 1px solid var(--efour-border-subtle);
  display: flex;
  gap: 7px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.efour-chips-container::-webkit-scrollbar {
  display: none;
}

.efour-chip {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.efour-chip:hover {
  background: #ffffff;
  border-color: var(--efour-primary);
  color: var(--efour-primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

/* Unified Capsule Input Bar */
.efour-chat-footer {
  padding: 10px 14px 14px 14px;
  background: #ffffff;
}

.efour-input-capsule {
  display: flex;
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--efour-border);
  border-radius: 24px;
  padding: 3px 4px 3px 14px;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.efour-input-capsule:focus-within {
  border-color: var(--efour-primary);
  box-shadow: 0 0 0 3px rgba(0, 125, 113, 0.1);
}

#efour-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 7px 0;
  font-size: 13.5px;
  color: var(--efour-text-dark);
  outline: none;
  font-family: inherit;
  min-width: 0;
}

#efour-input::placeholder {
  color: #94a3b8;
  font-size: 13px;
}

.efour-input-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}

.efour-mic-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s ease;
}

.efour-mic-btn:hover {
  color: var(--efour-primary);
  background: #f1f5f9;
}

.efour-mic-btn.recording {
  color: #ef4444;
  background: #fee2e2;
  animation: efourBlink 1s infinite;
}

@keyframes efourBlink {
  50% { opacity: 0.4; }
}

.efour-send-btn {
  background: var(--efour-primary);
  color: #ffffff;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.efour-send-btn:hover {
  background: var(--efour-primary-hover);
  transform: scale(1.04);
}

.efour-send-btn:disabled {
  background: #e2e8f0;
  color: #94a3b8;
  cursor: not-allowed;
  transform: none;
}

.efour-send-btn svg {
  width: 15px;
  height: 15px;
}

/* Typing Indicator */
.efour-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 9px 12px;
  background: #ffffff;
  border: 1px solid var(--efour-border-subtle);
  border-radius: 14px;
  width: fit-content;
}

.efour-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--efour-primary);
  animation: efourBounce 1.4s infinite ease-in-out both;
}

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

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

/* Mobile Responsiveness */
@media (max-width: 480px) {
  #efour-ai-container {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  #efour-ai-launcher {
    bottom: 16px;
    right: 16px;
  }
}
