/* ==========================================================================
   VaultX - Backup view (assets/backup.js) and the storage warning (Backup and Security).
   Uses the design tokens from app.css only, so dark, light and system themes follow automatically.
   ========================================================================== */

.bk-view { display: flex; flex-direction: column; gap: 16px; }
/* Focused or scrolled-to elements stay clear of the sticky top bar. */
.bk-view *, .bk-warning-slot * { scroll-margin-top: calc(var(--topbar-h) + 16px); scroll-margin-bottom: 16px; }
.bk-warning-slot:empty { display: none; }
.bk-warning-slot.is-security:not(:empty) { margin-bottom: 16px; }
.bk-card { min-width: 0; }
.bk-card .panel-header h2:focus { outline: none; }
.bk-card .panel-header h2:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: 4px; }
.bk-head-action { margin-left: auto; flex-shrink: 0; }

/* Collapsed sidebar: the percent is hidden there, so a dot on the Backup icon shows that a backup is running
   (the percent is in the item's tooltip, see updateBackupNavBadge). */
.sidebar.collapsed .nav-item.is-running { position: relative; }
.sidebar.collapsed .nav-item.is-running::after { content: ""; position: absolute; top: 5px; right: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--sidebar-bg); }

/* Create a backup ------------------------------------------------------------ */
.bk-create { container: bk-create / inline-size; }
.bk-form-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.bk-group { min-width: 0; margin: 0; padding: 0; border: 0; }
.bk-group > legend { padding: 0; margin: 0 0 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-soft); }
@container bk-create (min-width: 620px) {
  .bk-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; }
  .bk-group-dest { grid-column: 1 / -1; }
}
@container bk-create (min-width: 980px) {
  .bk-form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bk-group-dest { grid-column: auto; }
}

/* Checkbox rows: the whole row is the label. */
.bk-check { display: flex; align-items: flex-start; gap: 10px; margin: 0 -10px; padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; transition: background-color .12s; }
.bk-check:hover { background: var(--hover); }
.bk-check > input { flex-shrink: 0; width: 16px; height: 16px; margin: 2px 0 0; cursor: inherit; }
.bk-check-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.bk-check-text strong { font-size: 13px; font-weight: 550; color: var(--text); overflow-wrap: anywhere; }
.bk-check-text small { font-size: 12px; line-height: 1.45; color: var(--muted); overflow-wrap: anywhere; }
.bk-check-text small.is-warning { color: var(--amber); font-weight: 550; }
.bk-check:has(> input:disabled) { cursor: default; }
.bk-check:has(> input:disabled):hover { background: transparent; }
.bk-check:has(> input:disabled) .bk-check-text strong { color: var(--muted); }
.bk-check.is-locked .bk-check-text strong { color: var(--text); }
.bk-check.is-locked > input:disabled { opacity: .75; }

.bk-password { margin-top: 10px; padding: 14px 14px 6px; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); background: var(--surface2); }
.bk-password .field { margin-bottom: 12px; }
.bk-password .bk-check { margin: 0 -6px; padding: 6px; }
.bk-secret { position: relative; display: flex; min-width: 0; }
.bk-secret > input { flex: 1; width: 100%; padding-right: 42px; }
.bk-reveal { position: absolute; top: 2px; right: 2px; }
.bk-reveal[aria-pressed="true"] { color: var(--accent); }
.bk-note { display: flex; align-items: flex-start; gap: 6px; margin: 6px 0 8px; font-size: 12px; line-height: 1.45; color: var(--muted); }
.bk-note .icon { width: 14px; height: 14px; margin-top: 2px; flex-shrink: 0; }

