/* KaosKatun - Main CSS (centralized). No inline CSS in views. */
/* Mobile-first sizing and spacing tuned for touch targets. */

/* General styling & resets */
html, body {
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background-color: #f5f6fa;
  color: #222;
}

/* Container max width on larger screens while keeping mobile-first */
.container-narrow {
  max-width: 680px;
  margin-left: auto;
  margin-right: auto;
}

/* Big primary actions (Dashboard buttons) */
.btn-huge {
  height: 3.5rem;           /* bigger tap area */
  font-size: 1.1rem;        /* readable label */
  border-radius: 10px;      /* softer look */
}

/* Icon + text alignment for big buttons */
.btn-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

/* Cards/boxes spacing */
.box-spacious {
  padding: 1.25rem;
}

/* Form field spacing suitable for scrollable forms */
.form-section {
  margin-bottom: 1.25rem;
}

.form-section h2,
.form-section h3 {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* Sticky bottom submit bar (for New Order) */
.sticky-submit {
  position: sticky;
  bottom: 0;
  background: #ffffffcc;
  backdrop-filter: blur(6px);
  padding: 0.75rem;
  border-top: 1px solid #e8eaee;
}

/* File upload preview grid */
.upload-grid {
  /* Auto-fill responsive columns to wrap gracefully on small screens */
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
}

@media (min-width: 480px) { .upload-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); } }
@media (min-width: 768px) { .upload-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); } }

.upload-thumb {
  width: 100%;   /* important for grid */
  aspect-ratio: 1/1;   /* square thumbnails */
  object-fit: cover;     /* crop to fill */
  border-radius: 6px;
  border: 1px solid #e6e6e6;
}

/* Status chips */
.chip {
  display: inline-block;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  border: 1px solid transparent;
}
.chip--quote { background: #fff7e6; color: #925b00; border-color: #ffe8bf; }
.chip--process { background: #e6f7ff; color: #005a8e; border-color: #bfe8ff; }
.chip--done { background: #e6ffed; color: #216e3a; border-color: #b7f5c9; }
.chip--delivered { background: #f0fff4; color: #217346; border-color: #caffe0; }
.chip--not-delivered { background: #ffebee; color: #b71c1c; border-color: #ffcdd2; }

/* Invoice highlights */
.invoice-total {
  font-size: 1.2rem;
  font-weight: 700;
}

/* Utility helpers */
.hidden { display: none !important; }
.center { text-align: center; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.rounded { border-radius: 8px; }

/* Make native checkbox inputs sit above nearby inline elements so they receive clicks.
   Some layouts (flex + inline spans) can cause adjacent text to be positioned above
   the checkbox in certain browsers; this ensures the checkbox has its own stacking
   context and a visible pointer cursor. */
input[type="checkbox"] {
  position: relative;
  z-index: 2;
  width: 1.15rem;
  height: 1.15rem;
  cursor: pointer;
  /* keep default appearance but ensure consistent sizing */
  -webkit-appearance: checkbox;
  appearance: checkbox;
}

/* Invoice exists chip */
.chip--invoice { background: #fff7f0; color: #8a2b2b; border-color: #ffd7cf; }

/* Prevent overscroll glow on some mobile browsers */
* {
  overscroll-behavior: contain;
}

/* Off-canvas from right side */
.offcanvas-menu {
  position: fixed;
  top: 0;
  right: -300px; /* Start off-screen to the right */
  width: 300px;
  height: 100%;   /* Changed from vh */
  background-color: #ffffff;
  z-index: 99999; /* raised to ensure panel overlays all page content */
  transition: right 0.3s ease-in-out;
  overflow-y: auto;
  box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
}

.offcanvas-menu.is-active {
  right: 0; /* Slide in from right */
}

.offcanvas-menu-items {
  display: flex;
  flex-direction: column;
  padding: 1rem;
}

.offcanvas-menu-items .navbar-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f5f5f5;
}

.offcanvas-menu-items .navbar-item:last-child {
  border-bottom: none;
}

.offcanvas-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;

  height: 100%; /* Changed from vh */
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 99990; /* below panel but above content */
  opacity: 0;
  visibility: hidden;
  pointer-events: none; /* prevent blocking clicks when hidden */
  transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.offcanvas-backdrop.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto; /* enable interaction only when active */
}

/* Admin-only field labels */
.label-admin {
  color: #005a8e; /* Blue color for admin fields */
  font-weight: 600;
}

/* Responsive chips for orders history: - .chips-desktop: visible on tablet/desktop
   - .chips-mobile: visible on mobile (placed under price in markup) */
.chips-desktop {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.chips-mobile {
  display: none;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* Ensure chips have small spacing on mobile and wrap */
.chips-mobile .chip {
  margin-right: 0.5rem;
  margin-bottom: 0.25rem;
}

.atkFields {
  display: block;
}

/* Breakpoint: mobile and small tablets */
@media (max-width: 768px) {
  .chips-desktop {
    display: none !important;
  }
  .chips-mobile {
    display: flex !important;
    margin-top: 0.5rem;
  }
}

/* Sticky header on mobile: keep header and burger floating at top while scrolling */
@media (max-width: 1023px) {
  .site-header {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    z-index: 99980; /* below backdrop & panel but above content */
    width: 100%;
    transform: none !important;
    filter: none !important;
  }

  .site-header .navbar {
    background: #ffffff;            /* solid to avoid creating containing block via filters */
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    border-bottom: 1px solid #e8eaee;
  }

  /* Ensure burger is on top inside the header */
  .site-header .navbar-burger {
    position: relative;
    z-index: 99981;
  }

  /* Push page content down so it is not covered by the fixed header on mobile */
  .site-header + section,
  .site-header + .section,
  body.has-fixed-mobile-header .section {
    padding-top: 3.75rem; /* matches navbar height (3.25rem) + small gap */
  }
}

/* Desktop view: show menu inline and disable off-canvas behavior */
@media (min-width: 1024px) {
  /* Backdrop is not needed on desktop */
  .offcanvas-backdrop {
    display: none !important;
  }

  /* Transform the offcanvas menu back into a regular inline navbar menu */
  .navbar .navbar-menu.offcanvas-menu {
    position: static;
    right: auto;
    width: auto;
    height: auto;
    background: transparent;
    box-shadow: none;
    transition: none;
    overflow: visible;
  }

  /* Ensure any is-active state does not move things around on desktop */
  .navbar .navbar-menu.offcanvas-menu.is-active {
    right: auto;
  }

  /* Horizontal items for desktop */
  .navbar .navbar-menu.offcanvas-menu .offcanvas-menu-items {
    flex-direction: row;
    padding: 0;
  }

  .navbar .navbar-menu.offcanvas-menu .navbar-item {
    border: 0;
    padding: 0.5rem 0.75rem;
  }

  /* Force menu to be visible regardless of Alpine open state on desktop */
  .navbar .navbar-menu {
    display: flex !important;
  }
}

/* Thumbnails and preview modal */
/* Ensure thumbnails auto-fit inside fixed container and never overlap actions below */
.thumb-128 {
  width: 128px;
  height: 128px;
  display: inline-block;
}
.thumb-fit {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background-color: #f5f5f5;
}

/* Center modal content and constrain preview image size */
.modal-content.is-centered {
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-image {
  max-width: 90vw;
  max-height: 80vh;
  width: auto;
  height: auto;
  object-fit: contain;
}
