/* ============================================================
   Microcessor Design System — Bootstrap Overrides
   ============================================================
   Brand: #5D9288 (teal green)
   Text:  #414244 (dark gray)
   BG:    #F7F6F3 (warm off-white)
   ============================================================ */

:root, [data-theme="light"] {
  /* Brand overrides for Bootstrap */
  --bs-primary: #5D9288;
  --bs-primary-rgb: 93, 146, 136;
  --bs-body-bg: #F7F6F3;
  --bs-body-color: #414244;
  --bs-font-sans-serif: 'Inter', system-ui, -apple-system, sans-serif;
  --bs-border-color: #E2E0DB;

  /* Custom tokens */
  --brand: #5D9288;
  --brand-dark: #4A7A70;
  --brand-darker: #3A6259;
  --brand-light: #7DB0A5;
  --brand-subtle: #E8F2EF;
  --focus: #9B59B6;
  --focus-dark: #8244A0;
  --focus-subtle: #F0E4F7;
  --danger: #C0392B;
  --danger-dark: #A93226;
  --danger-subtle: #FADBD8;
  --text-primary: #414244;
  --text-secondary: #6B6D6F;
  --text-muted: #9B9DA0;
  --bg: #F7F6F3;
  --bg-sunken: #EFEEE9;
  --surface: #fff;
  --bg-hover: #f1f3f5;
  --surface-hover: rgba(0, 0, 0, 0.03);
  --logo-url: url('/public/micro.svg');
  color-scheme: light;
}

[data-theme="dark"] {
  --bs-primary: #7DB0A5;
  --bs-primary-rgb: 125, 176, 165;
  --bs-body-bg: #1A1B1E;
  --bs-body-color: #E0DED9;
  --bs-border-color: #2E3035;

  --brand: #7DB0A5;
  --brand-dark: #5D9288;
  --brand-darker: #4A7A70;
  --brand-light: #9BC4BC;
  --brand-subtle: #1E2C29;
  --focus: #BB86D6;
  --focus-dark: #9B59B6;
  --focus-subtle: #2D1F36;
  --danger: #E74C3C;
  --danger-dark: #C0392B;
  --danger-subtle: #3B1C1A;
  --text-primary: #E0DED9;
  --text-secondary: #A3A1A0;
  --text-muted: #6B6D6F;
  --bg: #1A1B1E;
  --bg-sunken: #141517;
  --surface: #232529;
  --bg-hover: #2a2c30;
  --surface-hover: rgba(255, 255, 255, 0.04);
  --logo-url: url('/public/microw.svg');
  color-scheme: dark;
}

body {
  font-family: var(--bs-font-sans-serif);
  background-color: var(--bg);
  color: var(--text-primary);
}

/* --- Alpine.js: hide elements until initialized --- */
[x-cloak] { display: none !important; }

/* --- Bootstrap button override --- */
.btn-primary {
  --bs-btn-bg: var(--brand);
  --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand-dark);
  --bs-btn-hover-border-color: var(--brand-dark);
  --bs-btn-active-bg: var(--brand-darker);
  --bs-btn-active-border-color: var(--brand-darker);
  --bs-btn-disabled-bg: var(--brand);
  --bs-btn-disabled-border-color: var(--brand);
}

.btn-outline-danger {
  --bs-btn-color: var(--danger);
  --bs-btn-border-color: var(--danger);
  --bs-btn-hover-bg: var(--danger);
  --bs-btn-hover-border-color: var(--danger);
  --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: var(--danger-dark);
  --bs-btn-active-border-color: var(--danger-dark);
}

.btn-outline-primary {
  --bs-btn-color: var(--brand);
  --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand);
  --bs-btn-hover-border-color: var(--brand);
  --bs-btn-active-bg: var(--brand-dark);
  --bs-btn-active-border-color: var(--brand-dark);
}

/* --- Links --- */
a {
  color: var(--brand);
}
a:hover {
  color: var(--brand-dark);
}

/* --- Navbar --- */
.navbar {
  background: color-mix(in srgb, var(--bg) 92%, transparent) !important;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--bs-border-color);
}

/* --- Dark mode: surface colors --- */
[data-theme="dark"] .card,
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] .input-group-text { background-color: var(--surface); color: var(--text-primary); border-color: var(--bs-border-color); }
[data-theme="dark"] .form-control::placeholder { color: var(--text-muted); }
[data-theme="dark"] .btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); }
[data-theme="dark"] .text-muted { color: var(--text-muted) !important; }
[data-theme="dark"] .text-secondary { color: var(--text-secondary) !important; }
[data-theme="dark"] .border-bottom, [data-theme="dark"] .border-top { border-color: var(--bs-border-color) !important; }
[data-theme="dark"] .form-nested-overlay { background: rgba(0, 0, 0, 0.72); }

