/* Luma PDF — base components */

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--bg-elevated);
  --btn-fg: var(--text);
  --btn-border: var(--surface-border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px;
  font-size: var(--fs-sm); font-weight: 550; letter-spacing: .005em;
  border-radius: var(--r-md); border: 1px solid var(--btn-border);
  background: var(--btn-bg); color: var(--btn-fg);
  white-space: nowrap; user-select: none;
  transition: background var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out),
              color var(--dur-2) var(--ease-out), transform var(--dur-1) var(--ease-out), box-shadow var(--dur-2) var(--ease-out);
}
.btn:hover { background: var(--bg-hover); }
.btn:active { transform: translateY(.5px) scale(.995); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn .icon { width: 16px; height: 16px; flex: none; }
.btn-primary { --btn-bg: var(--accent); --btn-fg: #fff; --btn-border: transparent; box-shadow: 0 1px 2px rgba(16,16,24,.12); }
.btn-primary:hover { --btn-bg: var(--accent-hover); }
:root[data-theme="dark"] .btn-primary { --btn-fg: #14121f; }
.btn-ghost { --btn-bg: transparent; --btn-border: transparent; color: var(--text-secondary); }
.btn-ghost:hover { --btn-bg: var(--bg-hover); color: var(--text); }
.btn-outline { --btn-bg: transparent; }
.btn-danger { --btn-bg: transparent; --btn-fg: var(--danger); --btn-border: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-danger:hover { --btn-bg: var(--danger-soft); }
.btn-sm { height: 31px; padding: 0 11px; font-size: var(--fs-xs); border-radius: var(--r-sm); }
.btn-lg { height: 46px; padding: 0 22px; font-size: var(--fs-md); border-radius: var(--r-lg); }
.btn-icon { width: 36px; padding: 0; flex: none; }
.btn-icon.btn-sm { width: 30px; }
.btn-block { width: 100%; }
.btn .spinner { width: 14px; height: 14px; }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: var(--fs-xs); font-weight: 560; color: var(--text-secondary); letter-spacing: .01em; }
.hint { font-size: var(--fs-xs); color: var(--text-muted); line-height: var(--lh-snug); }
.input, .select, .textarea {
  height: 38px; width: 100%; padding: 0 12px;
  font-size: var(--fs-sm); color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--surface-border-strong);
  border-radius: var(--r-md);
  transition: border-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), background var(--dur-2);
  appearance: none;
}
.textarea { height: auto; min-height: 84px; padding: 10px 12px; line-height: var(--lh-snug); resize: vertical; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-300); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }
.select {
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px;
}
.input-sm { height: 31px; font-size: var(--fs-xs); padding: 0 9px; }
.input-group { display: flex; gap: 8px; align-items: center; }
.checkbox, .radio { display: inline-flex; align-items: center; gap: 9px; font-size: var(--fs-sm); color: var(--text-secondary); cursor: pointer; user-select: none; min-height: 28px; }
.checkbox input, .radio input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; flex: none; cursor: pointer; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--fs-sm); color: var(--text-secondary); min-height: 30px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track { width: 36px; height: 21px; border-radius: var(--r-pill); background: var(--ink-300); position: relative; transition: background var(--dur-2) var(--ease-out); flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2.5px; left: 2.5px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--dur-2) var(--ease-out); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(15px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--focus-ring); }

