/* AINNA Market Intelligence — Target Alerts (shared)
   Desktop: side drawer + bottom FAB
   Mobile: slim top bar (default) → expand to ~1/4 panel → hide back to top bar
*/
.ma-root {
  --ma-green: #00d68f;
  --ma-red: #ff4d6d;
  --ma-cyan: #6ad9ff;
  --ma-gold: #f5b942;
  --ma-panel: rgba(8, 16, 30, 0.94);
  --ma-border: rgba(255, 255, 255, 0.12);
  --ma-text: #f4f7fb;
  --ma-muted: #93a4be;
  --ma-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  --ma-nav-h: 56px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  z-index: 9990;
}

html[data-theme='light'] .ma-root {
  --ma-panel: rgba(255, 255, 255, 0.96);
  --ma-border: rgba(12, 20, 35, 0.12);
  --ma-text: #0c1729;
  --ma-muted: #516078;
  --ma-shadow: 0 16px 48px rgba(20, 30, 55, 0.18);
}

/* ——— Desktop FAB (hidden on mobile) ——— */
.ma-fab {
  position: fixed;
  right: 18px;
  bottom: 88px;
  z-index: 9991;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1px solid var(--ma-border);
  background: linear-gradient(135deg, rgba(245, 185, 66, 0.95), rgba(255, 159, 28, 0.92));
  color: #111;
  font-weight: 700;
  font-size: 0.84rem;
  cursor: pointer;
  box-shadow: var(--ma-shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.ma-fab:hover { transform: translateY(-2px); }
.ma-fab-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #111;
  color: #fff;
  font-size: 0.72rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ma-fab-badge.is-zero { opacity: 0.45; }

/* ——— Mobile top bar (hidden on desktop) ——— */
.ma-topbar {
  display: none;
}

.ma-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9992;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.ma-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.ma-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(420px, 100vw);
  height: 100vh;
  z-index: 9993;
  background: var(--ma-panel);
  border-left: 1px solid var(--ma-border);
  box-shadow: var(--ma-shadow);
  color: var(--ma-text);
  transform: translateX(105%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.ma-panel.is-open { transform: translateX(0); }

.ma-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--ma-border);
  flex-shrink: 0;
}
.ma-panel-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
}
.ma-panel-head p {
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: var(--ma-muted);
  line-height: 1.4;
}
.ma-panel-head-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.ma-close {
  border: 1px solid var(--ma-border);
  background: transparent;
  color: var(--ma-text);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}
.ma-close-hide { display: none; }

