/**
 * Roosis Quick Hub (P8.5) — Floating Dock & Command Drawer Styles
 * Herda design tokens do Roosis_Skin_Engine com fallbacks escuros de alto contraste.
 */

.roosis-qh-root {
  --roosis-qh-surface: var(--roosis-surface, #0F1B2D);
  --roosis-qh-text: var(--roosis-text, #E2E8F0);
  --roosis-qh-muted: var(--roosis-muted, #94A3B8);
  --roosis-qh-accent: var(--roosis-accent, #38BDF8);
  --roosis-qh-border: var(--roosis-border, rgba(56, 189, 248, 0.28));
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--roosis-qh-text);
  line-height: 1.4;
}

.roosis-qh-root *,
.roosis-qh-root *::before,
.roosis-qh-root *::after {
  box-sizing: border-box;
}

/* ── Launcher Button (Floating Dock) ──────────────────────────────────────── */
.roosis-qh-toggle {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 999990;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 16px;
  border-radius: 9999px;
  border: 1px solid var(--roosis-qh-border);
  background: var(--roosis-qh-surface);
  background: color-mix(in srgb, var(--roosis-qh-surface) 88%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--roosis-qh-text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow:
    0 10px 28px -6px rgba(2, 6, 23, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.05) inset;
  transition:
    left 0.24s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.2s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.roosis-qh-toggle:hover {
  transform: translateY(-2px);
  border-color: var(--roosis-qh-accent);
  box-shadow:
    0 14px 32px -6px rgba(2, 6, 23, 0.65),
    0 0 16px -4px color-mix(in srgb, var(--roosis-qh-accent) 45%, transparent);
}

.roosis-qh-toggle:active {
  transform: translateY(0);
}

.roosis-qh-toggle:focus-visible,
.roosis-qh-close:focus-visible,
.roosis-qh-item:focus-visible,
.roosis-qh-footer-link:focus-visible,
.roosis-qh-footer a:focus-visible {
  outline: 2px solid var(--roosis-qh-accent);
  outline-offset: 2px;
}

.roosis-qh-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--roosis-qh-accent);
  box-shadow: 0 0 8px var(--roosis-qh-accent);
}

.roosis-qh-brand {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

/* ── Role Badges ──────────────────────────────────────────────────────────── */
.roosis-qh-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid rgba(148, 163, 184, 0.32);
  background: rgba(148, 163, 184, 0.14);
  color: #CBD5E1;
}

.roosis-qh-badge--network_admin {
  border-color: rgba(251, 191, 36, 0.45);
  background: rgba(251, 191, 36, 0.16);
  color: #FDE68A;
}

.roosis-qh-badge--tenant_owner {
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(56, 189, 248, 0.16);
  color: #7DD3FC;
}

.roosis-qh-badge--affiliate {
  border-color: rgba(168, 85, 247, 0.45);
  background: rgba(168, 85, 247, 0.18);
  color: #D8B4FE;
}

.roosis-qh-badge--client_subscriber {
  border-color: rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.16);
  color: #6EE7B7;
}

.roosis-qh-badge--tenant_end_customer,
.roosis-qh-badge--visitor_hub {
  border-color: rgba(148, 163, 184, 0.32);
  background: rgba(148, 163, 184, 0.14);
  color: #CBD5E1;
}

/* ── Drawer Panel ─────────────────────────────────────────────────────────── */
.roosis-qh-panel {
  position: fixed;
  bottom: 76px;
  left: 24px;
  z-index: 999995;
  width: 340px;
  max-width: calc(100vw - 32px);
  max-height: 76vh;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  border: 1px solid var(--roosis-qh-border);
  background: var(--roosis-qh-surface);
  background: color-mix(in srgb, var(--roosis-qh-surface) 90%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--roosis-qh-text);
  box-shadow:
    0 24px 48px -12px rgba(2, 6, 23, 0.72),
    0 0 0 1px rgba(255, 255, 255, 0.06) inset;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(10px) scale(0.98);
  transform-origin: bottom left;
  transition:
    left 0.24s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.2s ease,
    transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0.2s ease;
}

.roosis-qh-panel.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* ── Smart Dock Offset (Zero Collision with #roosisia-flow-fab) ───────────── */
@media (min-width: 769px) {
  .roosis-qh-root.roosis-qh-has-flow .roosis-qh-toggle,
  .roosis-qh-root.roosis-qh-has-flow .roosis-qh-panel {
    left: 96px;
  }
}

/* ── Drawer Header ────────────────────────────────────────────────────────── */
.roosis-qh-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}

.roosis-qh-header-title,
.roosis-qh-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--roosis-qh-text);
  letter-spacing: 0.01em;
}