/* ---------- Surfaces ---------- */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--surface-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}
.card-pad { padding: var(--sp-5); }
.panel { background: var(--bg-elevated); border: 1px solid var(--surface-border); border-radius: var(--r-lg); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--surface-border); }
.panel-body { padding: var(--sp-5); }
.panel-title { font-size: var(--fs-md); font-weight: 600; }
.divider { height: 1px; background: var(--surface-border); border: 0; margin: 0; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 21px; padding: 0 8px;
  font-size: var(--fs-2xs); font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  border-radius: var(--r-xs); background: var(--bg-active); color: var(--text-secondary);
}
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warn { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px;
  font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary);
  background: var(--bg-sunken); border: 1px solid var(--surface-border-strong); border-bottom-width: 2px; border-radius: var(--r-xs);
}
.muted { color: var(--text-muted); }
.small { font-size: var(--fs-xs); }
.mono { font-family: var(--font-mono); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.col { display: flex; flex-direction: column; gap: var(--sp-3); }
.grow { flex: 1 1 auto; min-width: 0; }
.wrap { flex-wrap: wrap; }
.stack-4 { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack-5 { display: flex; flex-direction: column; gap: var(--sp-5); }
.stack-6 { display: flex; flex-direction: column; gap: var(--sp-6); }

/* ---------- Spinner & progress ---------- */
.spinner {
  width: 18px; height: 18px; flex: none; border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 22%, transparent);
  border-top-color: currentColor;
  animation: luma-spin .7s linear infinite;
}
@keyframes luma-spin { to { transform: rotate(360deg); } }
.progress { height: 5px; border-radius: var(--r-pill); background: var(--bg-active); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width var(--dur-3) var(--ease-out); }
.progress-indeterminate > i { width: 38% !important; animation: luma-indeterminate 1.1s var(--ease-in-out) infinite; }
@keyframes luma-indeterminate { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }

/* ---------- Toasts ---------- */
.toast-host { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: var(--z-toast); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(94vw, 460px); }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px;
  width: 100%; padding: 11px 14px; font-size: var(--fs-sm);
  background: var(--ink-900); color: #f4f4f7; border-radius: var(--r-md);
  box-shadow: var(--shadow-lg); animation: luma-toast-in var(--dur-3) var(--ease-out);
  border: 1px solid rgba(255,255,255,.08);
}
.toast.leaving { animation: luma-toast-out var(--dur-2) var(--ease-in-out) forwards; }
.toast .toast-body { flex: 1; min-width: 0; }
.toast .toast-title { font-weight: 600; }
.toast .toast-msg { color: #c8c8d2; font-size: var(--fs-xs); margin-top: 2px; line-height: 1.45; word-break: break-word; }
.toast .toast-close { color: #9a9aa8; padding: 2px; border-radius: var(--r-xs); }
.toast .toast-close:hover { color: #fff; background: rgba(255,255,255,.1); }
.toast .toast-icon { margin-top: 1px; flex: none; }
.toast-success .toast-icon { color: #63d29b; }
.toast-error .toast-icon { color: #ff8f85; }
.toast-warn .toast-icon { color: var(--amber-400); }
@keyframes luma-toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes luma-toast-out { to { opacity: 0; transform: translateY(6px) scale(.98); } }

/* ---------- Dialog ---------- */
dialog.modal {
  padding: 0; border: 1px solid var(--surface-border); border-radius: var(--r-xl);
  background: var(--bg-elevated); color: var(--text); box-shadow: var(--shadow-pop);
  width: min(92vw, 520px); max-height: min(88vh, 780px);
  overflow: visible;
}
dialog.modal::backdrop { background: rgba(12, 12, 20, .5); backdrop-filter: blur(3px); }
dialog.modal[open] { animation: luma-dialog-in var(--dur-3) var(--ease-out); }
dialog.modal[open]::backdrop { animation: luma-fade-in var(--dur-3) var(--ease-out); }
@keyframes luma-dialog-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes luma-fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-5) var(--sp-5) var(--sp-3); }
.modal-title { font-size: var(--fs-lg); font-weight: 620; }
.modal-sub { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 3px; }
.modal-body { padding: 0 var(--sp-5) var(--sp-4); overflow: auto; max-height: 62vh; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--surface-border); background: var(--bg-sunken); border-radius: 0 0 var(--r-xl) var(--r-xl); flex-wrap: wrap; }

/* ---------- Bottom sheet ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-sheet);
  background: var(--bg-elevated); border-top: 1px solid var(--surface-border);
  border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: var(--shadow-pop);
  padding: var(--sp-3) var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom));
  transform: translateY(102%); transition: transform var(--dur-3) var(--ease-out);
  max-height: 72vh; overflow: auto;
}
.sheet[data-open="true"] { transform: none; }
.sheet-grip { width: 36px; height: 4px; border-radius: var(--r-pill); background: var(--surface-border-strong); margin: 2px auto var(--sp-3); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-3); }
.sheet-title { font-weight: 600; font-size: var(--fs-md); }
.sheet-backdrop { position: fixed; inset: 0; z-index: calc(var(--z-sheet) - 1); background: rgba(10,10,16,.42); opacity: 0; pointer-events: none; transition: opacity var(--dur-3); }
.sheet-backdrop[data-open="true"] { opacity: 1; pointer-events: auto; }

/* ---------- Empty state ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: var(--sp-8) var(--sp-4); color: var(--text-muted); }
.empty .empty-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--r-lg); background: var(--bg-sunken); color: var(--text-muted); border: 1px solid var(--surface-border); }
.empty h3 { font-size: var(--fs-md); color: var(--text); font-weight: 600; }
.empty p { font-size: var(--fs-sm); max-width: 42ch; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--surface-border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; padding: 10px 12px; font-size: var(--fs-sm); font-weight: 550; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
  transition: color var(--dur-2), border-color var(--dur-2);
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--bg-sunken); border: 1px solid var(--surface-border); border-radius: var(--r-md); }
.segmented button { padding: 5px 11px; font-size: var(--fs-xs); font-weight: 550; color: var(--text-muted); border-radius: var(--r-sm); transition: background var(--dur-2), color var(--dur-2); }
.segmented button[aria-pressed="true"] { background: var(--bg-elevated); color: var(--text); box-shadow: var(--shadow-xs); }

/* ---------- Dropzone ---------- */
.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: var(--sp-7) var(--sp-5); text-align: center; cursor: pointer;
  border: 1.5px dashed var(--surface-border-strong); border-radius: var(--r-lg);
  background: var(--bg-elevated); color: var(--text-secondary);
  transition: border-color var(--dur-2), background var(--dur-2), transform var(--dur-2);
}
.dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.is-dragover { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.005); }
.dropzone .dz-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: var(--r-md); background: var(--accent-soft); color: var(--accent-text); }
.dropzone .dz-title { font-size: var(--fs-sm); font-weight: 600; color: var(--text); }
.dropzone .dz-sub { font-size: var(--fs-xs); color: var(--text-muted); }
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---------- File list ---------- */
.file-row { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border: 1px solid var(--surface-border); border-radius: var(--r-md); background: var(--bg-elevated); }
.file-row + .file-row { margin-top: 6px; }
.file-row .fr-icon { width: 30px; height: 30px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); flex: none; }
.file-row .fr-name { font-size: var(--fs-sm); font-weight: 550; }
.file-row .fr-meta { font-size: var(--fs-2xs); color: var(--text-muted); }
.file-row.dragging { opacity: .45; }
.file-row.drop-target { border-color: var(--accent); box-shadow: 0 0 0 2px var(--focus-ring); }

/* ---------- Icons ---------- */
.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; display: block; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }
