/* The side panel: the one slide-in pane on the right of a page. Trip chat,
   comments, the Idea Zone and the SplitGoGo budget all use it, and only one
   can be open at a time because they all swap into #side-panel (base.html).

   Markup contract for a pane template, in order:

     <div class="side-panel-backdrop" onclick="closeSidePanel()"></div>
     <div class="side-panel" data-panel="<name>" data-vv-panel>
       {% include "tripgogo/_components/side_panel_header.html" with title="..." icon="..." %}
       ...a body that scrolls itself (flex: 1; overflow-y: auto)...
     </div>

   Behaviour (close, toggle, Escape, scroll lock): js/side_panel.js.
   Keyboard-aware height on phones: js/viewport-panel.js via data-vv-panel. */

.side-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  /* Above the mobile hamburger (z-index 1001). */
  z-index: 1003;
}

.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 380px;
  max-width: 100vw;
  /* --panel-vh is overridden by viewport-panel.js while the keyboard is open;
     defaults to dynamic viewport height so the panel never exceeds the screen. */
  height: var(--panel-vh, 100dvh);
  background: var(--surface, #fff);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  z-index: 1004;
  animation: side-panel-in 0.2s ease-out;
}

@keyframes side-panel-in {
  from {
    transform: translateX(100%);
  }

  to {
    transform: translateX(0);
  }
}

.side-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem 0.75rem 1.25rem;
  /* Clear the status bar / notch so the header isn't tucked behind it on iOS. */
  padding-top: calc(0.75rem + env(safe-area-inset-top));
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  flex-shrink: 0;
}

.side-panel__title {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary, #333);
}

.side-panel__title i {
  color: var(--primary, #2dd4bf);
}

/* 44px: besides the backdrop, the only way out of the pane on a phone. */
.side-panel__close {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--text-muted, #767676);
  font-size: 1.2rem;
  cursor: pointer;
}

.side-panel__close:hover {
  background: var(--surface-muted, #f3f4f6);
  color: var(--text-primary, #333);
}

@media (max-width: 600px) {
  .side-panel {
    width: 100%;
  }

  /* 16px prevents iOS Safari from auto-zooming the page on input focus,
     which otherwise shifts the panel and clips its top. */
  .side-panel input,
  .side-panel textarea {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .side-panel {
    animation: none;
  }
}
