/*
 * shadcn/ui "neutral" tokens and components as plain CSS. No build step.
 * --primary is the DigiCMS teal-green (#068a72 in the logo), a little darker
 * so white button text stays readable (5:1). --primary-text is for text on the page.
 */
:root {
  --radius: .625rem;
  --background: oklch(1 0 0);
  --foreground: oklch(.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(.145 0 0);
  --popover: oklch(1 0 0);
  --primary: oklch(.53 .1 172);
  --primary-foreground: oklch(1 0 0);
  --primary-text: oklch(.5 .095 172);
  --secondary: oklch(.97 0 0);
  --secondary-foreground: oklch(.205 0 0);
  --muted: oklch(.97 0 0);
  --muted-foreground: oklch(.556 0 0);
  --accent: oklch(.97 0 0);
  --accent-foreground: oklch(.205 0 0);
  --destructive: oklch(.48 .19 18);
  --border: oklch(.922 0 0);
  --input: oklch(.922 0 0);
  --ring: oklch(.7 .11 172);
  --sidebar: oklch(.985 0 0);
  --success: oklch(.527 .154 150.069);
  --warning: oklch(.555 .163 48.998);
  /* Second and third brand colors, set in Settings > Colors & fonts. */
  --brand-secondary: oklch(.33 .1 258);
  --brand-secondary-foreground: oklch(1 0 0);
  --brand-accent: oklch(.8 .16 85);
  --brand-accent-foreground: oklch(.145 0 0);
  color-scheme: light;
}
.dark {
  --background: oklch(.145 0 0);
  --foreground: oklch(.985 0 0);
  --card: oklch(.205 0 0);
  --card-foreground: oklch(.985 0 0);
  --popover: oklch(.205 0 0);
  --primary: oklch(.53 .1 172);
  --primary-foreground: oklch(1 0 0);
  --primary-text: oklch(.78 .12 172);
  --secondary: oklch(.269 0 0);
  --secondary-foreground: oklch(.985 0 0);
  --muted: oklch(.269 0 0);
  --muted-foreground: oklch(.708 0 0);
  --accent: oklch(.269 0 0);
  --accent-foreground: oklch(.985 0 0);
  --destructive: oklch(.704 .191 12);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(.68 .11 172);
  --sidebar: oklch(.205 0 0);
  --success: oklch(.792 .209 151.711);
  --warning: oklch(.828 .189 84.429);
  color-scheme: dark;
}

*, ::before, ::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
a, button, input, select, textarea, label, summary { touch-action: manipulation; }
body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { text-wrap: balance; }
svg { flex-shrink: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: -60px; left: 8px; z-index: 70; padding: 8px 12px; border: 1px solid var(--border); border-radius: calc(var(--radius) - 2px); background: var(--background); color: var(--foreground); font-weight: 500; }
.skip-link:focus { top: 8px; }
#main:focus { outline: 0; }
.muted { color: var(--muted-foreground); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack { display: grid; gap: 16px; }
.stack-sm { display: grid; gap: 8px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link { text-decoration: underline; text-underline-offset: 3px; }

/* Button */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border: 1px solid transparent; border-radius: calc(var(--radius) - 2px);
  background: var(--primary); color: var(--primary-foreground);
  font: inherit; font-weight: 500; white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: opacity .15s, background-color .15s;
}
.btn:hover { opacity: .9; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; }
.btn[aria-busy="true"] svg { display: none; }
.btn[aria-busy="true"]::before { content: ""; width: 14px; height: 14px; flex-shrink: 0; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-outline { background: var(--background); color: var(--foreground); border-color: var(--input); }
.dark .btn-outline { background: var(--input); }
.btn-outline:hover, .btn-ghost:hover { background: var(--accent); color: var(--accent-foreground); opacity: 1; }
.btn-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.btn-ghost { background: transparent; color: var(--foreground); }
.btn-danger { background: var(--destructive); color: #fff; }
.dark .btn-danger { color: oklch(.205 0 0); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-icon-danger:hover { color: var(--destructive); }
.btn-block { width: 100%; }

/* Forms */
.field { display: grid; gap: 6px; }
.label { font-weight: 500; font-size: 14px; }
.help { font-size: 12px; color: var(--muted-foreground); }
.error { font-size: 12px; color: var(--destructive); }
.input, .select, .textarea {
  width: 100%; min-height: 36px; padding: 7px 12px; border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px); background: transparent; color: var(--foreground); font: inherit;
}
.dark .input, .dark .select, .dark .textarea { background: var(--input); }
.select { appearance: auto; padding-right: 8px; }
.select option { background: var(--popover); color: var(--foreground); }
.textarea { min-height: 88px; resize: vertical; }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: 0; border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 40%, transparent); }
[aria-invalid="true"] { border-color: var(--destructive); }
.input::placeholder, .textarea::placeholder { color: var(--muted-foreground); }
input[type="checkbox"].checkbox {
  appearance: none; width: 16px; height: 16px; margin: 0; flex-shrink: 0; cursor: pointer;
  border: 1px solid var(--input); border-radius: 4px; background: transparent; display: inline-grid; place-items: center;
}
.dark input[type="checkbox"].checkbox { background: var(--input); }
input[type="checkbox"].checkbox:checked, input[type="checkbox"].checkbox:indeterminate { background: var(--primary); border-color: var(--primary); }
input[type="checkbox"].checkbox:checked::after {
  content: ""; width: 9px; height: 5px; margin-top: -2px; transform: rotate(-45deg);
  border-left: 2px solid var(--primary-foreground); border-bottom: 2px solid var(--primary-foreground);
}
input[type="checkbox"].checkbox:indeterminate::after { content: ""; width: 8px; height: 2px; background: var(--primary-foreground); }
.check-row { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
/* Checkbox lists in forms: options as bordered rows, in groups with "Select all", a count and a filter. */
.check-panel { display: grid; gap: 14px; }
.check-panel-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.check-filter { flex: 1 1 180px; min-height: 34px; }
.check-count { margin-left: auto; white-space: nowrap; }
.check-group { display: grid; gap: 8px; }
.check-group-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted-foreground); }
.check-group-all { appearance: none; border: 0; background: none; padding: 2px 4px; border-radius: 4px; font: inherit; font-size: 12px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--primary); cursor: pointer; }
.check-group-all:hover { text-decoration: underline; }
.check-group-all:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.check-options { display: grid; gap: 6px; }
.check-option { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: border-color .12s, background .12s; }
.check-option:hover { background: var(--muted); }
.check-option .checkbox { margin-top: 2px; }
.check-option:has(.checkbox:checked) { border-color: color-mix(in oklab, var(--primary) 55%, var(--border)); background: color-mix(in oklab, var(--primary) 7%, transparent); }
.check-option:has(.checkbox:focus-visible) { outline: 2px solid var(--ring); outline-offset: 1px; }
.check-option-text { display: grid; gap: 2px; min-width: 0; }
.check-option-label { font-size: 14px; font-weight: 500; line-height: 1.35; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.check-option-desc { font-size: 12.5px; line-height: 1.4; color: var(--muted-foreground); }
/* Short options without groups, such as file types: a grid of small chips. */
.check-panel-compact .check-options { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.check-panel-compact .check-option { padding: 7px 10px; align-items: center; }
.check-panel-compact .check-option .checkbox { margin-top: 0; }
.check-panel-compact .check-option-label { font-size: 13px; }
.check-list { display: grid; gap: 8px; max-height: 200px; overflow: auto; padding: 2px; }
.switch { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { width: 36px; height: 20px; flex-shrink: 0; border-radius: 999px; background: var(--input); position: relative; transition: background .15s; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--ring); outline-offset: 2px; }
.media-field { display: flex; align-items: center; gap: 8px; }
.media-preview { width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 6px; object-fit: cover; background: var(--muted); }

/* Card */
.card { background: var(--card); color: var(--card-foreground); border: 1px solid var(--border); border-radius: var(--radius); }
.card-header { padding: 16px 20px 0; }
.card-title { font-size: 15px; font-weight: 600; }
.card-content { padding: 16px 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* Badge */
.badge { display: inline-flex; align-items: center; padding: 1px 8px; border: 1px solid var(--border); border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge-solid { background: var(--primary); color: var(--primary-foreground); border-color: transparent; }
.badge-muted { background: var(--secondary); color: var(--secondary-foreground); border-color: transparent; }
.badge-success { color: var(--success); border-color: color-mix(in oklab, var(--success) 40%, transparent); }
.badge-warning { color: var(--warning); border-color: color-mix(in oklab, var(--warning) 40%, transparent); }
.badge-danger { color: var(--destructive); border-color: color-mix(in oklab, var(--destructive) 40%, transparent); }

/* Alert */
.alert { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); }
.alert-danger { color: var(--destructive); border-color: color-mix(in oklab, var(--destructive) 40%, transparent); }
.alert-warning { color: var(--warning); border-color: color-mix(in oklab, var(--warning) 40%, transparent); }

/* Sheet: the right-side panel used instead of modal dialogs */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / .5); opacity: 0; pointer-events: none; transition: opacity .2s; }
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 51; width: min(480px, 100vw);
  display: flex; flex-direction: column; background: var(--background); border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgb(0 0 0 / .12); transform: translateX(100%); visibility: hidden; transition: transform .22s ease, visibility .22s;
}
.sheet.open { transform: none; visibility: visible; }
.sheet.sheet-wide { width: min(760px, 100vw); }
.sheet-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.sheet-form { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.sheet-header { padding: 16px 48px 12px 20px; }
.sheet-title { font-size: 16px; font-weight: 600; }
.sheet-content { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 8px 20px 20px; display: grid; gap: 16px; align-content: start; }
.sheet-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.sheet-close { position: absolute; top: 12px; right: 12px; z-index: 1; }
.sheet-loading { padding: 40px 20px; text-align: center; color: var(--muted-foreground); }

@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after { transition: none !important; animation: none !important; }
}