/* --- Form focus ring --- */
.form-control:focus,
.form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 0.2rem rgba(93, 146, 136, 0.25);
}

/* --- Cards --- */
.card {
  border-color: var(--bs-border-color);
  border-radius: 0.75rem;
  background: var(--surface);
  transition: box-shadow 0.2s ease;
}
.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

/* --- Brand helpers --- */
.text-brand { color: var(--brand) !important; }
.bg-brand { background-color: var(--brand) !important; }
.bg-brand-subtle { background-color: var(--brand-subtle) !important; }
.border-brand { border-color: var(--brand) !important; }

/* --- Badge overrides --- */
.badge.bg-brand-subtle {
  color: var(--brand-dark);
}

/* --- Custom: app icon box --- */
.app-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-subtle);
  color: var(--brand);
  border-radius: 0.5rem;
}

/* --- Custom: numbered steps --- */
.step-number {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 1.125rem;
  border-radius: 50%;
  flex-shrink: 0;
}

/* --- Custom: code block --- */
.code-block {
  background: #1E1E2E;
  color: #CDD6F4;
  border-radius: 0.75rem;
  padding: 1.5rem;
  overflow-x: auto;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.875rem;
  line-height: 1.6;
}
.code-block .comment { color: #6C7086; }
.code-block .keyword { color: #CBA6F7; }
.code-block .string { color: #A6E3A1; }
.code-block .function { color: #89B4FA; }
.code-block .punctuation { color: #9399B2; }

/* --- Custom: CTA banner --- */
.cta-banner {
  background: var(--brand);
  border-radius: 1rem;
  color: #fff;
}
.cta-banner h2 { color: #fff; }
.cta-banner p { color: rgba(255, 255, 255, 0.8); }

.btn-white {
  background: #fff;
  color: var(--brand);
  border: none;
  font-weight: 600;
}
.btn-white:hover {
  background: var(--bg);
  color: var(--brand-dark);
}

/* --- Pricing card --- */
.pricing-card .price {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--brand);
}
.pricing-card .price-unit {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 400;
}
.pricing-card .free-tier {
  font-size: 0.8rem;
  color: #3D8B37;
  font-weight: 500;
}

/* --- Ecosystem pills --- */
.eco-node {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  background: #fff;
  border: 1px solid var(--bs-border-color);
  border-radius: 50rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  transition: all 0.2s ease;
}
.eco-node:hover {
  border-color: var(--brand);
  background: var(--brand-subtle);
  color: var(--brand-dark);
}
.eco-hub {
  padding: 0.6rem 1.5rem;
  background: var(--brand);
  color: #fff;
  border-radius: 50rem;
  font-weight: 700;
  font-size: 1rem;
  border: 2px solid var(--brand);
}
.eco-connector {
  width: 32px;
  height: 2px;
  background: var(--bs-border-color);
}

@media (max-width: 768px) {
  .eco-connector {
    display: none;
  }
}

/* ============================================================
   Form Drawer System
   ============================================================ */

/* --- Backdrop: translucent glass blur --- */
.form-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 1040;
  cursor: pointer;
}

/* --- Right-side drawer --- */
.form-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 50vw;
  min-width: 480px;
  max-width: 90vw;
  background: var(--bg);
  border-left: 1px solid var(--bs-border-color);
  z-index: 1050;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.08);
  animation: drawer-slide-in 0.2s ease-out;
}

@media (max-width: 768px) {
  .form-drawer {
    width: 100vw;
    min-width: 0;
  }
}

@keyframes drawer-slide-in {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

.form-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--bs-border-color);
}

.form-drawer-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.form-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.form-drawer-body::-webkit-scrollbar { display: none; }

.form-drawer-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
}
.form-drawer-close:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}
.form-drawer-close .material-symbols-outlined { font-size: 20px; }

.form-drawer-footer {
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--bs-border-color);
  display: flex;
  justify-content: space-between;
  margin-top: auto;
}

/* ============================================================
   Drawer System — platform-level slide-out panel
   Usage: overlay → drawer container → header / body
   Width: default (50vw, min 480px), .drawer-lg (70vw)
   ============================================================ */