.ma-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 16px 0;
  flex-shrink: 0;
}
.ma-tab {
  flex: 1;
  border: 1px solid var(--ma-border);
  background: rgba(255,255,255,0.04);
  color: var(--ma-muted);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.ma-tab.is-active {
  color: var(--ma-gold);
  border-color: rgba(245, 185, 66, 0.4);
  background: rgba(245, 185, 66, 0.12);
}

.ma-body {
  flex: 1;
  overflow: auto;
  padding: 14px 16px 24px;
  -webkit-overflow-scrolling: touch;
}

.ma-form {
  display: grid;
  gap: 10px;
  margin-bottom: 8px;
}
.ma-field label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ma-muted);
  margin-bottom: 4px;
  font-weight: 600;
}
.ma-field input,
.ma-field select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--ma-border);
  background: rgba(255,255,255,0.05);
  color: var(--ma-text);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 0.88rem;
}
.ma-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.ma-kind-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.ma-kind {
  border: 1px solid var(--ma-border);
  background: rgba(255,255,255,0.04);
  color: var(--ma-muted);
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  text-align: left;
  font-size: 0.8rem;
}
.ma-kind strong { display: block; margin-bottom: 2px; color: var(--ma-text); }
.ma-kind.is-target.is-active {
  border-color: rgba(0, 214, 143, 0.55);
  background: rgba(0, 214, 143, 0.12);
  color: var(--ma-green);
}
.ma-kind.is-warning.is-active {
  border-color: rgba(255, 77, 109, 0.55);
  background: rgba(255, 77, 109, 0.12);
  color: var(--ma-red);
}
.ma-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.ma-btn {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
}
.ma-btn-primary {
  background: linear-gradient(135deg, var(--ma-gold), #ff9f1c);
  color: #111;
  flex: 1;
}
.ma-btn-ghost {
  background: transparent;
  color: var(--ma-muted);
  border: 1px solid var(--ma-border);
}
.ma-note {
  font-size: 0.72rem;
  color: var(--ma-muted);
  line-height: 1.45;
  margin: 8px 0 0;
}

.ma-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ma-empty {
  text-align: center;
  color: var(--ma-muted);
  padding: 28px 12px;
  font-size: 0.86rem;
  line-height: 1.5;
}
.ma-card {
  border: 1px solid var(--ma-border);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255,255,255,0.03);
}
.ma-card.is-target { border-left: 3px solid var(--ma-green); }
.ma-card.is-warning { border-left: 3px solid var(--ma-red); }
.ma-card-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}
.ma-card-top strong {
  font-size: 0.92rem;
}
.ma-card-top span {
  font-size: 0.72rem;
  color: var(--ma-muted);
}
.ma-card-meta {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--ma-muted);
  line-height: 1.4;
}
.ma-status {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 999px;
}
.ma-status.active { background: rgba(106,217,255,0.14); color: var(--ma-cyan); }
.ma-status.triggered.target { background: rgba(0,214,143,0.15); color: var(--ma-green); }
.ma-status.triggered.warning { background: rgba(255,77,109,0.15); color: var(--ma-red); }
.ma-status.snoozed { background: rgba(245,185,66,0.15); color: var(--ma-gold); }
.ma-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.ma-mini {
  border: 1px solid var(--ma-border);
  background: transparent;
  color: var(--ma-text);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.74rem;
  cursor: pointer;
}
.ma-mini.danger { color: var(--ma-red); }

