/*
 * Storefront / shared CSS bundle. Loaded by app/views/layouts/application.html.erb
 * and inherited by the admin and POS layouts (which add admin.css / pos.css on top).
 *
 * Sibling stylesheets (admin.css, pos.css, pos_receipt.css) are NOT bundled here —
 * each is loaded by the layout that needs it. We avoid `require_tree .` because
 * pos_receipt.css contains unscoped `body`, `table`, `th/td`, `.btn`, `.footer`
 * rules intended for the receipt preview only; bundling them globally leaks
 * `body { padding: 16px }` and other rules onto every storefront page.
 *

 */

.pos-page {
  min-height: 100vh;
  background: linear-gradient(to bottom, #fff1f2 0%, #ffffff 40%, #f8fafc 100%);
  color: #1e293b;
}

.pos-header {
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid #e2e8f0;
  backdrop-filter: blur(8px);
}

.pos-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.pos-card-muted {
  background: rgba(255, 241, 242, 0.6);
  border: 1px solid #ffe4e6;
  border-radius: 0.75rem;
  padding: 1.5rem;
}

.pos-section-title {
  font-size: 1.25rem;
  line-height: 1.75rem;
  font-weight: 600;
  color: #0f172a;
}

.pos-label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #334155;
}

.pos-input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  color: #0f172a;
  background: #ffffff;
}

.pos-input:focus {
  outline: 2px solid #ec4899;
  outline-offset: 0;
  border-color: #ec4899;
}

.pos-btn-primary,
.pos-btn-neutral,
.pos-btn-soft,
.pos-btn-success,
.pos-btn-warning,
.pos-btn-danger,
.pos-btn-disabled {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.pos-btn-primary { background: #db2777; color: #ffffff; }
.pos-btn-primary:hover { background: #ec4899; }

.pos-btn-neutral { background: #1e293b; color: #ffffff; }
.pos-btn-neutral:hover { background: #334155; }

.pos-btn-soft { background: #ffffff; color: #334155; border: 1px solid #cbd5e1; }
.pos-btn-soft:hover { background: #f8fafc; }

.pos-btn-success { background: #059669; color: #ffffff; }
.pos-btn-success:hover { background: #10b981; }

.pos-btn-warning { background: #d97706; color: #ffffff; }
.pos-btn-warning:hover { background: #f59e0b; }

.pos-btn-danger { background: #e11d48; color: #ffffff; }
.pos-btn-danger:hover { background: #f43f5e; }

.pos-btn-disabled {
  background: #cbd5e1;
  color: #475569;
  cursor: not-allowed;
}

.pos-chip {
  display: inline-block;
  border-radius: 9999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pos-table-wrap {
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
}

.pos-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.pos-thead {
  background: #f8fafc;
  color: #334155;
}

.pos-th,
.pos-td {
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.pos-th {
  font-weight: 600;
}

.pos-table tbody tr + tr td {
  border-top: 1px solid #f1f5f9;
}

.pos-link {
  color: #be185d;
  font-weight: 600;
  text-decoration: none;
}

.pos-link:hover {
  color: #db2777;
}

/* ---------------------------------------------------------------------------
 * Storefront / shared utilities (extracted from inline view styles).
 * Inline `style="..."` belongs in CSS files; only dynamic single-value props
 * (e.g. progress-bar width) are passed in via CSS custom properties.
 * ------------------------------------------------------------------------- */

/* Subtle dot pattern used as a hero background overlay. */
.dot-pattern-bg {
  background-image: radial-gradient(circle at 1px 1px, currentColor 1px, transparent 0);
  background-size: 40px 40px;
}

/* Bouncing-dot animation delays for the chat typing indicator. */
.animate-bounce-delay-1 { animation-delay: 0.1s; }
.animate-bounce-delay-2 { animation-delay: 0.2s; }

/* iOS / Hotwire Native bottom safe-area padding. Apply on elements that sit
 * flush with the bottom of the viewport (sticky bars, bottom navs). */
.safe-area-bottom {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Progress / fill bars driven by a `--progress` custom property on the inline
 * style. Width still scales with the value, but no rule lives in markup. */
.progress-bar-fill {
  width: var(--progress, 0%);
}

/* Checkout-step connectors animate from 0% → 100% width when the step
 * before them is complete. Toggled by checkout_steps_controller.js. */
.checkout-step-connector {
  width: 0%;
}

.checkout-step-connector.is-complete {
  width: 100%;
}

/* Hide the native number-input spinners on cart/quantity fields so the
 * styled +/- controls own the interaction. */
.no-spinner::-webkit-outer-spin-button,
.no-spinner::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.no-spinner {
  -moz-appearance: textfield;
}

/* Disable CSS transitions/animations in the test environment so Capybara
 * does not race the animation start. Toggled by a `data-test-mode` body
 * attribute set by the application layout when Rails.env.test? is true. */
[data-test-mode] *,
[data-test-mode] *::before,
[data-test-mode] *::after {
  transition-duration: 0s !important;
  animation-duration: 0s !important;
}

/* Chat widget: the only fixed element pinned to the right edge with safe-area
 * awareness; cannot use Tailwind's `right-2` because we need `max(...)`. */
.chat-widget-anchor {
  left: auto;
  right: max(0.5rem, env(safe-area-inset-right));
}

.chat-widget-menu {
  list-style: none;
  z-index: 10001;
}

.chat-widget-panel {
  position: fixed;
  z-index: 10000;
  border-radius: 24px;
  clip-path: inset(0 round 24px);
}

/* ---------------------------------------------------------------------------
 * Chat widget — toggle, panel, responsive sizing.
 * ------------------------------------------------------------------------- */
details.chat-widget-toggle[open] .chat-open-icon {
  display: none;
}

details.chat-widget-toggle[open] .chat-close-icon {
  display: block;
}

.chat-panel-surface {
  border-color: rgb(209 213 219 / 0.9);
  box-shadow:
    0 26px 50px -12px rgb(15 23 42 / 0.32),
    0 10px 22px -10px rgb(15 23 42 / 0.24),
    0 0 0 1px rgb(255 255 255 / 0.55);
}

/* Mobile (< 1024px): position toggle button above the bottom nav */
@media (max-width: 1023px) {
  .chat-widget-container {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 4.5rem) !important;
  }
}

/* Desktop (>= 1024px): standard bottom positioning */
@media (min-width: 1024px) {
  .chat-widget-container {
    bottom: max(1.5rem, env(safe-area-inset-bottom)) !important;
  }
}

/* Desktop: chat panel sizing (>= 640px) */
@media (min-width: 640px) {
  #chat-panel {
    right: max(0.5rem, env(safe-area-inset-right));
    bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 4.5rem);
    width: 460px;
    max-width: calc(100vw - 1rem);
    height: min(75vh, calc(100vh - 7rem));
    max-height: 760px;
  }
}

/* Mobile: chat panel as bottom sheet above the bottom nav */
@media (max-width: 639px) {
  #chat-panel {
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: calc(100vh - 7rem);
    max-height: none;
    border-radius: 16px 16px 0 0 !important;
    clip-path: inset(0 round 16px 16px 0 0) !important;
  }
}