.drawer-overlay {
  position: fixed; inset: 0; z-index: 1040;
  background: rgba(0,0,0,0.35);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: drawer-fade-in 0.15s ease;
  cursor: pointer;
}
@keyframes drawer-fade-in { from { opacity: 0; } to { opacity: 1; } }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 50vw; min-width: 480px; max-width: 100vw;
  z-index: 1050;
  background: var(--surface);
  box-shadow: -4px 0 24px rgba(0,0,0,0.1);
  display: flex; flex-direction: column;
  animation: drawer-slide-in 0.2s ease-out;
}
.drawer-lg { width: 70vw; }

.drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--bs-border-color);
  position: sticky; top: 0; z-index: 1;
  background: var(--surface);
}
.drawer-title {
  margin: 0; font-size: 0.9375rem; font-weight: 600;
  color: var(--text-primary);
}
.drawer-close {
  background: none; border: none; font-size: 1.25rem;
  color: var(--text-muted); cursor: pointer;
  padding: 0.25rem; line-height: 1; border-radius: 4px;
}
.drawer-close:hover { background: var(--bg-sunken); color: var(--text-primary); }

.drawer-body {
  flex: 1; overflow-y: auto; padding: 1.25rem;
  scrollbar-width: none; -ms-overflow-style: none;
}
.drawer-body::-webkit-scrollbar { display: none; }

@media (max-width: 768px) {
  .drawer { width: 100vw; min-width: 0; }
}

/* ============================================================
   Nested Form (Level 2) — form inside an existing drawer
   Usage: overlay covers the drawer body, toolbar + card on top
   ============================================================ */

.form-nested-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 50vw;
  min-width: 480px;
  max-width: 90vw;
  z-index: 1060;
  background: rgba(255, 255, 255, 0.82);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  display: flex;
  flex-direction: column;
  animation: drawer-fade-in 0.15s ease;
}

@media (max-width: 768px) {
  .form-nested-overlay {
    width: 100vw;
    min-width: 0;
  }
}

.form-nested-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0rem 9rem;
  margin-top: 9rem;
  margin-bottom: 1rem;
  flex-shrink: 0;
}

.form-nested-close {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border: none;
  border-radius: 6px;
  background: rgba(220, 38, 38, 0.1);
  color: #DC2626;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.form-nested-close:hover {
  background: rgba(220, 38, 38, 0.18);
}
.form-nested-close .material-symbols-outlined { font-size: 16px; }

.form-nested-save {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border: none;
  border-radius: 6px;
  background: rgba(61, 139, 55, 0.1);
  color: #3D8B37;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.form-nested-save:hover {
  background: rgba(61, 139, 55, 0.18);
}
.form-nested-save:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.form-nested-save .material-symbols-outlined { font-size: 16px; }

.form-nested-card {
  margin: 0 9rem 9rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--bs-border-color);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.form-nested-card .alert { margin: 0; }

/* ============================================================
   Centered Modal — shared across all apps
   Usage: .pf-modal-backdrop > .pf-modal > header / body / footer
   ============================================================ */

.pf-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1040;
}

.pf-modal {
  background: var(--surface);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  animation: pf-modal-in 0.15s ease;
}

.pf-modal-sm { max-width: 400px; }

@keyframes pf-modal-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.pf-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--bs-border-color);
}

.pf-modal-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.pf-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.pf-modal-close:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}
.pf-modal-close .material-symbols-outlined { font-size: 20px; }

.pf-modal-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.pf-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--bs-border-color);
}

/* --- Form groups --- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.form-group .form-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0;
}

.form-group .form-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* --- Sections --- */
.form-section {
  border: none;
  padding: 0;
  margin: 0.25rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.form-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0;
  padding-bottom: 0.375rem;
  border-bottom: 1px solid var(--bg-sunken);
}

.form-section-toggle {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-section-chevron {
  font-size: 0.625rem;
  transition: transform 0.2s;
}

.form-section-chevron.expanded {
  transform: rotate(180deg);
}

/* --- Radio cards --- */
.radio-cards {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.radio-card {
  flex: 1;
  min-width: 100px;
  border: 1.5px solid var(--bs-border-color);
  border-radius: 0.5rem;
  padding: 0.625rem 0.75rem;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  background: var(--surface);
}

.radio-card:hover {
  border-color: var(--brand-light);
}

.radio-card.active {
  border-color: var(--brand);
  background: var(--brand-subtle);
}

.radio-card-icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  margin-bottom: 0.125rem;
}

.radio-card.active .radio-card-icon {
  color: var(--brand);
}

.radio-card-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.radio-card-desc {
  font-size: 0.6875rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* --- Lookup field --- */
.lookup-wrapper {
  position: relative;
}

.lookup-clear {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
}

.lookup-clear:hover {
  color: var(--text-primary);
}

.lookup-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.375rem;
  margin-top: 0.25rem;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 10;
}

.lookup-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4375rem 0.75rem;
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--text-primary);
}

