/* Hide / show Chatwoot's own left menu inside the Unibox embed (desktop only).
   unibox-chat-menu.js tags the menu <aside> with data-unibox-chat-menu, puts one
   button at its top, and keeps the remembered state as a class on <html>.
   Colours follow the dashboard's own "Hide menu" button and gold "Menu" tab
   (dashboard/app/globals.css): gold #c99a36, deep #896316, soft #faf3e2. */

.unibox-chat-menu-toggle {
  display: none;
}

@media (min-width: 768px) {
  /* Expanded: a large outlined button at the top of the menu, in normal flow,
     so it never covers Chatwoot's own controls. */
  aside[data-unibox-chat-menu] > .unibox-chat-menu-toggle {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
    min-height: 48px;
    margin: 8px 8px 6px;
    padding: 8px 12px;
    border: 2px solid rgb(201 154 54 / 70%);
    border-radius: 12px;
    background: #fffefa;
    color: #896316;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0;
    text-align: center;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
  }

  aside[data-unibox-chat-menu] > .unibox-chat-menu-toggle:hover {
    border-color: #c99a36;
    background: #faf3e2;
    color: #111;
  }

  aside[data-unibox-chat-menu] > .unibox-chat-menu-toggle:focus-visible {
    outline: 3px solid #896316;
    outline-offset: 2px;
  }

  .unibox-chat-menu-arrow {
    font-size: 22px;
    line-height: 1;
    font-weight: 700;
  }

  .unibox-chat-menu-text {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  /* Chatwoot's own icon-rail width (~56px): stack the arrow over "Hide". */
  aside[data-unibox-chat-menu] > .unibox-chat-menu-toggle[data-state="shown-compact"] {
    flex-direction: column;
    gap: 2px;
    margin: 8px 4px 6px;
    padding: 6px 2px;
    font-size: 14px;
  }

  /* Hidden: the menu shrinks to a full-height gold tab. Chatwoot's markup stays
     mounted (only display changes), so its state, shortcuts and the phone inbox
     list in unibox-mobile.js keep working. */
  html.unibox-chat-menu-hidden aside[data-unibox-chat-menu] {
    width: 64px !important;
    min-width: 64px !important;
    max-width: 64px !important;
    padding: 0 !important;
    overflow: hidden !important;
    border-right-width: 0 !important;
  }

  html.unibox-chat-menu-hidden aside[data-unibox-chat-menu] > :not(.unibox-chat-menu-toggle) {
    display: none !important;
  }

  html.unibox-chat-menu-hidden aside[data-unibox-chat-menu] > .unibox-chat-menu-toggle {
    flex: 1 1 auto;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 12px 4px;
    border: 0;
    border-radius: 0;
    /* Cream stripe on the left keeps it distinct from the dashboard's own
       gold "Menu" tab when both menus are hidden side by side. */
    box-shadow: inset 4px 0 0 #fffefa, 2px 0 10px rgb(33 23 8 / 12%);
    background: #c99a36;
    color: #111;
    font-size: 16px;
    white-space: normal;
  }

  html.unibox-chat-menu-hidden aside[data-unibox-chat-menu] > .unibox-chat-menu-toggle:hover,
  html.unibox-chat-menu-hidden aside[data-unibox-chat-menu] > .unibox-chat-menu-toggle:active {
    background: #896316;
    color: #fff;
  }

  html.unibox-chat-menu-hidden aside[data-unibox-chat-menu] > .unibox-chat-menu-toggle:focus-visible {
    outline: 3px solid #111;
    outline-offset: -5px;
  }

  html.unibox-chat-menu-hidden .unibox-chat-menu-text {
    gap: 2px;
    line-height: 1.15;
  }

  /* No width animation on page load; only after a click (READY class). */
  html:not(.unibox-chat-menu-ready) aside[data-unibox-chat-menu] {
    transition: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  aside[data-unibox-chat-menu] {
    transition: none !important;
  }
}