/* Toast stack */
.ma-toasts {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10020;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(380px, calc(100vw - 24px));
  pointer-events: none;
}
.ma-toast {
  pointer-events: auto;
  border-radius: 14px;
  border: 1px solid var(--ma-border);
  background: var(--ma-panel);
  color: var(--ma-text);
  box-shadow: var(--ma-shadow);
  padding: 14px 14px 12px;
  animation: ma-slide-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(14px);
}
.ma-toast.is-target { border-left: 4px solid var(--ma-green); }
.ma-toast.is-warning { border-left: 4px solid var(--ma-red); }
.ma-toast-title {
  font-weight: 800;
  font-size: 0.92rem;
  margin: 0 0 4px;
}
.ma-toast-body {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ma-muted);
  line-height: 1.45;
}
.ma-toast-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
@keyframes ma-slide-in {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Inline bell buttons on host pages */
.ma-inline-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--ma-border, rgba(255,255,255,0.12));
  background: rgba(255,255,255,0.04);
  color: var(--ma-muted, #93a4be);
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
}
.ma-inline-btn:hover {
  color: var(--ma-gold, #f5b942);
  border-color: rgba(245, 185, 66, 0.4);
}
.ma-inline-btn svg { width: 16px; height: 16px; }

/* ========== MOBILE: top bar + 1/4 panel ========== */
@media (max-width: 768px) {
  /* No bottom FAB — frees scroll area near globe */
  .ma-fab {
    display: none !important;
  }

  /* Slim top bar under mobile nav */
  .ma-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    position: fixed;
    top: calc(var(--ma-nav-h, 56px) + 6px);
    left: 10px;
    right: 10px;
    z-index: 10015;
    min-height: 40px;
    padding: 4px 6px 4px 4px;
    border-radius: 14px;
    border: 1px solid var(--ma-border);
    background: var(--ma-panel);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    color: var(--ma-text);
    pointer-events: auto;
  }

  .ma-topbar-main {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 0;
    background: linear-gradient(135deg, rgba(245, 185, 66, 0.95), rgba(255, 159, 28, 0.9));
    color: #111;
    font-weight: 800;
    font-size: 0.78rem;
    border-radius: 11px;
    padding: 7px 10px;
    cursor: pointer;
    flex-shrink: 0;
  }
  .ma-topbar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
  }
  .ma-topbar-icon svg { display: block; }
  .ma-topbar-label { letter-spacing: 0.01em; }
  .ma-topbar-main .ma-fab-badge {
    background: rgba(0,0,0,0.85);
    color: #fff;
    min-width: 18px;
    height: 18px;
    font-size: 0.68rem;
  }

  .ma-topbar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    flex: 1;
    justify-content: flex-end;
  }

  .ma-topbar-btn {
    border: 1px solid var(--ma-border);
    background: rgba(255,255,255,0.04);
    color: var(--ma-muted);
    border-radius: 8px;
    padding: 6px 8px;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
  }
  .ma-topbar-btn.is-active {
    color: var(--ma-gold);
    border-color: rgba(245, 185, 66, 0.45);
    background: rgba(245, 185, 66, 0.12);
  }

  .ma-topbar-hide {
    border: 1px solid var(--ma-border);
    background: transparent;
    color: var(--ma-text);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
  }

  /* Collapsed = top bar only (page fully scrollable) */
  .ma-root.ma-collapsed .ma-topbar-actions {
    display: none;
  }
  .ma-root.ma-collapsed .ma-topbar {
    left: auto;
    right: 10px;
    width: auto;
    max-width: calc(100vw - 80px);
    padding: 4px;
    /* keep clear of burger (left) */
  }
  .ma-root.ma-collapsed .ma-topbar-main {
    padding: 7px 12px;
  }

  /* Expanded panel: ~1/4 viewport under top bar — NOT full screen */
  .ma-panel {
    top: calc(var(--ma-nav-h, 56px) + 52px);
    left: 10px;
    right: 10px;
    width: auto;
    height: auto;
    max-height: 25vh; /* 1/4 screen */
    max-height: 25dvh;
    border-radius: 14px;
    border: 1px solid var(--ma-border);
    border-left: 1px solid var(--ma-border);
    box-shadow: var(--ma-shadow);
    transform: translateY(-6px) scale(0.98);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    z-index: 10014;
  }
  .ma-panel.is-open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
  }

  /* Head/tabs live in top bar on mobile — free vertical space for 1/4 panel */
  .ma-panel-head,
  .ma-tabs {
    display: none;
  }

  .ma-body {
    padding: 10px;
  }
  .ma-empty {
    padding: 12px 8px;
    font-size: 0.78rem;
  }
  .ma-card {
    padding: 8px 10px;
    border-radius: 10px;
  }
  .ma-card-top strong { font-size: 0.84rem; }
  .ma-card-meta { font-size: 0.74rem; margin-top: 4px; }
  .ma-card-actions { margin-top: 6px; }
  .ma-kind { padding: 7px 8px; font-size: 0.72rem; }
  .ma-field input,
  .ma-field select {
    padding: 7px 9px;
    font-size: 0.82rem;
  }
  .ma-btn { padding: 8px 10px; font-size: 0.78rem; }
  .ma-note { display: none; }

  /* No full-screen dim — page stays visible while scrolling */
  .ma-overlay {
    display: none !important;
  }

  /* Toasts: below chrome, not covering whole page */
  .ma-toasts {
    top: auto;
    bottom: 96px;
    right: 10px;
    left: 10px;
    width: auto;
  }

  /* Host pages: nudge main content so top bar doesn't cover hero */
  body.bursa-page,
  body.forex-page,
  body.brent-page {
    scroll-padding-top: var(--ma-chrome-offset, 110px);
  }
}
