/* ============================================================
   Portal2026 — Floating Menu Widget Styles
   ============================================================ */

/* ---- Container ---- */
.fm-container {
  position: fixed;
  z-index: 99990;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Main trigger button ---- */
.fm-trigger {
  position: relative;
  z-index: 99992;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  font-size: 1.5rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  padding: 0;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}

.fm-trigger:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
}

/* trigger does NOT rotate — only items animate */

.fm-trigger-img {
  width: 60%;
  height: 60%;
  object-fit: contain;
  pointer-events: none;
}

/* ---- Shape variants ---- */
.fm-shape-circle {
  border-radius: 50%;
}

.fm-shape-rounded {
  border-radius: 12px;
}

.fm-shape-square {
  border-radius: 0;
}

/* ---- Items wrapper ---- */
.fm-items {
  position: absolute;
  display: flex;
  gap: 10px;
  pointer-events: none;
  z-index: 99991;
}

.fm-items.fm-visible {
  pointer-events: auto;
}

/* Hide items until visible */
.fm-items:not(.fm-visible) .fm-item {
  opacity: 0;
  pointer-events: none;
}

/* ---- List mode layout direction ---- */
/* Auto direction: expand away from nearest edge */
.fm-mode-list {
  flex-direction: column-reverse; /* default: expand upward */
}

[data-corner="bottom-right"] .fm-mode-list,
[data-corner="bottom-left"] .fm-mode-list {
  bottom: calc(100% + 12px);
  flex-direction: column-reverse;
}

[data-corner="top-right"] .fm-mode-list,
[data-corner="top-left"] .fm-mode-list {
  top: calc(100% + 12px);
  flex-direction: column;
}

/* Horizontal centering for list mode */
[data-corner$="right"] .fm-mode-list {
  right: 0;
  align-items: flex-end;
}

[data-corner$="left"] .fm-mode-list {
  left: 0;
  align-items: flex-start;
}

/* ---- Surround mode ---- */
.fm-mode-surround {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
}

/* ---- Fullscreen mode ---- */
.fm-mode-fullscreen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 99993;
  pointer-events: none;
}

.fm-mode-fullscreen.fm-visible {
  pointer-events: auto;
}

/* ---- Fullscreen overlay ---- */
.fm-overlay {
  position: fixed;
  inset: 0;
  z-index: 99989;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.fm-overlay.fm-overlay-visible {
  pointer-events: auto;
}

/* ---- Individual item ---- */
.fm-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.fm-item.fm-item-visible {
  opacity: 1;
}

/* ---- Item button (or anchor) ---- */
.fm-item-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  text-decoration: none;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  padding: 0;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}

.fm-item-btn:hover {
  transform: scale(1.12);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.25);
}

.fm-item-img {
  width: 60%;
  height: 60%;
  object-fit: contain;
  pointer-events: none;
}

/* ---- Toggle active state ---- */
.fm-item-btn.fm-toggle-on {
  outline: 3px solid #4caf50;
  outline-offset: 2px;
}

/* ---- Tooltip label ---- */
.fm-item-label {
  position: absolute;
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  top: calc(100% + 4px);
}

.fm-item:hover .fm-item-label {
  opacity: 1;
}

/* For surround mode, put labels below */
.fm-mode-surround .fm-item-label {
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
}

/* ---- Info panel ---- */
.fm-info-panel {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  color: #333;
  border-radius: 8px;
  padding: 12px 16px;
  min-width: 180px;
  max-width: 280px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  z-index: 99994;
  font-size: 0.85rem;
  line-height: 1.45;
}

.fm-info-panel strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.95rem;
}

.fm-info-panel p {
  margin: 0;
}

/* Fullscreen mode: items are bigger */
.fm-mode-fullscreen .fm-item-btn {
  font-size: 1.5rem;
}

.fm-mode-fullscreen .fm-item-label {
  position: static;
  opacity: 1;
  background: none;
  color: #fff;
  font-size: 1rem;
  padding: 4px 0;
}

/* ---- Single-item direct panel ---- */
.fm-single-item-panel {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 99994;
}

/* ---- Local-data info rows ---- */
.fm-info-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0;
  border-bottom: 1px solid #eee;
}

.fm-info-row:last-child {
  border-bottom: none;
}

.fm-info-field {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.fm-info-key {
  font-weight: 600;
  color: #555;
  font-size: 0.8rem;
  text-transform: capitalize;
}

.fm-info-value {
  color: #222;
  font-size: 0.8rem;
}

.fm-info-empty {
  color: #999;
  font-style: italic;
  text-align: center;
  padding: 8px 0;
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
  .fm-trigger {
    width: 48px !important;
    height: 48px !important;
    font-size: 1.2rem;
  }

  .fm-item-btn {
    font-size: 1rem;
  }

  .fm-page-panel,
  .fm-page-panel-direct {
    width: calc(100vw - 16px) !important;
    max-width: none !important;
  }
}

/* ---- Page embed panel ---- */
.fm-page-panel {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 360px;
  max-height: 70vh;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.22);
  z-index: 99994;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.fm-page-panel-direct {
  position: relative;
  left: auto;
  bottom: auto;
  transform: none;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
}

.fm-page-content {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  border-radius: inherit;
  -webkit-overflow-scrolling: touch;
}

/* Inside floating menu panels: override server-rendered fixed heights
   so content auto-sizes and the panel scrollbar works properly. */
.fm-page-content .widget-local-data,
.fm-page-content .widget-table {
  height: auto !important;
  min-height: 0 !important;
}
.fm-page-content .local-data-grid {
  grid-auto-rows: auto !important;
}
.fm-page-content .row {
  min-height: 0 !important;
  flex: 0 0 auto !important;
}
/* Break the height:100% circular dependency set by table-widget.css on the
   direct-child row of each local-data-cell.  Without this the row resolves
   100% of an auto-sized grid track → 0px and content gets clipped. */
.fm-page-content .widget-table .local-data-grid > .column.local-data-cell > .row[data-depth]:first-child {
  height: auto !important;
  flex: 0 0 auto !important;
}

.fm-page-close {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: background 0.2s ease;
}

.fm-page-close:hover {
  background: rgba(0, 0, 0, 0.7);
}