/* "Send to" choices. */
.bk-dest { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin-top: 4px; }
@container bk-create (min-width: 620px) { .bk-dest { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@container bk-create (min-width: 980px) { .bk-dest { grid-template-columns: minmax(0, 1fr); } }
.bk-dest-option { display: flex; align-items: flex-start; gap: 10px; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; transition: border-color .12s, background-color .12s; }
.bk-dest-option:hover { border-color: var(--line-strong); }
.bk-dest-option:has(> input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.bk-dest-option:has(> input:disabled) { cursor: not-allowed; border-style: dashed; background: var(--surface2); }
.bk-dest-option:has(> input:disabled) .bk-check-text strong, .bk-dest-option:has(> input:disabled) .bk-dest-icon { color: var(--muted); }
.bk-dest-option > input { flex-shrink: 0; width: 16px; height: 16px; margin: 2px 0 0; cursor: inherit; }
.bk-dest-icon { display: inline-flex; color: var(--accent); }
.bk-dest-icon .icon { width: 18px; height: 18px; }
.bk-once { margin: 12px 0 0; }

.bk-create-form > .form-error { margin: 16px 0 0; }
.bk-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; }
.panel .bk-actions .button[type=submit] { margin-top: 0; } /* app.css: .panel form .button[type=submit] { margin-top: 4px } */
.bk-submit { justify-content: flex-end; padding-top: 16px; border-top: 1px solid var(--line-soft); }

/* Progress */
.bk-run { display: flex; flex-direction: column; gap: 10px; }
.bk-run-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.bk-run-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.bk-run-head h3:focus { outline: none; }
.bk-run-head h3:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: 4px; }
.bk-run-percent { font-size: 20px; font-weight: 650; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.bk-progress { height: 10px; overflow: hidden; border-radius: 999px; background: var(--active); }
.bk-progress-fill { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent-strong), var(--accent)); transition: width .35s var(--ease); }
.bk-create[data-mode="resume"] .bk-progress-fill { background: var(--line-strong); }
.bk-run-message { min-height: 20px; margin: 0; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.bk-run-text { margin: 2px 0 0; font-size: 13px; color: var(--text); }
.bk-run .field { max-width: 420px; margin: 4px 0 0; }
.bk-run .form-error { margin: 4px 0 0; }
.bk-run .bk-actions { margin-top: 6px; }
.bk-run .tool-footnote { margin-top: 2px; overflow-wrap: anywhere; }

/* Result */
.bk-result-head { display: flex; align-items: flex-start; gap: 12px; }
.bk-result-head > div { min-width: 0; }
.bk-result-head h3 { margin: 0 0 2px; font-size: 15px; font-weight: 600; }
.bk-result-head h3:focus { outline: none; }
.bk-result-head h3:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: 4px; }
.bk-result-head p { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
.bk-result-icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%; background: var(--success-soft); color: var(--green); }
.bk-result-icon .icon { width: 18px; height: 18px; }
.bk-result.is-failed .bk-result-icon { background: var(--danger-soft); color: var(--red); }
.bk-result-note { margin: 12px 0 0; font-size: 13px; color: var(--text); }
.bk-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 8px; margin: 16px 0 0; }
.bk-facts > div { min-width: 0; padding: 8px 12px; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); background: var(--surface2); }
.bk-facts > div.is-wide { grid-column: 1 / -1; }
.bk-facts dt { font-size: 12px; color: var(--muted); }
.bk-facts dd { margin: 2px 0 0; font-size: 13px; font-weight: 550; overflow-wrap: anywhere; }
.bk-facts-compact { margin: 0 0 4px; }

