/* BBQ — la file d'impression. Mobile-first, light/dark via prefers-color-scheme. */

:root {
  color-scheme: light dark;
  --bg: #f6f4f1;
  --surface: #ffffff;
  --surface-2: #f1ede7;
  --border: #e4ded5;
  --text: #1f1c18;
  --muted: #6b645a;
  --accent: #c94a1c;
  --accent-hover: #b03f15;
  --accent-contrast: #ffffff;
  --accent-soft: #fde6db;
  --accent-text: #a63c14;
  --ok: #1d7f46;
  --ok-soft: #dcf2e4;
  --warn: #9a5b00;
  --warn-soft: #fcefd3;
  --danger: #c0292b;
  --danger-soft: #fbe2e2;
  --info: #2459b8;
  --info-soft: #e0e9fb;
  --mine: #6b3fb5;
  --mine-soft: #ece4fa;
  --focus: #2f6fe4;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 6px 20px rgb(0 0 0 / 0.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14120f;
    --surface: #1d1a17;
    --surface-2: #29251f;
    --border: #39332c;
    --text: #f1ece6;
    --muted: #a99f93;
    --accent: #f07443;
    --accent-hover: #ff8a5c;
    --accent-contrast: #1a0f0a;
    --accent-soft: #3b2219;
    --accent-text: #ff9a6e;
    --ok: #5cc98a;
    --ok-soft: #15301f;
    --warn: #e8ab45;
    --warn-soft: #34280f;
    --danger: #f27474;
    --danger-soft: #3b1a1a;
    --info: #79a6f2;
    --info-soft: #172642;
    --mine: #b99af0;
    --mine-soft: #2a2140;
    --focus: #7fa9ff;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 6px 20px rgb(0 0 0 / 0.25);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: var(--accent-text);
  text-underline-offset: 2px;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--surface-2);
  padding: 0.05em 0.35em;
  border-radius: 5px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.875rem;
}

.boot,
.noscript {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--muted);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Cards ---------------------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-top: 0.5rem;
}

.count {
  color: var(--muted);
  font-weight: 500;
}

.empty {
  color: var(--muted);
  padding: 1rem 0;
  text-align: center;
}

/* Buttons -------------------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  transition: background-color 0.15s, border-color 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn[aria-busy="true"] {
  cursor: progress;
}

.btn-sm {
  min-height: 36px;
  padding: 0.35rem 0.75rem;
  font-size: 0.9rem;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  min-width: 36px;
  padding-inline: 0.5rem;
  font-size: 1rem;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}

.btn-primary:not(:disabled):hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
}

.btn-secondary:not(:disabled):hover,
.btn-ghost:not(:disabled):hover {
  background: var(--surface-2);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
}

.btn-ok {
  background: var(--ok);
  color: var(--surface);
}

.btn-warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 35%, transparent);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
}

.btn-danger-ghost:not(:disabled):hover {
  background: var(--danger-soft);
}

.btn-warn-ghost {
  background: transparent;
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 40%, transparent);
}

.btn-warn-ghost:not(:disabled):hover {
  background: var(--warn-soft);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* Chips ---------------------------------------------------------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--muted);
}

.chip-accent {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.chip-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.chip-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.chip-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.chip-info {
  background: var(--info-soft);
  color: var(--info);
}

.chip-mine {
  background: var(--mine-soft);
  color: var(--mine);
}

.chip-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 500;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* Forms ---------------------------------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

.field > label,
.duration legend {
  font-weight: 600;
  font-size: 0.92rem;
}

fieldset.field {
  border: 0;
  margin: 0;
  padding: 0;
}

fieldset.field legend {
  padding: 0;
  margin-bottom: 0.3rem;
}

input[type="text"],
input[type="url"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* avoids iOS zoom on focus */
}

textarea {
  resize: vertical;
  min-height: 4.5rem;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 0;
  border-color: var(--focus);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.75;
}