.roosis-qh-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(255, 255, 255, 0.04);
  color: var(--roosis-qh-muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.roosis-qh-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--roosis-qh-text);
  border-color: var(--roosis-qh-border);
}

/* ── Search Input ─────────────────────────────────────────────────────────── */
.roosis-qh-search-wrap {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

#roosisQhSearch,
.roosis-qh-search {
  width: 100%;
  min-height: 36px;
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(2, 6, 23, 0.32);
  color: var(--roosis-qh-text);
  font-family: inherit;
  font-size: 13px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#roosisQhSearch::placeholder,
.roosis-qh-search::placeholder {
  color: var(--roosis-qh-muted);
}

#roosisQhSearch:focus-visible,
.roosis-qh-search:focus-visible {
  outline: none;
  border-color: var(--roosis-qh-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--roosis-qh-accent) 22%, transparent);
}

/* ── Sections & Items ─────────────────────────────────────────────────────── */
.roosis-qh-sections {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.3) transparent;
}

.roosis-qh-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.roosis-qh-section[hidden] {
  display: none;
}

.roosis-qh-section-title {
  padding: 2px 8px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--roosis-qh-muted);
}

.roosis-qh-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.roosis-qh-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--roosis-qh-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    transform 0.15s ease;
}

.roosis-qh-item[hidden] {
  display: none;
}

.roosis-qh-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(148, 163, 184, 0.18);
  transform: translateX(2px);
  color: var(--roosis-qh-text);
}

.roosis-qh-item-main {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1 1 auto;
}

.roosis-qh-item-icon {
  flex-shrink: 0;
  font-size: 15px;
  line-height: 1;
}

.roosis-qh-item-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.roosis-qh-item-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.roosis-qh-item-desc {
  font-size: 11.5px;
  color: var(--roosis-qh-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.roosis-qh-item-badge {
  flex-shrink: 0;
  padding: 2px 7px;
  border-radius: 9999px;
  font-size: 10.5px;
  font-weight: 700;
  background: rgba(56, 189, 248, 0.14);
  color: var(--roosis-qh-accent);
  border: 1px solid color-mix(in srgb, var(--roosis-qh-accent) 32%, transparent);
}

.roosis-qh-item--highlight {
  background: rgba(56, 189, 248, 0.1);
  background: color-mix(in srgb, var(--roosis-qh-accent) 12%, transparent);
  border-color: var(--roosis-qh-border);
  font-weight: 600;
}

.roosis-qh-item--highlight:hover {
  background: color-mix(in srgb, var(--roosis-qh-accent) 18%, transparent);
  border-color: var(--roosis-qh-accent);
}

.roosis-qh-empty {
  padding: 20px 12px;
  text-align: center;
  font-size: 13px;
  color: var(--roosis-qh-muted);
}

/* ── Footer ───────────────────────────────────────────────────────────────── */
.roosis-qh-footer {
  padding: 10px 14px;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(2, 6, 23, 0.22);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--roosis-qh-muted);
}

.roosis-qh-footer:empty {
  display: none;
}

.roosis-qh-footer-link,
.roosis-qh-footer a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--roosis-qh-accent);
  text-decoration: none;
  font-weight: 600;
}

.roosis-qh-footer-link:hover,
.roosis-qh-footer a:hover {
  text-decoration: underline;
}

/* ── Mobile Layout (Below Chat FABs at bottom: 80px) ──────────────────────── */
@media (max-width: 768px) {
  .roosis-qh-toggle {
    bottom: 16px;
    left: 16px;
    padding: 8px 14px;
    font-size: 13px;
  }

  .roosis-qh-panel {
    bottom: 68px;
    left: 16px;
    right: 16px;
    width: auto;
    max-width: none;
    max-height: 70vh;
  }
}

/* ── Reduced Motion ───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .roosis-qh-toggle,
  .roosis-qh-panel,
  .roosis-qh-close,
  .roosis-qh-item,
  #roosisQhSearch {
    transition: none;
  }
}