/* FTP server and Google Drive ------------------------------------------------ */
.bk-destinations { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr)); gap: 16px; align-items: start; }
.bk-status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0 0 16px; padding: 8px 12px; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); background: var(--surface2); font-size: 13px; color: var(--muted); }
.bk-status.is-on { color: var(--text); }
.bk-status > .icon { width: 16px; height: 16px; color: var(--amber); }
.bk-status-dot { flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; background: var(--text-soft); }
.bk-status.is-on .bk-status-dot { background: var(--green); box-shadow: 0 0 0 3px var(--success-soft); }
.bk-status-text { min-width: 0; overflow-wrap: anywhere; }
.bk-status-text strong { font-weight: 600; }
.bk-status-note { margin-left: auto; font-size: 12px; color: var(--muted); }
.bk-text { margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.bk-form .field { margin-bottom: 14px; }
.bk-form > .bk-check { margin-top: -4px; margin-bottom: 10px; }
.bk-field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.bk-field-row.is-port { grid-template-columns: minmax(0, 1fr) minmax(88px, 120px); }
.bk-result-line { display: flex; align-items: flex-start; gap: 8px; margin: 12px 0 0; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.bk-result-line:empty { margin: 0; }
.bk-result-line .icon { flex-shrink: 0; width: 16px; height: 16px; margin-top: 1px; }
.bk-result-line.is-ok { color: var(--green); }
.bk-result-line.is-error { color: var(--red); }
.bk-result-line > span { min-width: 0; }

/* Disclosures ("Advanced", "How to fix", "Setup steps"). */
.bk-details { margin: 0; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); background: var(--surface2); }
.bk-details > summary { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: var(--radius-sm); cursor: pointer; list-style: none; font-size: 13px; font-weight: 550; color: var(--text); user-select: none; }
.bk-details > summary::-webkit-details-marker { display: none; }
.bk-details > summary::marker { content: ""; }
.bk-details > summary:hover { background: var(--hover); }
.bk-details > summary .icon { width: 16px; height: 16px; color: var(--muted); transition: transform .15s var(--ease); }
.bk-details[open] > summary .icon { transform: rotate(90deg); }
.bk-details-body { padding: 4px 12px 12px; }
.bk-details-body > .bk-check { margin: 0 -6px; padding: 6px; }
.bk-details-body > .field { margin: 6px 0 4px; }
.bk-form + .bk-details, .bk-details + .bk-form { margin-top: 14px; }

.bk-steps { margin: 0 0 16px; padding-left: 22px; font-size: 13px; line-height: 1.55; color: var(--text); }
.bk-steps li { margin: 0 0 8px; padding-left: 2px; overflow-wrap: anywhere; }
.bk-steps li:last-child { margin-bottom: 0; }
.bk-steps li::marker { color: var(--muted); font-weight: 600; }
.bk-details-body > .bk-steps { margin: 4px 0 0; }
.bk-copy { display: flex; gap: 8px; margin-top: 8px; min-width: 0; }
.bk-copy input { flex: 1; min-width: 0; height: 32px; font-family: var(--font-mono); font-size: 12px; }

/* Recent backups ------------------------------------------------------------- */
.bk-history { margin: 0; padding: 0; list-style: none; }
.bk-history-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.bk-history-row:first-child { padding-top: 2px; border-top: 0; }
.bk-history-row:last-child { padding-bottom: 0; }
.bk-history-icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 32px; height: 32px; border-radius: 8px; background: var(--surface2); color: var(--muted); }
.bk-history-icon .icon { width: 16px; height: 16px; }
.bk-history-row.is-encrypted .bk-history-icon { background: var(--warning-soft); color: var(--amber); }
.bk-history-main { flex: 1; min-width: 0; }
.bk-history-main strong { display: block; font-size: 13px; font-weight: 550; overflow-wrap: anywhere; }
.bk-history-main small { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.bk-history-main small.bk-history-error { color: var(--red); }
.bk-badge { display: inline-flex; align-items: center; flex-shrink: 0; gap: 6px; padding: 2px 9px; border-radius: 999px; background: var(--surface2); color: var(--muted); font-size: 12px; font-weight: 550; white-space: nowrap; }
.bk-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.bk-badge.is-done { background: var(--success-soft); color: var(--green-text); }
.bk-badge.is-failed { background: var(--danger-soft); color: var(--red); }
.bk-empty { margin: 0; padding: 12px 0 4px; font-size: 13px; color: var(--muted); }

/* Storage warning ------------------------------------------------------------- */
.bk-alert { display: flex; align-items: flex-start; gap: 14px; padding: 16px 18px; border: 1px solid var(--line); border-color: color-mix(in srgb, var(--red) 38%, var(--line)); border-left: 4px solid var(--red); border-radius: var(--radius); background: var(--danger-soft); }
.bk-alert-icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%; background: var(--danger-soft); color: var(--red); }
.bk-alert-icon .icon { width: 18px; height: 18px; }
.bk-alert-body { flex: 1; min-width: 0; }
.bk-alert h2 { margin: 0 0 4px; font-size: 15px; font-weight: 650; color: var(--text); }
.bk-alert p { max-width: 760px; margin: 0; font-size: 13px; color: var(--text); }
.bk-alert .bk-fix { max-width: 760px; margin-top: 12px; background: var(--surface); }
.bk-alert-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; }
.bk-alert-status { font-size: 12px; color: var(--muted); }
.bk-private-line { display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 5px 12px 5px 10px; border-radius: 999px; background: var(--success-soft); color: var(--green-text); font-size: 12px; font-weight: 550; }
.bk-private-line .icon { width: 15px; height: 15px; }
.bk-private-line:focus { outline: none; }
.bk-private-line:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* Phones and narrow windows --------------------------------------------------- */
@media (max-width: 800px) {
  .bk-destinations { grid-template-columns: minmax(0, 1fr); }
  .bk-actions .button { min-height: 40px; }
}
@media (max-width: 560px) {
  .bk-alert { flex-direction: column; gap: 10px; padding: 14px; }
  .bk-alert-icon { width: 32px; height: 32px; }
  .bk-field-row { grid-template-columns: minmax(0, 1fr); }
  .bk-field-row.is-port { grid-template-columns: minmax(0, 1fr) 96px; }
  .bk-actions .button { flex: 1 1 auto; }
  .bk-status-note { width: 100%; margin-left: 18px; }
  .bk-run-percent { font-size: 18px; }
  .bk-card .panel-header:has(.bk-head-action) { flex-wrap: wrap; }
  .bk-history-row { flex-wrap: wrap; }
  .bk-history-row .bk-badge { margin-left: 44px; }
  .bk-copy { flex-wrap: wrap; }
  .bk-copy input { flex: 1 1 100%; }
  .bk-copy .button { flex: 0 0 auto; }
}