.help {
  color: var(--muted);
  font-size: 0.86rem;
}

.form-row {
  display: grid;
  gap: 0.9rem;
}

@media (min-width: 560px) {
  .form-row {
    grid-template-columns: 1fr 1fr;
  }
}

.duration-inputs {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.duration-part {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.duration-part label {
  color: var(--muted);
  font-weight: 600;
}

.input-num {
  width: 5.5rem !important;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  cursor: pointer;
}

.check input {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--accent);
}

.input-with-btn {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.input-with-btn input {
  flex: 1;
}

.add-form,
.edit-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.status-line {
  font-size: 0.9rem;
  color: var(--muted);
}

.status-line:empty {
  display: none;
}

.status-ok {
  color: var(--ok);
}

.status-error,
.error-text {
  color: var(--danger);
  font-size: 0.9rem;
}

/* Notices & toasts ----------------------------------------------------------------------------- */

.notice {
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.95rem;
}

.notice-info {
  background: var(--info-soft);
  color: var(--info);
}

.notice-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.notice-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(92vw, 420px);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.5rem 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.2);
  pointer-events: auto;
  animation: toast-in 0.18s ease-out;
}

.toast-error {
  background: var(--danger);
  color: #ffffff;
}

.toast-info {
  background: var(--info);
  color: #ffffff;
}

.toast-text {
  flex: 1;
  font-size: 0.95rem;
}

.toast-close {
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 1.3rem;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    animation: none;
  }
}

/* Auth screens --------------------------------------------------------------------------------- */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.auth-card {
  width: min(100%, 420px);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
}

.brand-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  text-align: center;
}

.brand-logo-lg {
  border-radius: 14px;
}

.brand-title {
  font-size: 1.45rem;
  letter-spacing: -0.02em;
}

.auth-heading {
  font-size: 1.2rem;
  text-align: center;
}

.lead,
.invite-label {
  text-align: center;
}

