/* FilamentHub 3D - Premium Bento Glass & Adaptive Design System (iPhone 14 Pro Optimized) */

:root {
  /* Default: Dark Theme Tokens */
  --bg-primary: #0a0f1d;
  --bg-surface: #0f172a;
  --bg-card: #131c31;
  --bg-card-hover: #17233d;
  --border-card: #22304d;
  --border-card-hover: #3b82f6;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent-indigo: #6366f1;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --accent-rose: #e11d48;
  --accent-cyan: #06b6d4;
  --header-bg: rgba(15, 23, 42, 0.85);
  --header-border: rgba(30, 41, 59, 0.8);
  --modal-bg: #0d1425;
  --modal-border: #2b3c5f;
  --input-bg: #0b0f19;
  --input-border: #334155;
  --input-text: #f8fafc;
  --card-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
}

/* Light Theme Variables when .dark is NOT present */
html:not(.dark) {
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --border-card: #e2e8f0;
  --border-card-hover: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --header-bg: rgba(255, 255, 255, 0.88);
  --header-border: rgba(226, 232, 240, 0.9);
  --modal-bg: #ffffff;
  --modal-border: #e2e8f0;
  --input-bg: #ffffff;
  --input-border: #cbd5e1;
  --input-text: #0f172a;
  --card-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.06);
}

html, body {
  height: 100dvh;
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
  overscroll-behavior: none;
  position: fixed;
  inset: 0;
}

#mainScrollArea {
  -webkit-overflow-scrolling: touch;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

/* Glassmorphism Header */
.solid-header {
  background-color: var(--header-bg) !important;
  border-bottom: 1px solid var(--header-border) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* Hide scrollbars globally for a commercial native iOS app feel */
::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}
* {
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

/* Cards & Bento Grid */
.solid-card, .glass-card {
  background: var(--bg-card);
  border-color: var(--border-card);
  box-shadow: var(--card-shadow);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.solid-card:hover, .glass-card:hover {
  border-color: var(--border-card-hover);
}

/* Modals */
.solid-modal {
  background: var(--modal-bg);
  border-color: var(--modal-border);
  box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.5);
}

/* Light Theme Overrides for Inputs & Form Controls */
html:not(.dark) .solid-modal {
  background-color: #ffffff !important;
  border-color: #e2e8f0 !important;
  color: #0f172a !important;
}

html:not(.dark) input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),
html:not(.dark) select,
html:not(.dark) textarea {
  background-color: #ffffff !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
}

html:not(.dark) input::placeholder,
html:not(.dark) textarea::placeholder {
  color: #94a3b8 !important;
}

/* Status Badges */
.badge-status-new {
  background-color: rgba(59, 130, 246, 0.14);
  color: #2563eb;
  border: 1px solid rgba(59, 130, 246, 0.35);
}
html.dark .badge-status-new {
  background-color: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.45);
}

.badge-status-opened, .badge-status-inuse {
  background-color: rgba(16, 185, 129, 0.14);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.35);
}
html.dark .badge-status-opened, html.dark .badge-status-inuse {
  background-color: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.5);
}

.badge-status-empty {
  background-color: rgba(100, 116, 139, 0.14);
  color: #64748b;
  border: 1px solid rgba(100, 116, 139, 0.35);
}
html.dark .badge-status-empty {
  background-color: rgba(100, 116, 139, 0.2);
  color: #94a3b8;
  border: 1px solid rgba(100, 116, 139, 0.45);
}

/* Manufacturer Quick Brand Pills */
.brand-pill-btn {
  transition: all 0.15s ease-in-out;
  border: 1px solid var(--border-card);
  background: var(--bg-surface);
}
.brand-pill-btn:hover {
  border-color: var(--accent-indigo);
  background: var(--bg-card-hover);
}
.brand-pill-btn.active {
  border-color: var(--accent-indigo);
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent-indigo);
}

/* Touch & Button Feedback */
button:active, .clickable:active {
  transform: scale(0.98);
}

