/* ==========================================================================
   MediMate AI Chatbot - Design System & Component Styles
   Mirrors Flutter MediMate UX for MediHelpWeb
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Floating Action Button (FAB)
   -------------------------------------------------------------------------- */
.mm-fab {
  position: fixed !important;
  bottom: 2rem !important;
  right: 2rem !important;
  left: auto !important;
  width: 68px !important;
  height: 68px !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, #06b6d4 0%, #14b8a6 100%) !important;
  box-shadow: 0 10px 25px -4px rgba(6, 182, 212, 0.45), 0 4px 12px -2px rgba(20, 184, 166, 0.35) !important;
  border: none !important;
  cursor: pointer !important;
  z-index: 9990 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  overflow: visible !important;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.28s ease !important;
  outline: none !important;
  -webkit-tap-highlight-color: transparent !important;
}

html[dir="rtl"] .mm-fab,
body[data-rtl="true"] .mm-fab {
  right: auto !important;
  left: 2rem !important;
}

.mm-fab:hover {
  transform: scale(1.08) translateY(-3px) !important;
  box-shadow: 0 14px 30px -4px rgba(6, 182, 212, 0.55), 0 6px 16px -2px rgba(20, 184, 166, 0.45) !important;
}

.mm-fab:active {
  transform: scale(0.94) !important;
}

.mm-fab__glow {
  position: absolute !important;
  inset: -3px !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.6), rgba(20, 184, 166, 0.6)) !important;
  z-index: -1 !important;
  opacity: 0.6 !important;
  filter: blur(6px) !important;
  animation: mm-pulse 3s infinite ease-in-out !important;
}

.mm-fab__fallback {
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: 36px !important;
  height: 36px !important;
  pointer-events: none !important;
  z-index: 1 !important;
  transition: opacity 0.3s ease !important;
}

.mm-fab.has-lottie .mm-fab__fallback {
  opacity: 0 !important;
  display: none !important;
}

.mm-fab__lottie {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  pointer-events: none !important;
  z-index: 2 !important;
  border-radius: 50% !important;
  overflow: hidden !important;
}

.mm-fab__lottie svg {
  width: 100% !important;
  height: 100% !important;
  transform: scale(1.4) !important;
  transform-origin: center center !important;
  display: block !important;
  pointer-events: none !important;
}

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

/* --------------------------------------------------------------------------
   Tooltip on Hover
   -------------------------------------------------------------------------- */
.mm-fab__tooltip {
  position: absolute !important;
  right: calc(100% + 14px) !important;
  top: 50% !important;
  transform: translateY(-50%) translateX(6px) !important;
  background: rgba(10, 17, 30, 0.95) !important;
  backdrop-filter: blur(14px) !important;
  -webkit-backdrop-filter: blur(14px) !important;
  color: #f8fafc !important;
  font-family: inherit !important;
  font-size: 0.825rem !important;
  font-weight: 600 !important;
  letter-spacing: -0.01em !important;
  white-space: nowrap !important;
  padding: 0.5rem 0.85rem !important;
  border-radius: 9999px !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  box-shadow: 0 10px 25px -4px rgba(0, 0, 0, 0.5), 0 0 15px rgba(6, 182, 212, 0.2) !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  display: flex !important;
  align-items: center !important;
  gap: 0.4rem !important;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.22s !important;
  z-index: 10000 !important;
}

.mm-fab__tooltip::after {
  content: "" !important;
  position: absolute !important;
  top: 50% !important;
  right: -5px !important;
  transform: translateY(-50%) rotate(45deg) !important;
  width: 8px !important;
  height: 8px !important;
  background: rgba(10, 17, 30, 0.95) !important;
  border-right: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.12) !important;
}

.mm-fab:hover .mm-fab__tooltip,
.mm-fab:focus-visible .mm-fab__tooltip {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(-50%) translateX(0) !important;
}

html[dir="rtl"] .mm-fab__tooltip,
body[data-rtl="true"] .mm-fab__tooltip {
  right: auto !important;
  left: calc(100% + 14px) !important;
  transform: translateY(-50%) translateX(-6px) !important;
}

