/*
 * Oplify Application Styles
 * Tailwind CSS handles utility classes; this file holds custom components.
 */

/* Turbo progress bar */
.turbo-progress-bar {
  height: 3px;
  background: linear-gradient(to right, #5A48DC, #7060E9);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000;
  transition: width 0.3s ease;
}

/* Flash dismiss animation */
.flash-dismiss {
  transition: opacity 0.2s ease-out, transform 0.2s ease-out;
}
.flash-dismiss.hiding {
  opacity: 0;
  transform: translateY(-10px);
}

/* Notification Toast Animations */
.notification-toast {
  transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}
.notification-toast.show {
  transform: translateX(0);
  opacity: 1;
}

/* Sidebar transitions */
.sidebar-overlay {
  transition: opacity 0.3s ease;
}
.sidebar-panel {
  transition: transform 0.3s ease;
}

/*
 * Buttons — Oplify design system.
 * Each color class is self-sufficient (the grouped selector supplies the base
 * layout) so bare `class: "btn-primary"` keeps working. `.btn` is an optional
 * alias. Size defaults to md (15px / 11x20 / r10); add .btn-sm or .btn-lg.
 * Colors use literal spec hexes (application.css is not scanned by Tailwind,
 * so the @theme --color-* vars are tree-shaken and unavailable here).
 */
.btn,
.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-danger,
.btn-success {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  font-family: "Figtree", ui-sans-serif, system-ui, sans-serif;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s;
}

/* Sizes (defined after the base group so they win the padding/font override) */
.btn-sm { padding: 7px 14px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 15px 28px; font-size: 17px; border-radius: 12px; }

/* Primary */
.btn-primary {
  color: #FFFFFF;
  background-color: #5A48DC;
  box-shadow: 0 2px 8px rgba(90, 72, 220, 0.28);
}
.btn-primary:hover { background-color: #4A3BBE; }
.btn-primary:focus-visible {
  outline: none;
  box-shadow: 0 2px 8px rgba(90, 72, 220, 0.28), 0 0 0 3px #E5E3FD;
}

/* Secondary */
.btn-secondary {
  color: #45403A;
  background-color: #F4F2EF;
  border-color: #E9E6E1;
}
.btn-secondary:hover { background-color: #E9E6E1; border-color: #D8D3CC; }
.btn-secondary:focus-visible { outline: none; box-shadow: 0 0 0 3px #E5E3FD; }

/* Ghost */
.btn-ghost { color: #5A48DC; background-color: transparent; }
.btn-ghost:hover { background-color: #F1F0FE; }
.btn-ghost:focus-visible { outline: none; box-shadow: 0 0 0 3px #E5E3FD; }

/* Danger */
.btn-danger { color: #FFFFFF; background-color: #DC2626; }
.btn-danger:hover { background-color: #B91C1C; }
.btn-danger:focus-visible { outline: none; box-shadow: 0 0 0 3px #FEE2E2; }

/* Success (not in the spec table; mapped to the semantic success token) */
.btn-success { color: #FFFFFF; background-color: #16A34A; }
.btn-success:hover { background-color: #15803D; }
.btn-success:focus-visible { outline: none; box-shadow: 0 0 0 3px #DCFCE7; }

/* Disabled — applies to real <button disabled> and [disabled] across variants */
.btn:disabled, .btn[disabled],
.btn-primary:disabled, .btn-primary[disabled],
.btn-secondary:disabled, .btn-secondary[disabled],
.btn-ghost:disabled, .btn-ghost[disabled],
.btn-danger:disabled, .btn-danger[disabled],
.btn-success:disabled, .btn-success[disabled] {
  background-color: #F4F2EF;
  color: #B0AAA1;
  border-color: transparent;
  box-shadow: none;
  cursor: not-allowed;
}

/* Loading spinner — drop <span class="btn-spinner"></span> before the label */
.btn-spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #FFFFFF;
  border-radius: 9999px;
  animation: op-spin 0.7s linear infinite;
}

/* Table row hover */
.table-row-hover:hover {
  background-color: var(--surface-subtle);
}

/* Custom scrollbar for sidebar */
.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}
.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 2px;
}

/* Dropdown animation */
.dropdown-enter {
  transition: opacity 0.1s ease-out, transform 0.1s ease-out;
}
.dropdown-enter.hidden {
  opacity: 0;
  transform: scale(0.95);
}

/* Image zoom on hover */
.img-zoom {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: default;
}
.img-zoom:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Pagy pagination */
nav.pagy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.75rem 0;
}
nav.pagy a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0.5rem;
  border: 1px solid var(--surface-border);
  color: var(--text-secondary);
  background: var(--surface-card);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
nav.pagy a:hover:not([aria-disabled]) {
  background: var(--surface-subtle);
  border-color: #D8D3CC;
}
nav.pagy a.current {
  background: #5A48DC;
  color: white;
  border-color: #5A48DC;
  cursor: default;
}
nav.pagy a[aria-disabled="true"] {
  color: var(--text-disabled);
  background: var(--surface-subtle);
  cursor: default;
}
nav.pagy a.gap {
  border: none;
  background: none;
  cursor: default;
  color: var(--text-muted);
}

/* ============================================================
 * Oplify logo animations (Aperture)
 * Animated SVG rects pivot around their own center.
 * ============================================================ */
.op-mark-ring,
.op-mark-unit {
  transform-box: fill-box;
  transform-origin: center;
}

/* A · Assemble — PWA splash / first paint */
@keyframes op-ring {
  0%   { opacity: 0; transform: scale(.55) rotate(-35deg); }
  18%  { opacity: 1; transform: scale(1.06) rotate(4deg); }
  27%  { transform: scale(1) rotate(0); }
  86%  { opacity: 1; }
  100% { opacity: 0; transform: scale(.94); }
}
@keyframes op-unit {
  0%, 7% { opacity: 0; transform: translateY(-24px) scale(.4); }
  22%    { opacity: 1; transform: translateY(3px) scale(1.18); }
  29%    { transform: translateY(0) scale(1); }
  86%    { opacity: 1; }
  100%   { opacity: 0; }
}
.op-assemble .op-mark-ring { animation: op-ring 3.4s cubic-bezier(0.34, 1.3, 0.5, 1) infinite; }
.op-assemble .op-mark-unit { animation: op-unit 3.4s cubic-bezier(0.34, 1.3, 0.5, 1) infinite; }

/* Floating accent (marketing vignettes) */
@keyframes op-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* B · Orbit — reusable loading spinner (static aperture + orbiting coral dot) */
@keyframes op-orbit { to { transform: rotate(360deg); } }
.op-spinner { position: relative; display: inline-block; line-height: 0; }
.op-spinner-orbit { position: absolute; inset: 0; animation: op-orbit 1.5s linear infinite; }
.op-spinner-dot {
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 3px;
  background: #E0492C;
}

/* C · Breathe — scan-success / fulfilled confirmations / idle empty states */
@keyframes op-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.09); } }
@keyframes op-glow {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(224, 73, 44, 0)); }
  50%      { filter: drop-shadow(0 0 6px rgba(224, 73, 44, .6)); }
}
.op-breathe { animation: op-breathe 2.6s ease-in-out infinite; transform-origin: center; }
.op-breathe .op-mark-unit { animation: op-glow 2.6s ease-in-out infinite; }

/* Respect reduced motion: disable Assemble + Breathe; keep the loader minimal. */
@media (prefers-reduced-motion: reduce) {
  .op-assemble .op-mark-ring,
  .op-assemble .op-mark-unit,
  .op-breathe,
  .op-breathe .op-mark-unit { animation: none; }
  .op-spinner-orbit { animation-duration: 2.4s; }
}
