/* LUXIOUS QR STUDIO - components (shared by offline and hosted apps). */

/* ---------- Buttons ---------- */
.btn {
  --btn-h: 38px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--btn-h); padding: 0 16px; border-radius: var(--r-pill);
  font-size: var(--fs-base); font-weight: 550; letter-spacing: -0.005em; white-space: nowrap;
  border: 1px solid transparent; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: transform var(--dur-press) var(--ease-out), background-color var(--dur-fast) ease, border-color var(--dur-fast) ease, color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
  touch-action: manipulation;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn svg.icon { width: 17px; height: 17px; }
.btn-primary { background: var(--ink); color: var(--on-ink); box-shadow: var(--shadow-1); }
.btn-primary:hover { background: var(--ink-hover); }
.btn-secondary { background: var(--bg-elev); color: var(--text); border-color: var(--line-strong); box-shadow: var(--shadow-1); }
.btn-secondary:hover { border-color: var(--text-3); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-gold { background: var(--gold); color: #17181c; }
.btn-gold:hover { filter: brightness(1.05); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-sm { --btn-h: 32px; padding: 0 12px; font-size: var(--fs-sm); }
.btn-lg { --btn-h: 46px; padding: 0 22px; font-size: var(--fs-md); }
.btn-block { width: 100%; }
.btn-icon { width: var(--btn-h); padding: 0; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn .spinner { width: 15px; height: 15px; }
.btn-trail {
  display: inline-grid; place-items: center; width: 26px; height: 26px; margin-inline-end: -10px;
  border-radius: 50%; background: rgba(255, 255, 255, 0.14);
  transition: transform var(--dur) var(--ease-out);
}
.btn-primary:hover .btn-trail { transform: translateX(2px); }
[dir="rtl"] .btn-primary:hover .btn-trail { transform: translateX(-2px); }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-sm);
  color: var(--text-2); transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease, transform var(--dur-press) var(--ease-out);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg.icon { width: 19px; height: 19px; }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Form fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 14px; }
.field-grid > .full { grid-column: 1 / -1; }
.label { font-size: var(--fs-sm); font-weight: 550; color: var(--text); display: flex; align-items: center; gap: 6px; }
.label .req { color: var(--gold-text); font-weight: 600; }
.label .opt { color: var(--text-3); font-weight: 400; }
.hint { font-size: var(--fs-xs); color: var(--text-3); line-height: 1.45; }
.error-text { font-size: var(--fs-xs); color: var(--danger); display: flex; gap: 6px; align-items: flex-start; }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 9px 12px; border-radius: var(--r-sm);
  background: var(--field); border: 1px solid var(--line-strong); color: var(--text);
  font-size: var(--fs-base); line-height: 1.4;
  transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); opacity: 1; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--gold-soft); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--danger); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--danger-soft); }
.textarea { resize: vertical; min-height: 84px; }
.select {
  appearance: none; -webkit-appearance: none; padding-inline-end: 36px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
[dir="rtl"] .select { background-position: 13px 52%, 18px 52%; }
.input-group { display: flex; align-items: stretch; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--field); transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease; }
.input-group:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px var(--gold-soft); }
.input-group .input { border: 0; box-shadow: none !important; background: transparent; }
.input-group .addon { display: flex; align-items: center; padding: 0 10px; color: var(--text-3); font-size: var(--fs-sm); white-space: nowrap; }
.input-group .addon + .input { padding-inline-start: 0; }
input[type="number"].input { -moz-appearance: textfield; }
.input-mono { font-family: var(--font-mono); font-size: var(--fs-sm); }

/* Checkbox / switch */
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--fs-base); user-select: none; min-height: 32px; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .box {
  width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--line-strong); background: var(--field);
  display: grid; place-items: center; transition: background-color var(--dur-fast) ease, border-color var(--dur-fast) ease; flex: none;
}
.check .box svg { width: 12px; height: 12px; fill: var(--on-ink); opacity: 0; transform: scale(0.6); transition: opacity var(--dur-fast) ease, transform var(--dur-fast) var(--ease-out); }
.check input:checked + .box { background: var(--ink); border-color: var(--ink); }
.check input:checked + .box svg { opacity: 1; transform: scale(1); }
.check input:focus-visible + .box { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: 32px; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 36px; height: 20px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--line);
  position: relative; transition: background-color var(--dur-fast) ease; flex: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--bg-elev); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform var(--dur) var(--ease-out);
}
.switch input:checked + .track { background: var(--ink); }
.switch input:checked + .track::after { transform: translateX(16px); background: var(--on-ink); }
[dir="rtl"] .switch input:checked + .track::after { transform: translateX(-16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Range slider */
.range { display: flex; align-items: center; gap: 12px; }
.range input[type="range"] { flex: 1; appearance: none; -webkit-appearance: none; height: 4px; border-radius: 4px; background: var(--surface-3); outline-offset: 6px; }
.range input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--bg-elev); border: 1.5px solid var(--ink); box-shadow: var(--shadow-1); cursor: grab; }
.range input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--bg-elev); border: 1.5px solid var(--ink); cursor: grab; }
.range output { min-width: 44px; text-align: end; font-variant-numeric: tabular-nums; font-size: var(--fs-sm); color: var(--text-2); }

