/* These styles are generated from project.scss. */

[x-cloak] {
  display: none !important;
}

/* Scan Mode fills the visible viewport exactly. 100vh includes the area
   behind mobile browser toolbars, which pushed the bottom of the scanner
   (recent-scans strip, mode nav, sometimes the Scan button) off screen on
   phones with dynamic chrome. dvh tracks the visible height; scanner.js
   pins the height for browsers that predate dvh. */
#scanner-shell {
  height: 100vh;
}

@supports (height: 100dvh) {
  #scanner-shell {
    height: 100dvh;
  }
}

/* crispy-tailwind ships its own corner radii. Override them with the portal
   token so form controls match buttons and cards. */
form [id^="div_id_"] .rounded,
form [id^="div_id_"] .rounded-lg,
form [id^="div_id_"] .rounded-t,
form [id^="div_id_"] .rounded-b,
form [id^="div_id_"] .rounded-l-none,
form [id^="div_id_"] .rounded-r-none {
  border-radius: var(--ui-radius) !important;
}

/* Tailwind's reset strips the native file-picker button down to a bare white
   rectangle. Dress it as the portal's secondary button (cotton/button.html). */
input[type="file"] {
  font-size: 0.875rem;
  color: #374151;
  cursor: pointer;
}

input[type="file"]::file-selector-button {
  margin-right: 0.75rem;
  padding: 0.5rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: var(--ui-radius);
  background-color: #ffffff;
  color: #374151;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

input[type="file"]::file-selector-button:hover {
  background-color: #f5f7f9;
}

/* Date inputs enhanced with the calendar popup (js/widgets/datetime-picker.js):
   hide the browser's own picker icon so it cannot open the native calendar
   next to the custom one. Scoped to the widget wrapper so it applies before
   Alpine initializes; without JavaScript the icon stays as the only picker. */
@media (scripting: enabled) {
  .datetime-picker input::-webkit-calendar-picker-indicator {
    display: none;
  }
}

.alert-debug {
  color: black;
  background-color: white;
  border-color: #e5e7eb;
}

.alert-error {
  color: #BC3C00;
  background-color: #FFF1EB;
  border-color: #FF5100;
}

.htmx-on-request {
  display: none;
}

.htmx-request .htmx-on-request,
.htmx-request.htmx-on-request {
  display: inline;
}

.htmx-request .htmx-on-idle,
.htmx-request.htmx-on-idle {
  display: none;
}

.export-job-submit.htmx-request {
  cursor: wait;
  color: #6b7280;
}

/* PDF ticket designer. The canvas stays framework-light: PDF.js paints the
   artwork and Alpine positions plain DOM overlays in millimetres. */
.ticket-layout-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.ticket-layout-workspace {
  display: grid;
  grid-template-columns: 13rem minmax(28rem, 1fr) 18rem;
  min-width: 0;
}

.ticket-layout-layers,
.ticket-layout-properties,
.ticket-layout-stage {
  min-width: 0;
}

.ticket-layout-page-shell {
  width: 100%;
  max-width: 46rem;
  margin-inline: auto;
}

.ticket-layout-page {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.ticket-layout-page canvas {
  pointer-events: none;
}

.ticket-layout-element {
  z-index: 1;
  touch-action: none;
  outline: none;
}

.ticket-layout-resize-handle {
  cursor: nwse-resize;
  touch-action: none;
}

@media (min-width: 1280px) {
  .ticket-layout-layers,
  .ticket-layout-properties {
    position: sticky;
    top: 4rem;
    max-height: calc(100vh - 5rem);
    align-self: start;
    overflow-y: auto;
  }
}

@media (max-width: 1279px) {
  .ticket-layout-workspace {
    grid-template-columns: 12rem minmax(0, 1fr);
  }

  .ticket-layout-properties {
    grid-column: 1 / -1;
    border-top: 1px solid #e5e7eb;
    border-left: 0;
  }
}

@media (max-width: 767px) {
  .ticket-layout-toolbar {
    display: grid;
    align-items: stretch;
  }

  .ticket-layout-workspace {
    display: block;
  }

  .ticket-layout-layers {
    border-right: 0;
    border-bottom: 1px solid #e5e7eb;
  }

  .ticket-layout-properties {
    border-top: 1px solid #e5e7eb;
  }
}

.portal-shell {
  position: relative;
}

.portal-sidebar {
  z-index: 30;
}

.sidebar-open-button,
.sidebar-close-button {
  display: none;
}

@media (max-width: 1023px) {
  .portal-main {
    margin-left: 0;
  }

  .portal-sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease-in-out;
  }

  .portal-shell.sidebar-open .portal-sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(17, 24, 39, 0.45);
    border: 0;
    padding: 0;
    cursor: pointer;
  }

  .sidebar-open-button,
  .sidebar-close-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border: 1px solid #e5e7eb;
    border-radius: var(--ui-radius);
    background: #fff;
    color: #374151;
  }

  .sidebar-open-button {
    flex-direction: column;
    gap: 0.2rem;
    flex-shrink: 0;
  }

  .sidebar-open-button span {
    width: 0.9rem;
    height: 2px;
    border-radius: var(--ui-radius-full);
    background: currentColor;
    font-size: 0;
  }

  .sidebar-close-button {
    font-size: 1.5rem;
    line-height: 1;
  }
}

@media (min-width: 1024px) {
  .sidebar-backdrop,
  .sidebar-open-button,
  .sidebar-close-button {
    display: none !important;
  }
}

/* Collapsed rail. Desktop only: below 1024px the sidebar is already a
   drawer, and that mechanism must not inherit the narrow width. */
.sidebar-rail-button {
  display: none;
}

@media (min-width: 1024px) {
  .sidebar-rail-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
    border: 1px solid #e5e7eb;
    border-radius: var(--ui-radius);
    background: #fff;
    color: #6b7280;
  }

  .sidebar-rail-button:hover {
    background: #f9fafb;
    color: #111827;
  }

  /* The chevron points the way the click goes: left to collapse while the
     sidebar is open, right to expand it again once railed. */
  .sidebar-rail-button svg {
    transition: transform 0.15s ease-in-out;
  }

  .portal-shell:not(.sidebar-railed) .sidebar-rail-button svg {
    transform: rotate(180deg);
  }

  .portal-sidebar,
  .portal-main {
    transition:
      width 0.15s ease-in-out,
      margin-left 0.15s ease-in-out;
  }

  .portal-shell.sidebar-railed .portal-sidebar {
    width: 4.5rem;
  }

  /* Beats Tailwind's ml-72 on the main column: three classes to one. */
  .portal-shell.sidebar-railed .portal-main {
    margin-left: 4.5rem;
  }

  /* Labels leave the page but stay in the accessibility tree, so the rail
     still announces every destination to a screen reader. */
  .portal-shell.sidebar-railed .portal-sidebar nav a,
  .portal-shell.sidebar-railed .sidebar-footer a {
    justify-content: center;
    gap: 0;
    font-size: 0;
  }

  .portal-shell.sidebar-railed .sidebar-brand,
  .portal-shell.sidebar-railed .sidebar-section-label,
  .portal-shell.sidebar-railed .sidebar-identity,
  .portal-shell.sidebar-railed .sidebar-version {
    display: none;
  }

  .portal-shell.sidebar-railed .sidebar-header {
    justify-content: center;
  }
}