html[dir="rtl"] .mm-fab__tooltip::after,
body[data-rtl="true"] .mm-fab__tooltip::after {
  right: auto !important;
  left: -5px !important;
  border-right: none !important;
  border-top: none !important;
  border-left: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12) !important;
}

html[dir="rtl"] .mm-fab:hover .mm-fab__tooltip,
html[dir="rtl"] .mm-fab:focus-visible .mm-fab__tooltip,
body[data-rtl="true"] .mm-fab:hover .mm-fab__tooltip,
body[data-rtl="true"] .mm-fab:focus-visible .mm-fab__tooltip {
  transform: translateY(-50%) translateX(0) !important;
}

/* --------------------------------------------------------------------------
   2. Page-Locking Backdrop
   -------------------------------------------------------------------------- */
.mm-backdrop {
  position: fixed !important;
  inset: 0 !important;
  background: rgba(4, 9, 18, 0.72) !important;
  backdrop-filter: blur(6px) !important;
  -webkit-backdrop-filter: blur(6px) !important;
  z-index: 9995 !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transition: opacity 0.32s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.32s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.mm-backdrop.mm-active {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important; /* Intercepts and completely blocks clicks to underlying page */
}

/* --------------------------------------------------------------------------
   3. Modal Sheet (Half-Screen 1-Column Split)
   -------------------------------------------------------------------------- */
.mm-sheet {
  position: fixed !important;
  top: 0 !important;
  bottom: 0 !important;
  right: 0 !important;
  left: auto !important;
  height: 100vh !important;
  height: 100dvh !important;
  width: 50vw !important;
  min-width: 480px !important;
  max-width: 800px !important;
  z-index: 9999 !important;
  background: rgba(10, 17, 30, 0.94) !important;
  backdrop-filter: blur(28px) !important;
  -webkit-backdrop-filter: blur(28px) !important;
  border-left: 1px solid rgba(255, 255, 255, 0.08) !important;
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.5) !important;
  display: flex !important;
  flex-direction: column !important;
  transform: translateX(100%) !important;
  transition: transform 0.36s cubic-bezier(0.16, 1, 0.3, 1) !important;
  color: #f8fafc !important;
  overflow: hidden !important;
}

html[data-theme="light"] .mm-sheet {
  background: rgba(248, 250, 252, 0.96) !important;
  border-left: 1px solid rgba(0, 0, 0, 0.08) !important;
  box-shadow: -10px 0 35px rgba(0, 0, 0, 0.15) !important;
  color: #0f172a !important;
}

html[dir="rtl"] .mm-sheet {
  right: auto !important;
  left: 0 !important;
  border-left: none !important;
  border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
  box-shadow: 12px 0 40px rgba(0, 0, 0, 0.5) !important;
  transform: translateX(-100%) !important;
}

html[dir="rtl"][data-theme="light"] .mm-sheet {
  border-right: 1px solid rgba(0, 0, 0, 0.08) !important;
}

.mm-sheet.mm-open {
  transform: translateX(0) !important;
}

/* Responsive: Full width on mobile */
@media (max-width: 767px) {
  .mm-sheet {
    width: 100vw;
    min-width: 100vw;
    max-width: 100vw;
    border-left: none;
    border-right: none;
  }
}

/* --------------------------------------------------------------------------
   4. Header Bar
   -------------------------------------------------------------------------- */
.mm-header {
  height: 72px;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  flex-shrink: 0;
}

html[data-theme="light"] .mm-header {
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.7);
}

.mm-header__left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.mm-header__avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(20, 184, 166, 0.2));
  border: 1px solid rgba(6, 182, 212, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(6, 182, 212, 0.2);
}

.mm-header__titles {
  display: flex;
  flex-direction: column;
}

.mm-header__title {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, #38bdf8 0%, #2dd4bf 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.mm-header__subtitle {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #38bdf8;
  opacity: 0.85;
}

html[data-theme="light"] .mm-header__subtitle {
  color: #0284c7;
}

.mm-header__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mm-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}

html[data-theme="light"] .mm-icon-btn {
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: #475569;
}

.mm-icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  transform: translateY(-1px);
}

html[data-theme="light"] .mm-icon-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  color: #0f172a;
}