/* Colour field */
.color-field { display: flex; align-items: center; gap: 0; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--field); height: 40px; padding-inline-start: 6px; transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease; }
.color-field:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px var(--gold-soft); }
.color-field .swatch { position: relative; width: 28px; height: 28px; border-radius: 6px; overflow: hidden; flex: none; box-shadow: inset 0 0 0 1px var(--line-strong); }
.color-field .swatch input[type="color"] { position: absolute; inset: -8px; width: 44px; height: 44px; border: 0; padding: 0; cursor: pointer; opacity: 0; }
.color-field .input { border: 0; box-shadow: none !important; background: transparent; font-family: var(--font-mono); font-size: var(--fs-sm); text-transform: uppercase; min-height: 36px; padding-inline: 8px; }

/* ---------- Segmented control ---------- */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--line); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button, .seg label {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 30px; padding: 0 12px; border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: 550; color: var(--text-2); white-space: nowrap; cursor: pointer;
  transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
.seg button:hover { color: var(--text); }
.seg [aria-pressed="true"], .seg [aria-selected="true"], .seg input:checked + span { background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }
.seg-block { display: flex; width: 100%; }
.seg-block button { flex: 1; }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--r-pill);
  border: 1px solid var(--line-strong); background: var(--bg-elev); color: var(--text-2); font-size: var(--fs-sm); font-weight: 500; white-space: nowrap;
  transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease, border-color var(--dur-fast) ease, transform var(--dur-press) var(--ease-out);
}
.chip:hover { color: var(--text); border-color: var(--text-3); }
.chip:active { transform: scale(0.97); }
.chip[aria-pressed="true"], .chip.is-active { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.chip svg.icon { width: 15px; height: 15px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 12px;
  color: var(--text-2); font-weight: 550; font-size: var(--fs-sm); white-space: nowrap; border-radius: var(--r-sm) var(--r-sm) 0 0;
  transition: color var(--dur-fast) ease;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; inset-inline: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--ink); }
.tab svg.icon { width: 16px; height: 16px; }

/* ---------- Surfaces ---------- */
.panel { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.panel-pad { padding: 20px; }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2, .panel-head h3 { font-size: var(--fs-md); font-weight: 600; }
.panel-body { padding: 20px; }
.card { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--r-md); }
.bezel { padding: 6px; border-radius: var(--r-xl); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.bezel > .bezel-core { border-radius: calc(var(--r-xl) - 6px); background: var(--bg-elev); box-shadow: var(--shadow-1), var(--inner-hi); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line);
}
.badge svg.icon { width: 13px; height: 13px; }
.badge-dynamic { background: var(--gold-soft); color: var(--gold-text); border-color: var(--gold-line); }
.badge-static { background: var(--surface-2); color: var(--text-2); }
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-ink { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }

/* ---------- Alerts ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-md); font-size: var(--fs-sm); line-height: 1.5; border: 1px solid var(--line); background: var(--surface-2); color: var(--text-2); }
.alert svg.icon { width: 18px; height: 18px; margin-top: 1px; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.alert-warn { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.alert-gold { background: var(--gold-soft); color: var(--gold-text); border-color: var(--gold-line); }
.alert strong { color: inherit; font-weight: 650; }

/* ---------- Empty state ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 48px 24px; }
.empty .empty-mark {
  width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; margin-bottom: 6px;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); color: var(--gold-text);
}
.empty .empty-mark svg.icon { width: 28px; height: 28px; }
.empty h3 { font-size: var(--fs-lg); }
.empty p { color: var(--text-2); max-width: 44ch; margin: 0; }
.empty .row-wrap { justify-content: center; margin-top: 8px; }

/* ---------- Skeleton ---------- */
.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--r-sm); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

/* ---------- Dialog ---------- */
.dialog-backdrop {
  position: fixed; inset: 0; z-index: var(--z-overlay); background: var(--scrim); display: grid; place-items: center; padding: 16px;
  opacity: 0; transition: opacity var(--dur) var(--ease-out);
}
.dialog-backdrop.is-open { opacity: 1; }
.dialog {
  width: min(520px, 100%); max-height: min(86dvh, 820px); overflow: auto; background: var(--bg-elev); border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop), 0 0 0 1px var(--line); transform: scale(0.96); opacity: 0;
  transition: transform var(--dur) var(--ease-out), opacity var(--dur) var(--ease-out);
}
.dialog-backdrop.is-open .dialog { transform: scale(1); opacity: 1; }
.dialog-lg { width: min(760px, 100%); }
.dialog-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px 6px; }
.dialog-head h2 { font-size: var(--fs-lg); }
.dialog-body { padding: 10px 22px 18px; color: var(--text-2); }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px 20px; flex-wrap: wrap; }

