/* ==========================================================================
   Modals, Bottom Sheets & Lightbox
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: var(--vv-offset-top, 0px);
  left: 0;
  right: 0;
  height: var(--app-height, 100dvh);
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal-backdrop.open { display: flex; }
.modal-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: calc(var(--app-height, 100dvh) - 24px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalPop 0.18s ease-out;
}
.modal-card.wide { max-width: 860px; }
@keyframes modalPop {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 16px;
}
.modal-body {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Toast Notification */
#toast-container {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
  width: max-content;
  max-width: 92vw;
}
.toast-msg {
  background: #0f172a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: modalPop 0.18s ease-out;
}
.toast-msg.success { background: var(--success); }
.toast-msg.error { background: var(--danger); }

.spinner-sm {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,0.35);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Unified Shell & Utility Classes for All Tabs (Mobile & Web Optimized)
   ========================================================================== */
:root { --bg-main: #f1f5f9; --text-primary: #0f172a; }

.hidden { display: none !important; }

@media (max-width: 639px) {
  .hide-mobile {
    display: none !important;
  }
}

.app-shell {
  position: fixed;
  top: var(--vv-offset-top, 0px);
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: var(--app-height, 100%);
  overflow: hidden;
}

html.in-liff .app-header,
body.in-liff .app-header { display: none !important; }

.app-header {
  height: calc(var(--header-h) + var(--safe-top));
  padding: var(--safe-top) 12px 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  z-index: 30;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
@media (min-width: 640px) {
  .app-header {
    padding: 0 18px;
  }
}

.flt-appbar-title {
  font-size: 20px;
  font-weight: 500;
  color: #1d1b20;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  min-width: 0;
}

.user-pill { max-width: 190px; }
@media (max-width: 480px) {
  .user-name {
    max-width: 100px;
  }
}

.app-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* Desktop Sidebar — Exact Flutter Material 3 NavigationRail (minWidth: 72) */
.app-sidebar {
  display: none;
  width: 80px;
  background: #ffffff;
  border-right: 1px solid #e0e0e0;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  gap: 4px;
  flex-shrink: 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 2px;
  border-radius: 12px;
  color: #49454f;
  font-weight: 500;
  font-size: 12px;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: center;
  transition: color 0.15s ease;
  position: relative;
}

.nav-icon-pill {
  width: 56px;
  height: 32px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background-color 0.15s ease;
}

.nav-item:hover .nav-icon-pill { background: rgba(2, 132, 199, 0.08); }

.nav-item.active { color: #1d1b20; font-weight: 700; }

.nav-item.active .nav-icon-pill { background: #d4e3ff; color: #001c3a; }

.nav-rail-label {
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.nav-item .nav-badge {
  position: absolute;
  top: -2px;
  right: 6px;
}

.app-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.tab-section {
  display: none;
  width: 100%;
  min-height: 100%;
  padding: 12px;
  max-width: 1280px;
  margin: 0 auto;
}
@media (min-width: 640px) {
  .tab-section {
    padding: 18px;
  }
}
#tab-home, #tab-products, #tab-design, #tab-jobs, #tab-studio, #tab-chat { padding: 0 !important; max-width: none !important; }
.tab-section.active { display: block; }
#tab-design.active,
#tab-jobs.active,
#tab-chat.active {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* Equal 3-column Sub-tabs on Mobile & Desktop */
.subtab-bar.equal-tabs { padding: 0 4px; gap: 0; }
.subtab-bar.equal-tabs .subtab-btn {
  flex: 1;
  justify-content: center;
  padding: 11px 4px;
  font-size: 13px;
}
@media (min-width: 640px) {
  .subtab-bar.equal-tabs .subtab-btn {
    padding: 12px 16px;
    font-size: 14px;
  }
}

/* Studio 5-tab bar */
.studio-subtab-bar { padding: 0 4px; }
.studio-subtab-bar .subtab-btn { padding: 10px 10px; font-size: 12.5px; }

/* Job Row Cards (Print & Press History) */
.job-row-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.job-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}

.app-bottom-nav {
  height: calc(var(--bottom-nav-h) + var(--safe-bottom));
  padding: 2px 2px calc(2px + var(--safe-bottom)) 2px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 30;
  box-shadow: 0 -2px 10px rgba(15, 23, 42, 0.04);
  overflow: hidden;
}

.bottom-nav-item {
  flex: 1;
  min-width: 0;
  padding: 3px 1px;
  gap: 2px;
}
.bottom-nav-item .nav-icon { font-size: 19px; line-height: 1.1; }
.bottom-nav-label {
  font-size: 10px;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  display: block;
}

@media (min-width: 860px) {
  .app-sidebar {
    display: flex;
  }
  .app-bottom-nav {
    display: none !important;
  }
}

html.keyboard-open .app-bottom-nav,
html.keyboard-open .fab-container {
  display: none !important;
}

/* Flex & Grid Utilities */
.row { display: flex; align-items: center; }
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.wrap { flex-wrap: wrap; }
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (max-width: 380px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.section-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
}
@media (min-width: 640px) {
  .section-title {
    font-size: 19px;
  }
}
.section-subtitle {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Additional Button & Badge Variants */
.btn-secondary {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #bae6fd;
}
.btn-secondary:hover:not(:disabled) { background: #bae6fd; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--bg); }
.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  font-size: 17px;
}

.badge-neutral { background: #f1f5f9; color: #334155; }
.badge-success { background: #dcfce7; color: #15803d; }

/* Empty State & Spinner */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 36px 16px;
  gap: 8px;
}
.empty-state-icon {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 4px;
}
.empty-state-title {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text);
}
.empty-state-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  max-width: 440px;
}
.spinner {
  width: 34px;
  height: 34px;
  border: 3.5px solid #cbd5e1;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* CCTV Overlays */
.cctv-badge-live {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(220, 38, 38, 0.88);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.cctv-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
}
.cctv-label-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 12px;
  background: linear-gradient(transparent, rgba(0,0,0,0.82));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Modal Dialog & Lightbox */
.modal-dialog {
  background: var(--surface);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalPop 0.18s ease-out;
}
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: #cbd5e1; }

.lightbox-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(4px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 12px 16px;
  z-index: 250;
}
.lightbox-backdrop.open { display: flex; }
.lightbox-viewport {
  width: 100%;
  height: 100%;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}
.lightbox-viewport.scrollable-mode { align-items: flex-start; }
.lightbox-backdrop img {
  max-width: 94vw;
  max-height: 82vh;
  border-radius: 12px;
  object-fit: contain;
  background-color: #ffffff;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  transition: background-color 0.15s ease;
  cursor: zoom-in;
}
.lightbox-backdrop img.fit-width-roll {
  width: min(92vw, 960px);
  max-width: none;
  max-height: none;
  height: auto;
  cursor: zoom-out;
}
.lightbox-backdrop img.bg-checker {
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
    linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
    linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.lightbox-backdrop img.bg-white { background-color: #ffffff; background-image: none; }
.lightbox-backdrop img.bg-grey { background-color: #94a3b8; background-image: none; }
.lightbox-backdrop img.bg-dark { background-color: #1e293b; background-image: none; }
.lightbox-bg-toolbar {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 5px 12px;
  border-radius: 999px;
  z-index: 255;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  max-width: calc(100vw - 104px);
  overflow-x: auto;
  white-space: nowrap;
}
.lightbox-bg-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.65);
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.12s, border-color 0.12s;
}
.lightbox-bg-btn.active {
  border-color: #fbbf24;
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.45);
  transform: scale(1.08);
}
.lightbox-zoom-btn {
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  font-family: inherit;
}
.lightbox-zoom-btn:hover,
.lightbox-zoom-btn.active { background: #0284c7; border-color: #38bdf8; }

/* In-App Top Chat Notification Banner */
.chat-top-banner {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 420px);
  background: #0f172a;
  color: #ffffff;
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-radius: 16px;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 300;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.45);
  cursor: pointer;
  animation: modalPop 0.2s ease-out;
}

/* ==========================================================================
   1:1 Flutter HalftoneStudioScreen Styles
   ========================================================================== */
.flt-studio-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: calc(var(--app-height, 100dvh) - var(--header-h));
  background: #eeeeee;
  position: relative;
  overflow: hidden;
}
@media (max-width: 859px) {
  .flt-studio-shell {
    height: calc(var(--app-height, 100dvh) - var(--header-h) - var(--bottom-nav-h) - var(--safe-bottom));
  }
}

.flt-studio-tabbar {
  display: flex;
  background: #ffffff;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
  width: 100%;
}
.flt-studio-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 48px;
  padding: 8px 4px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #9e9e9e;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}
.flt-studio-tab:hover { background: rgba(33, 150, 243, 0.04); }
.flt-studio-tab.active {
  color: #2196f3;
  border-bottom-color: #2196f3;
  font-weight: 700;
}
@media (max-width: 599px) {
  .flt-studio-tab .tab-label {
    display: none;
  }
}

.flt-studio-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.flt-studio-split {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.flt-studio-left {
  flex: 2;
  background: #eeeeee;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.flt-studio-right {
  flex: 1;
  min-width: 310px;
  max-width: 460px;
  background: #ffffff;
  border-left: 1px solid #e0e0e0;
  padding: 24px;
  overflow-y: auto;
}

.flt-compare-row {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.flt-compare-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.flt-compare-divider {
  width: 1px;
  background: #e0e0e0;
  flex-shrink: 0;
}

@media (max-width: 699px) {
  .flt-studio-shell {
    height: auto;
    min-height: calc(100dvh - var(--header-h) - var(--bottom-nav-h));
    overflow: visible;
  }
  .flt-studio-body {
    overflow: visible;
  }
  .flt-studio-split {
    flex-direction: column;
    overflow: visible;
  }
  .flt-studio-right {
    max-width: none;
    min-width: 0;
    border-left: none;
    border-bottom: 1px solid #e0e0e0;
    padding: 16px;
    overflow: visible;
  }
  .flt-compare-row {
    flex-direction: column;
  }
  .flt-compare-col {
    min-height: 340px;
  }
  .flt-compare-divider {
    width: 100%;
    height: 1px;
  }
}

.flt-toolbar {
  background: #ffffff;
  padding: 8px 16px;
  border-bottom: 1px solid #eeeeee;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  flex-shrink: 0;
}

.flt-icon-btn-filled {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.flt-icon-btn-filled:hover { filter: brightness(0.95); }
.flt-icon-btn-filled:active { transform: scale(0.95); }

.flt-checkerboard {
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, #e0e0e0 25%, transparent 25%),
    linear-gradient(-45deg, #e0e0e0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e0e0e0 75%),
    linear-gradient(-45deg, transparent 75%, #e0e0e0 75%);
  background-size: 40px 40px;
  background-position: 0 0, 0 20px, 20px -20px, -20px 0;
}

.flt-preview-viewport {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 16px;
  position: relative;
}
.flt-preview-viewport canvas,
.flt-preview-viewport img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.flt-bg-swatch {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid #9e9e9e;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.flt-bg-swatch.active { border: 2px solid #2196f3; }

.flt-elevated-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  height: 42px;
  border-radius: 999px;
  border: none;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  transition: filter 0.15s, box-shadow 0.15s;
}
.flt-elevated-btn:hover:not(:disabled) { filter: brightness(0.96); box-shadow: 0 2px 6px rgba(0,0,0,0.22); }
.flt-elevated-btn:disabled {
  background: #e0e0e0 !important;
  color: #9e9e9e !important;
  box-shadow: none !important;
  cursor: not-allowed;
}

.flt-segmented {
  display: inline-flex;
  border: 1px solid #79747e;
  border-radius: 999px;
  overflow: hidden;
  background: #ffffff;
}
.flt-seg-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  border: none;
  border-right: 1px solid #79747e;
  background: transparent;
  color: #1d1b20;
  font-size: 13px;
  cursor: pointer;
}
.flt-seg-item:last-child { border-right: none; }
.flt-seg-item.active {
  background: #e8def8;
  color: #1d192b;
  font-weight: 700;
}

