/* Menu AI — overview cards + chat overlay */

.mai-overview {
  padding: 4px 2px 8px;
}

.mai-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.mai-brand-icon {
  font-size: 18px;
  line-height: 1;
}

.mai-brand-title {
  font-size: 14px;
  font-weight: 800;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.mai-intro {
  font-size: 14px;
  line-height: 1.55;
  color: #334155;
  margin: 0 0 14px;
}

.mai-page-links-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6366f1;
  margin-bottom: 8px;
}

.mai-page-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.mai-page-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid #c7d2fe;
  border-radius: 12px;
  background: linear-gradient(135deg, #f8faff 0%, #fff 100%);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.mai-page-link:hover {
  border-color: #818cf8;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.12);
}

.mai-page-link-emoji {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}

.mai-page-link-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mai-page-link-title {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
}

.mai-page-link-reason {
  font-size: 12px;
  color: #4338ca;
  font-weight: 600;
}

.mai-page-link-desc {
  font-size: 11px;
  color: #64748b;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mai-page-link-arrow {
  color: #6366f1;
  font-weight: 700;
  flex-shrink: 0;
}

.mai-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.mai-card {
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.mai-card:hover {
  border-color: #bfdbfe;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.1);
}

.mai-card-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.mai-card-emoji {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}

.mai-card-titles {
  flex: 1;
  min-width: 0;
}

.mai-card-name {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 2px;
  line-height: 1.3;
}

.mai-card-rest {
  font-size: 12px;
  color: #64748b;
}

.mai-card-reason {
  font-size: 12px;
  color: #475569;
  line-height: 1.45;
  margin-bottom: 10px;
}

.mai-card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mai-stat {
  text-align: center;
  padding: 6px 4px;
  background: #f8fafc;
  border-radius: 8px;
}

.mai-stat-val {
  display: block;
  font-size: 13px;
  font-weight: 800;
  color: #0f172a;
}

.mai-stat-lbl {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
  margin-top: 2px;
}

.mai-card-cta {
  display: block;
  margin-top: 10px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: #2563eb;
}

.mai-why {
  padding: 12px 14px;
  background: linear-gradient(135deg, #eff6ff, #faf5ff);
  border-radius: 10px;
  margin-bottom: 12px;
}

.mai-why-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6366f1;
  margin-bottom: 6px;
}

.mai-why-text {
  font-size: 13px;
  line-height: 1.55;
  color: #475569;
  margin: 0;
}

.mai-followups-label {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  margin-bottom: 8px;
}

.mai-followups {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.mai-followup {
  border: 1px solid #c7d2fe;
  background: #eef2ff;
  color: #4338ca;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s;
  text-decoration: none;
  display: inline-block;
}

.mai-followup:hover {
  background: #e0e7ff;
}

.mai-actions {
  display: flex;
  gap: 8px;
  border-top: 1px solid #f1f5f9;
  padding-top: 10px;
}

.mai-btn-expand {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.mai-btn-expand:hover {
  filter: brightness(1.05);
}

.mai-btn-search-all {
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

/* ── Chat overlay (GPT-style) ─────────────────────────────── */
.mai-overlay {
  position: fixed;
  inset: 0;
  z-index: 10050;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.mai-overlay.is-open {
  opacity: 1;
  pointer-events: all;
}

.mai-chat {
  width: 100%;
  max-width: 720px;
  background: #fff;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100vh;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.2);
}

.mai-chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
  flex-shrink: 0;
}

.mai-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #fff;
  color: #475569;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.mai-back:hover {
  border-color: #2563eb;
  color: #2563eb;
  background: #eff6ff;
}

.mai-chat-title {
  flex: 1;
  font-size: 15px;
  font-weight: 800;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.mai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  -webkit-overflow-scrolling: touch;
  background: #fafafa;
}

.mai-msg {
  max-width: 92%;
  animation: mai-fade-in 0.25s ease;
}

@keyframes mai-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.mai-msg--user {
  align-self: flex-end;
}

.mai-msg--user .mai-msg-bubble {
  background: #2563eb;
  color: #fff;
  border-radius: 16px 16px 4px 16px;
}

.mai-msg--assistant {
  align-self: flex-start;
  width: 100%;
  max-width: 100%;
}

.mai-msg--assistant .mai-msg-bubble {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px 16px 16px 4px;
  color: #334155;
}

.mai-msg-bubble {
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.6;
}

.mai-msg-bubble strong {
  color: #0f172a;
  font-weight: 700;
}

.mai-msg--assistant .mai-cards {
  margin-top: 12px;
  margin-bottom: 0;
}

.mai-msg--assistant .mai-followups {
  margin-top: 12px;
  margin-bottom: 0;
}

.mai-typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-size: 13px;
  color: #64748b;
}

.mai-typing-dots span {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: mai-dot 1.2s infinite;
}

.mai-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.mai-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes mai-dot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

.mai-input-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid #e2e8f0;
  background: #fff;
  flex-shrink: 0;
}

.mai-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  resize: none;
  min-height: 46px;
  max-height: 120px;
}

.mai-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.mai-send {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mai-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Search page block */
.mai-page-block {
  margin-bottom: 32px;
  padding: 20px;
  border: 1px solid #bfdbfe;
  border-radius: 16px;
  background: linear-gradient(180deg, #f8faff 0%, #fff 100%);
}

.mai-page-block .mai-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

@media (min-width: 769px) {
  .mai-overlay {
    padding: 24px 16px;
  }

  .mai-chat {
    height: auto;
    max-height: min(88vh, 820px);
    border-radius: 16px;
    overflow: hidden;
  }
}

@media (max-width: 768px) {
  .mai-card-stats {
    grid-template-columns: repeat(3, 1fr);
  }

  .mai-actions {
    flex-direction: column;
  }

  .mai-page-block .mai-cards {
    grid-template-columns: 1fr;
  }
}

/* Wider floating panel when Menu AI is active */
.ais-panel.ais-panel--menu-ai {
  max-height: min(75vh, 560px) !important;
}

@media (min-width: 640px) {
  .ais-panel.ais-panel--menu-ai {
    min-width: 380px;
  }
}