/* Mobile Safe Spacing & iPhone Safe Areas */
.mobile-safe-bottom {
  padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
}
.safe-top-padding {
  padding-top: env(safe-area-inset-top, 0px);
}
.safe-bottom-padding {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Hide Scrollbar Utility */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Prevent iOS Safari Automatic Zoom on Inputs (16px minimum) */
@media (max-width: 640px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* iOS Segmented Control */
.segmented-container {
  background-color: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 3px;
  border-radius: 0.85rem;
}
html.dark .segmented-container {
  background-color: #0b0f19;
  border: 1px solid #1e293b;
}

.segmented-btn {
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 0.7rem;
  color: #64748b;
  font-weight: 600;
}
html.dark .segmented-btn {
  color: #94a3b8;
}

.segmented-btn.active {
  background-color: #6366f1;
  color: #ffffff !important;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.45);
}
.segmented-btn:not(.active):hover {
  color: #0f172a;
}
html.dark .segmented-btn:not(.active):hover {
  color: #f8fafc;
}

/* Bottom Sheet Animation for Mobile Modals */
@keyframes slideUpSheet {
  from {
    transform: translateY(100%);
    opacity: 0.4;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
@media (max-width: 640px) {
  .mobile-sheet {
    animation: slideUpSheet 0.24s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }
}

/* Eyedropper Magnifier Preview */
.color-swatch-ring {
  box-shadow: 0 0 0 2px var(--bg-surface), 0 0 0 4px currentColor;
}

/* Missing Field Wizard Quick Chips */
.missing-chip-btn {
  transition: all 0.15s ease-in-out;
  border: 1px solid rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border-radius: 0.6rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
}
html.dark .missing-chip-btn {
  background: rgba(120, 53, 15, 0.35);
  color: #fde68a;
}
.missing-chip-btn:hover, .missing-chip-btn.active {
  border-color: #f59e0b;
  background: #f59e0b;
  color: #ffffff;
}

/* ========================================================================= */
/* SWIPE-TO-ACTION (iOS Native Style List)                                    */
/* ========================================================================= */
.swipe-item-wrapper {
  position: relative;
  overflow: hidden;
  border-radius: 1rem;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  background-color: var(--bg-card);
}

.swipe-actions,
.swipe-actions-right {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  display: flex;
  align-items: stretch;
  z-index: 1;
  width: 216px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.swipe-actions-left {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: stretch;
  z-index: 1;
  width: 160px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.swipe-item-wrapper.is-swiping-left .swipe-actions-right,
.swipe-item-wrapper.swipe-open-right .swipe-actions-right,
.swipe-item-wrapper.is-swiping .swipe-actions,
.swipe-item-wrapper.swipe-open .swipe-actions {
  opacity: 1;
  pointer-events: auto;
}

.swipe-item-wrapper.is-swiping-right .swipe-actions-left,
.swipe-item-wrapper.swipe-open-left .swipe-actions-left {
  opacity: 1;
  pointer-events: auto;
}

.swipe-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  font-weight: 800;
  font-size: 0.75rem;
  color: #ffffff;
  transition: filter 0.15s ease;
  user-select: none;
}
.swipe-actions-left .swipe-action-btn {
  width: 80px;
}
.swipe-actions-right .swipe-action-btn,
.swipe-actions .swipe-action-btn {
  width: 72px;
}
.swipe-action-btn:active {
  filter: brightness(0.85);
}

.swipe-action-weigh {
  background-color: #059669;
}
.swipe-action-open {
  background-color: #0284c7;
}
.swipe-action-seal {
  background-color: #3b82f6;
}
.swipe-action-clone {
  background-color: #7c3aed;
}
.swipe-action-edit {
  background-color: #4f46e5;
}
.swipe-action-delete {
  background-color: #e11d48;
}

.swipe-content {
  position: relative;
  z-index: 2;
  transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
  background-color: var(--bg-card) !important;
  touch-action: pan-y;
}

.swipe-content.swiping {
  transition: none !important;
}

/* Light Theme Card Enhancements */
html:not(.dark) .swipe-content {
  background-color: #ffffff !important;
}

html:not(.dark) .swipe-item-wrapper,
html:not(.dark) .glass-card,
html:not(.dark) .solid-card {
  background-color: #ffffff !important;
  border-color: #e2e8f0 !important;
  box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.06);
}

html:not(.dark) .swipe-item-wrapper.border-emerald-500\/60,
html:not(.dark) .glass-card.border-emerald-500\/70 {
  border-color: #10b981 !important;
  box-shadow: 0 4px 16px -2px rgba(16, 185, 129, 0.18);
}

/* Print Specific Rules */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .no-print {
    display: none !important;
  }
  .print-only {
    display: block !important;
  }
}