.provider-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.guest-note {
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* Top bar & tabs ------------------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.55rem 1rem;
  padding-top: calc(0.55rem + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-right: auto;
}

.brand-logo {
  border-radius: 8px;
}

.brand-name {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}

.brand-sub {
  display: none;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (min-width: 640px) {
  .brand-sub {
    display: inline;
  }
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.live::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.live-on::before {
  background: var(--ok);
}

.live-off::before {
  background: var(--warn);
}

.me {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.me-name {
  font-weight: 600;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  flex: none;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
}

.avatar-sm {
  width: 32px;
  height: 32px;
}

.avatar-md {
  width: 44px;
  height: 44px;
}

.avatar-initials {
  --avatar-hue: 20;
  display: inline-grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: hsl(var(--avatar-hue) 55% 30%);
  background: hsl(var(--avatar-hue) 70% 88%);
}

@media (prefers-color-scheme: dark) {
  .avatar-initials {
    color: hsl(var(--avatar-hue) 70% 85%);
    background: hsl(var(--avatar-hue) 35% 28%);
  }
}

.avatar-md.avatar-initials {
  font-size: 1rem;
}

.tabs-wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.75rem 1rem 0;
}

.tabs {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0.2rem;
  background: var(--surface-2);
  border-radius: 12px;
  width: fit-content;
  max-width: 100%;
}

.tab {
  flex: none;
  min-height: 40px;
  padding: 0.4rem 0.95rem;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.1);
}

.content {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1rem 1rem calc(5rem + env(safe-area-inset-bottom, 0px));
}

/* File tab layout ------------------------------------------------------------------------------ */

.file-layout {
  display: grid;
  gap: 1rem;
}

.col-side,
.col-main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.printing-box:empty {
  display: none;
}

@media (min-width: 920px) {
  .file-layout {
    grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
    align-items: start;
  }

  .col-side {
    position: sticky;
    top: 5rem;
  }
}

/* Printer card */

.printer-card,
.printing-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.printer-big {
  font-size: 1.2rem;
  font-weight: 700;
}

.printer-subtask {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.progress-pct {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  min-width: 3.2rem;
  text-align: right;
}

progress {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 10px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

progress::-webkit-progress-bar {
  background: var(--surface-2);
  border-radius: 999px;
}

progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 999px;
}

progress::-moz-progress-bar {
  background: var(--accent);
  border-radius: 999px;
}

.printer-temps {
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  display: flex;
  flex-wrap: wrap;
  column-gap: 0.4rem;
}

.printing-card {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: linear-gradient(180deg, var(--accent-soft), var(--surface) 70%);
}

/* Jobs */

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin-bottom: 0.5rem;
}

.queue-total {
  font-size: 0.9rem;
}

.job-list,
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.job {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.4rem 0.75rem;
  padding: 0.85rem 0;
  border-top: 1px solid var(--border);
}

.job:first-child {
  border-top: 0;
}

.job-mine {
  box-shadow: inset 3px 0 0 var(--mine);
  padding-left: 0.6rem;
  margin-left: -0.25rem;
}

.job-pos {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--surface-2);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.job-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.job-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.job-title {
  font-weight: 650;
  overflow-wrap: anywhere;
}

.job-notes {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.93rem;
}

.job-meta {
  color: var(--muted);
  font-size: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 0.4rem;
}

.job-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

@media (min-width: 640px) {
  .job {
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
  }

  .job-actions {
    grid-column: auto;
    justify-content: flex-end;
    max-width: 22rem;
  }
}

.job-editing {
  grid-template-columns: auto minmax(0, 1fr) !important;
  align-items: start !important;
}

.edit-form {
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.edit-form input,
.edit-form textarea {
  background: var(--surface);
}

/* History */

.history summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 1.05rem;
  list-style-position: inside;
}

.history[open] summary {
  margin-bottom: 0.5rem;
}

.hist-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.4rem 0.75rem;
  align-items: center;
  padding: 0.7rem 0;
  border-top: 1px solid var(--border);
}

.hist-item:first-child {
  border-top: 0;
}

.hist-item > .btn {
  grid-column: 1 / -1;
  justify-self: start;
}

@media (min-width: 640px) {
  .hist-item {
    grid-template-columns: 6.5rem minmax(0, 1fr) auto;
  }

  .hist-item > .btn {
    grid-column: auto;
  }

  .hist-item > .chip {
    justify-self: start;
  }
}

.hist-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

/* Invitations ---------------------------------------------------------------------------------- */

.invite-list,
.user-list {
  display: grid;
  gap: 1rem;
}

@media (min-width: 920px) {
  .user-list {
    grid-template-columns: 1fr 1fr;
  }
}

.invite-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

@media (min-width: 640px) {
  .invite-card {
    flex-direction: row;
    align-items: flex-start;
  }
}

.invite-body {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex: 1;
  min-width: 0;
  width: 100%;
}

.invite-title {
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.invite-inactive {
  box-shadow: none;
  opacity: 0.8;
}

.old-invites summary {
  cursor: pointer;
  font-weight: 700;
}

.old-invites[open] summary {
  margin-bottom: 0.75rem;
}

.qr-wrap {
  flex: none;
  display: block;
  padding: 10px;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid var(--border);
  line-height: 0;
}

.qr {
  display: block;
  width: 220px;
  height: 220px;
}

.invite-url {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem !important;
}

/* Users ---------------------------------------------------------------------------------------- */

.user-card {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.user-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.user-id {
  min-width: 0;
}

.user-name {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.user-email {
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.lock-note {
  color: var(--muted);
  font-size: 0.82rem;
  font-style: italic;
}

/* Settings ------------------------------------------------------------------------------------- */

.settings-grid {
  display: grid;
  gap: 1rem;
  align-items: start;
}

@media (min-width: 920px) {
  .settings-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.sep {
  opacity: 0.7;
}