.lookup-option:hover,
.lookup-option.active {
  background: var(--brand-subtle);
  color: var(--brand-dark);
}

.lookup-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.lookup-initials {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  line-height: 1;
}

.lookup-option-icon {
  font-size: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.lookup-status {
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
}

.lookup-multi-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.375rem;
}

.lookup-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  background: var(--brand-subtle);
  color: var(--brand-dark);
  border-radius: 1rem;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.5;
}

.lookup-chip-remove {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.875rem;
  line-height: 1;
  color: var(--brand-dark);
  cursor: pointer;
  opacity: 0.6;
}

.lookup-chip-remove:hover {
  opacity: 1;
}

/* --- File upload zone --- */
.file-upload-zone {
  border: 2px dashed var(--bs-border-color);
  border-radius: var(--radius-sm, 6px);
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}
.file-upload-zone:hover,
.file-upload-zone.drag-over {
  border-color: var(--accent, #3B82F6);
  background: color-mix(in srgb, var(--accent, #3B82F6) 5%, transparent);
}
.file-upload-icon {
  font-size: 24px;
  color: var(--text-muted);
}
.file-upload-text {
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.file-upload-list {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.file-upload-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.5rem;
  background: var(--surface-hover, rgba(0,0,0,0.03));
  border-radius: var(--radius-sm, 6px);
  font-size: 0.8125rem;
  position: relative;
}
.file-upload-item-icon {
  font-size: 18px;
  color: var(--text-muted);
}
.file-upload-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-upload-item-size {
  color: var(--text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
}
.file-upload-item-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--bs-border-color);
  border-radius: 0 0 6px 6px;
  overflow: hidden;
}
.file-upload-item-bar {
  height: 100%;
  background: var(--accent, #3B82F6);
  transition: width 0.2s;
}
.file-upload-item-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.125rem;
}
.file-upload-item-remove:hover {
  color: var(--danger, #DC2626);
}

/* --- Hero specifics --- */
.hero-title {
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.05;
}

/* ============================================================
   MicroFilter — search-and-select input with closable badges
   ============================================================ */

.mf-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 34px;
  padding: 3px 8px;
  border: 1px solid var(--bs-border-color);
  border-radius: 6px;
  background: var(--surface);
  cursor: text;
  transition: border-color 0.15s;
}

.mf-wrap:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 0.2rem rgba(93, 146, 136, 0.25);
}

.mf-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.mf-icon .material-symbols-outlined {
  font-size: 18px;
  display: block;
}

.mf-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 6px 1px 8px;
  border-radius: 4px;
  background: var(--brand-subtle);
  color: var(--brand-dark);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.6;
}

.mf-badge-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border: none;
  background: transparent;
  color: var(--brand);
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  border-radius: 2px;
}

.mf-badge-close:hover {
  background: var(--brand);
  color: #fff;
}

.mf-input {
  flex: 1;
  min-width: 80px;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.8125rem;
  color: var(--text-primary);
  padding: 2px 0;
}

.mf-input::placeholder {
  color: var(--text-muted);
}

.mf-clear {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  border-radius: 2px;
}

.mf-clear:hover {
  color: var(--text-primary);
}

.mf-clear .material-symbols-outlined {
  font-size: 16px;
}

.mf-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--bs-border-color);
  border-radius: 6px;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 20;
}

.mf-option {
  padding: 6px 10px;
  font-size: 0.8125rem;
  color: var(--text-primary);
  cursor: pointer;
}

.mf-option:hover {
  background: var(--brand-subtle);
  color: var(--brand-dark);
}

.mf-status {
  padding: 8px 10px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
}

/* ============================================================
   is-loading — universal button spinner
   Works on circle, square, pill, or any shaped button.
   Dims the button and replaces content with a CSS spinner.
   ============================================================ */

.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
  opacity: 0.65;
}

.is-loading > * {
  visibility: hidden;
}

.is-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1em;
  height: 1em;
  margin: -0.5em 0 0 -0.5em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin-loading 0.6s linear infinite;
  opacity: 1;
  color: var(--text-muted);
}

/* White spinner on brand-colored buttons */
.is-loading[class*="btn-primary"]::after,
.is-loading.chat-send-btn::after,
.is-loading.chat-create-btn::after {
  color: #fff;
}

@keyframes spin-loading {
  to { transform: rotate(360deg); }
}

/* --- Section backgrounds --- */
.bg-white-section {
  background: #fff;
}

/* --- Footer --- */
footer h6 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
footer a {
  color: var(--text-secondary);
}
footer a:hover {
  color: var(--text-primary);
}