/* Modal: only for confirming an action. Forms use the sheet. */
.modal-backdrop { position: fixed; inset: 0; z-index: 52; background: rgb(0 0 0 / .5); opacity: 0; pointer-events: none; transition: opacity .15s; }
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal {
  position: fixed; top: 50%; left: 50%; z-index: 53; width: min(420px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto;
  display: grid; gap: 8px; padding: 20px; background: var(--background); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 16px 48px rgb(0 0 0 / .2);
  opacity: 0; visibility: hidden; transform: translate(-50%, -48%); transition: opacity .15s, transform .15s, visibility .15s;
}
.modal.open { opacity: 1; visibility: visible; transform: translate(-50%, -50%); }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* Toast */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: grid; gap: 8px; width: min(360px, calc(100vw - 32px)); }
.toast { padding: 12px 14px; background: var(--popover); color: var(--foreground); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgb(0 0 0 / .12); }
.toast-error { color: var(--destructive); }


/* Color setting: swatch picker, hex code and a reset button. */
.color-field { display: flex; align-items: center; gap: 8px; }
.color-field input[type="color"] { flex-shrink: 0; width: 40px; height: 36px; padding: 2px; border: 1px solid var(--input); border-radius: calc(var(--radius) - 2px); background: transparent; cursor: pointer; }
.color-field input[type="color"][data-empty] { opacity: .45; }
.color-field .input { max-width: 140px; text-transform: lowercase; }