/* ---------- Bottom sheet (mobile) ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: var(--z-overlay); background: var(--scrim); opacity: 0; transition: opacity var(--dur) var(--ease-out); }
.sheet-backdrop.is-open { opacity: 1; }
.sheet {
  position: fixed; inset-inline: 0; bottom: 0; z-index: calc(var(--z-overlay) + 1); max-height: 92dvh; overflow: auto;
  background: var(--bg-elev); border-radius: 24px 24px 0 0; box-shadow: var(--shadow-pop);
  transform: translateY(100%); transition: transform 360ms var(--ease-drawer); padding-bottom: env(safe-area-inset-bottom);
  overscroll-behavior: contain;
}
.sheet.is-open { transform: translateY(0); }
.sheet-grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line-strong); margin: 10px auto 4px; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 8px 18px 4px; }
.sheet-body { padding: 8px 18px 20px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: var(--z-toast); bottom: 20px; inset-inline-end: 20px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; max-width: calc(100vw - 32px); }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 420px; padding: 12px 14px 12px 12px;
  border-radius: var(--r-md); background: var(--ink); color: var(--on-ink); box-shadow: var(--shadow-pop); font-size: var(--fs-sm);
  transform: translateY(12px); opacity: 0; transition: transform 260ms var(--ease-out), opacity 260ms var(--ease-out);
}
.toast.is-in { transform: translateY(0); opacity: 1; }
.toast.is-out { transform: translateY(6px); opacity: 0; transition-duration: 180ms; }
.toast svg.icon { width: 18px; height: 18px; flex: none; }
.toast.ok svg.icon { color: #7fd3a4; }
.toast.err svg.icon { color: #ff9a92; }
.toast .toast-action { margin-inline-start: auto; color: var(--gold); font-weight: 600; padding: 4px 6px; border-radius: 6px; }
@media (max-width: 767px) { .toasts { inset-inline: 16px; bottom: calc(var(--bottomnav-h) + 14px + env(safe-area-inset-bottom)); align-items: stretch; } .toast { max-width: none; min-width: 0; } }

/* ---------- Menus ---------- */
.menu-wrap { position: relative; display: inline-flex; }
.menu {
  position: absolute; z-index: var(--z-overlay); top: calc(100% + 6px); inset-inline-end: 0; min-width: 200px; padding: 6px;
  background: var(--bg-elev); border-radius: var(--r-md); box-shadow: var(--shadow-pop), 0 0 0 1px var(--line);
  transform-origin: top right; transform: scale(0.97); opacity: 0; pointer-events: none;
  transition: transform var(--dur-fast) var(--ease-out), opacity var(--dur-fast) var(--ease-out);
}
[dir="rtl"] .menu { transform-origin: top left; }
.menu.is-open { transform: scale(1); opacity: 1; pointer-events: auto; }
.menu-item { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); font-size: var(--fs-sm); color: var(--text); text-align: start; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); outline: none; }
.menu-item svg.icon { width: 17px; height: 17px; color: var(--text-2); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger svg.icon { color: var(--danger); }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); }
.table th { text-align: start; font-weight: 550; color: var(--text-3); font-size: var(--fs-xs); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background-color var(--dur-fast) ease; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: end; font-variant-numeric: tabular-nums; }

/* ---------- Dropzone ---------- */
.dropzone {
  display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: var(--r-md); border: 1.5px dashed var(--line-strong);
  background: var(--surface-2); cursor: pointer; transition: border-color var(--dur-fast) ease, background-color var(--dur-fast) ease;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--gold); background: var(--gold-soft); }
.dropzone .dz-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--bg-elev); box-shadow: inset 0 0 0 1px var(--line); color: var(--text-2); flex: none; }
.dropzone input[type="file"] { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }

/* ---------- Progress ---------- */
.progress { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--ink); transition: width 200ms linear; }

/* ---------- Misc ---------- */
.kbd { font-family: var(--font-mono); font-size: 11px; padding: 1px 6px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); }
.divider { height: 1px; background: var(--line); border: 0; margin: 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); color: var(--text); display: grid; place-items: center; font-weight: 600; font-size: 13px; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.checker {
  background-color: var(--bg-elev);
  background-image: linear-gradient(45deg, var(--checker) 25%, transparent 25%), linear-gradient(-45deg, var(--checker) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--checker) 75%), linear-gradient(-45deg, transparent 75%, var(--checker) 75%);
  background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--text-3); }
.status-dot.ok { background: var(--success); }
.status-dot.bad { background: var(--danger); }
.status-dot.wait { background: var(--warning); }

@media (max-width: 767px) {
  .input, .select, .textarea { font-size: 16px; min-height: 44px; }
  .btn { --btn-h: 42px; }
  .btn-sm { --btn-h: 36px; }
  .field-grid { grid-template-columns: 1fr; }
}
@media (hover: none) {
  .table tbody tr:hover { background: transparent; }
}

/* Form actions keep their natural width inside field stacks */
.field > .btn, .field > form > .btn { align-self: flex-start; }