.mm-icon-btn--mode {
  color: #38bdf8;
}

.mm-icon-btn--off {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #ef4444;
}

.mm-icon-btn--off:hover {
  background: #ef4444;
  border-color: #ef4444;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.45);
}

/* --------------------------------------------------------------------------
   5. Chat Body & Empty State
   -------------------------------------------------------------------------- */
.mm-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  scroll-behavior: smooth;
}

.mm-empty {
  margin: auto;
  max-width: 440px;
  text-align: center;
  padding: 2rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.mm-empty__anim {
  width: 150px;
  height: 150px;
  margin-bottom: 1rem;
}

.mm-empty__title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: #f1f5f9;
}

html[data-theme="light"] .mm-empty__title {
  color: #0f172a;
}

.mm-empty__desc {
  font-size: 0.88rem;
  line-height: 1.55;
  color: #94a3b8;
  margin-bottom: 1.25rem;
}

html[data-theme="light"] .mm-empty__desc {
  color: #64748b;
}

.mm-empty__tour-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  border-radius: 9999px;
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: #38bdf8;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 1.75rem;
}

.mm-empty__tour-btn:hover {
  background: rgba(6, 182, 212, 0.22);
  transform: translateY(-1px);
}

.mm-empty__prompts-title {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 0.75rem;
  align-self: flex-start;
}

.mm-prompt-chips {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
}

.mm-prompt-chip {
  text-align: left;
  padding: 0.75rem 1rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: #cbd5e1;
  font-size: 0.85rem;
  line-height: 1.45;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

html[dir="rtl"] .mm-prompt-chip {
  text-align: right;
}

html[data-theme="light"] .mm-prompt-chip {
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(0, 0, 0, 0.06);
  color: #334155;
}

.mm-prompt-chip:hover {
  background: rgba(6, 182, 212, 0.12);
  border-color: rgba(6, 182, 212, 0.35);
  color: #38bdf8;
  transform: translateX(3px);
}

html[dir="rtl"] .mm-prompt-chip:hover {
  transform: translateX(-3px);
}

/* --------------------------------------------------------------------------
   6. Messages (User & Assistant)
   -------------------------------------------------------------------------- */
.mm-msg {
  display: flex;
  flex-direction: column;
  animation: mm-fade-in 0.25s ease-out;
}

@keyframes mm-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.mm-msg--user {
  align-self: flex-end;
  max-width: 85%;
}

.mm-msg--assistant {
  align-self: flex-start;
  max-width: 94%;
}

.mm-msg__bubble {
  padding: 0.85rem 1.15rem;
  border-radius: 18px;
  font-size: 0.92rem;
  line-height: 1.6;
  position: relative;
  word-break: break-word;
}

.mm-msg--user .mm-msg__bubble {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.22) 0%, rgba(20, 184, 166, 0.32) 100%);
  border: 1px solid rgba(6, 182, 212, 0.35);
  border-bottom-right-radius: 4px;
  color: #f1f5f9;
}

html[dir="rtl"] .mm-msg--user .mm-msg__bubble {
  border-bottom-right-radius: 18px;
  border-bottom-left-radius: 4px;
}

html[data-theme="light"] .mm-msg--user .mm-msg__bubble {
  background: linear-gradient(135deg, #0284c7 0%, #0d9488 100%);
  border: none;
  color: #ffffff;
}

.mm-msg--assistant .mm-msg__bubble {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom-left-radius: 4px;
  color: #f8fafc;
}

html[dir="rtl"] .mm-msg--assistant .mm-msg__bubble {
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 4px;
}

html[data-theme="light"] .mm-msg--assistant .mm-msg__bubble {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.07);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  color: #0f172a;
}

/* Assistant Markdown Styling */
.mm-markdown h1, .mm-markdown h2, .mm-markdown h3, .mm-markdown h4 {
  font-weight: 700;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  color: #38bdf8;
}

html[data-theme="light"] .mm-markdown h1,
html[data-theme="light"] .mm-markdown h2,
html[data-theme="light"] .mm-markdown h3,
html[data-theme="light"] .mm-markdown h4 {
  color: #0284c7;
}

.mm-markdown h1:first-child, .mm-markdown h2:first-child, .mm-markdown h3:first-child {
  margin-top: 0;
}

.mm-markdown p {
  margin-bottom: 0.75rem;
}

.mm-markdown p:last-child {
  margin-bottom: 0;
}

.mm-markdown ul, .mm-markdown ol {
  margin: 0.5rem 0 0.85rem 1.25rem;
  padding: 0;
}

html[dir="rtl"] .mm-markdown ul, html[dir="rtl"] .mm-markdown ol {
  margin: 0.5rem 1.25rem 0.85rem 0;
}

.mm-markdown li {
  margin-bottom: 0.35rem;
}

.mm-markdown strong {
  font-weight: 700;
  color: #e2e8f0;
}

html[data-theme="light"] .mm-markdown strong {
  color: #0f172a;
}

.mm-markdown code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85em;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.2em 0.4em;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.mm-markdown pre {
  background: rgba(0, 0, 0, 0.35);
  padding: 0.75rem;
  border-radius: 10px;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin: 0.75rem 0;
}

.mm-markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-size: 0.85rem;
}

.mm-markdown th, .mm-markdown td {
  padding: 0.5rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: left;
}

html[dir="rtl"] .mm-markdown th, html[dir="rtl"] .mm-markdown td {
  text-align: right;
}

.mm-markdown th {
  background: rgba(255, 255, 255, 0.06);
  color: #38bdf8;
}

/* Citations Pill Box */
.mm-citations {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.mm-citations__label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  color: #10b981;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.mm-citation-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: #38bdf8;
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.2);
  padding: 0.3rem 0.65rem;
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.18s ease;
  width: fit-content;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mm-citation-pill:hover {
  background: rgba(6, 182, 212, 0.18);
  border-color: rgba(6, 182, 212, 0.45);
}

/* Message Meta & Actions */
.mm-msg__actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.35rem;
  padding: 0 0.4rem;
}

.mm-action-btn {
  background: none;
  border: none;
  color: #64748b;
  font-size: 0.75rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  transition: color 0.18s ease, background 0.18s ease;
}

.mm-action-btn:hover {
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.05);
}

html[data-theme="light"] .mm-action-btn:hover {
  color: #0f172a;
  background: rgba(0, 0, 0, 0.04);
}

/* Thinking Indicator */
.mm-thinking {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #38bdf8;
  font-size: 0.85rem;
  padding: 0.25rem 0;
}

.mm-thinking__dots {
  display: flex;
  gap: 0.25rem;
}

.mm-thinking__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #38bdf8;
  animation: mm-bounce 1.4s infinite ease-in-out both;
}

.mm-thinking__dot:nth-child(1) { animation-delay: -0.32s; }
.mm-thinking__dot:nth-child(2) { animation-delay: -0.16s; }

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

/* --------------------------------------------------------------------------
   7. Input Footer Area
   -------------------------------------------------------------------------- */
.mm-footer {
  padding: 0.85rem 1.25rem 1.15rem;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
}

html[data-theme="light"] .mm-footer {
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.7);
}

.mm-input-box {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  padding: 0.4rem 0.6rem 0.4rem 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

html[dir="rtl"] .mm-input-box {
  padding: 0.4rem 1rem 0.4rem 0.6rem;
}

html[data-theme="light"] .mm-input-box {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.mm-input-box:focus-within {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}

.mm-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: #f8fafc;
  font-size: 0.92rem;
  line-height: 1.45;
  max-height: 140px;
  min-height: 24px;
  padding: 0.35rem 0;
  font-family: inherit;
}

html[data-theme="light"] .mm-textarea {
  color: #0f172a;
}

.mm-textarea::placeholder {
  color: #64748b;
}

.mm-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, #06b6d4 0%, #14b8a6 100%);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  flex-shrink: 0;
  outline: none;
}

.mm-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

.mm-send-btn:not(:disabled):hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.4);
}

.mm-send-btn--stop {
  background: #ef4444 !important;
  color: #ffffff;
  animation: mm-pulse 1.8s infinite ease-in-out;
}

.mm-disclaimer {
  font-size: 0.72rem;
  color: #64748b;
  text-align: center;
  line-height: 1.35;
}

/* --------------------------------------------------------------------------
   8. Sub-Dialogs (Save Prompt, Modes, History, Instructions)
   -------------------------------------------------------------------------- */
.mm-modal-overlay {
  position: absolute !important;
  inset: 0 !important;
  background: rgba(4, 9, 18, 0.75) !important;
  backdrop-filter: blur(10px) !important;
  -webkit-backdrop-filter: blur(10px) !important;
  z-index: 10005 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.mm-modal-overlay.mm-active {
  opacity: 1;
  visibility: visible;
}

.mm-dialog {
  width: 100%;
  max-width: 440px;
  border-radius: 24px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

html[data-theme="light"] .mm-dialog {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.mm-modal-overlay.mm-active .mm-dialog {
  transform: scale(1);
}

.mm-dialog__title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 0.65rem;
}

html[data-theme="light"] .mm-dialog__title {
  color: #0f172a;
}

.mm-dialog__body {
  font-size: 0.9rem;
  line-height: 1.55;
  color: #94a3b8;
  margin-bottom: 1.5rem;
}

html[data-theme="light"] .mm-dialog__body {
  color: #64748b;
}

.mm-dialog__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

.mm-btn {
  padding: 0.6rem 1.15rem;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  border: none;
  outline: none;
}

.mm-btn--primary {
  background: linear-gradient(135deg, #06b6d4 0%, #14b8a6 100%);
  color: #ffffff;
}

.mm-btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.35);
}

.mm-btn--danger {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

.mm-btn--danger:hover {
  background: #ef4444;
  color: #ffffff;
}

.mm-btn--ghost {
  background: transparent;
  color: #94a3b8;
}

.mm-btn--ghost:hover {
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.05);
}

/* Modes Selection List */
.mm-mode-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

html[data-theme="light"] .mm-mode-card {
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.mm-mode-card:hover:not(.mm-mode-card--disabled) {
  border-color: rgba(6, 182, 212, 0.4);
  background: rgba(6, 182, 212, 0.08);
}

.mm-mode-card--active {
  border-color: #38bdf8 !important;
  background: rgba(6, 182, 212, 0.12) !important;
}

.mm-mode-card--disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.mm-mode-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 182, 212, 0.15);
  color: #38bdf8;
  flex-shrink: 0;
}

.mm-mode-card:nth-child(2) .mm-mode-icon {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.mm-mode-card:nth-child(3) .mm-mode-icon {
  background: rgba(168, 85, 247, 0.15);
  color: #a855f7;
}

.mm-mode-details {
  flex: 1;
}

.mm-mode-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
  color: #f8fafc;
}

html[data-theme="light"] .mm-mode-title {
  color: #0f172a;
}

.mm-mode-desc {
  font-size: 0.78rem;
  color: #94a3b8;
  line-height: 1.35;
}

/* History Thread List */
.mm-history-list {
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
}

.mm-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  cursor: pointer;
  transition: all 0.18s ease;
}

.mm-history-item:hover {
  background: rgba(6, 182, 212, 0.1);
  border-color: rgba(6, 182, 212, 0.3);
}

.mm-history-item__left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  overflow: hidden;
}

.mm-history-item__title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

html[data-theme="light"] .mm-history-item__title {
  color: #0f172a;
}

.mm-history-item__date {
  font-size: 0.72rem;
  color: #64748b;
  margin-top: 0.15rem;
}

.mm-history-item__del {
  color: #ef4444;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 8px;
  opacity: 0.6;
  transition: opacity 0.18s ease, background 0.18s ease;
}

.mm-history-item__del:hover {
  opacity: 1;
  background: rgba(239, 68, 68, 0.12);
}

/* Instructions / Tour Dialog */
.mm-instructions {
  max-height: 520px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.mm-inst-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.65rem;
  margin-top: 0.75rem;
}

.mm-inst-card {
  padding: 0.75rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 0.8rem;
  line-height: 1.4;
  color: #cbd5e1;
}

html[data-theme="light"] .mm-inst-card {
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid rgba(0, 0, 0, 0.06);
  color: #334155;
}
