/* denovo-kit / components.css
   Atomic components — device-agnostic. Same shape on desktop + mobile.
   Extracted verbatim (then lightly adapted) from spheric's style.css. */

/* ── Universal box ──
   Base surface for cards, panels, rows — everything with bg-card + border. */
.box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.box--dashed  { border-style: dashed; }
.box--interactive {
    transition: border-color 0.15s, background 0.15s;
    cursor: pointer;
}
.box--interactive:hover {
    border-color: var(--accent-text);
    background: var(--bg-raised);
}

/* ── Universal card ── Higher-level container with padding */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-lg);
}
.card + .card { margin-top: var(--space-md); }
.card-title {
    font-family: var(--font-serif);
    font-size: 17px;
    font-weight: 500;
    color: var(--ink);
    margin-bottom: var(--space-xs);
}
.card-meta {
    font-size: 12px;
    color: var(--ink-faint);
    margin-bottom: var(--space-sm);
}
.card-body {
    font-size: 14px;
    color: var(--ink-soft);
    line-height: 1.6;
}

/* ── Pinned bar ──
   Bottom action bars, compose bars, selection trays. */
.pinned-bar {
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    padding: 10px 16px;
    background: var(--bg-raised);
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

/* ── Buttons ── */
.btn {
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background 0.15s, opacity 0.15s;
    font-family: var(--font-sans);
    letter-spacing: 0.2px;
    display: inline-block;
    text-align: center;
}
.btn-primary {
    background: var(--accent);
    /* Hard-code white rather than var(--ink). --ink flips to a dark ink
       in light mode, which renders ~#2e2a28 on the dark-green --accent
       — unreadable contrast (~2.3:1, fails WCAG). The accent hue is
       the same in both themes so the foreground should be too. */
    color: #fff;
}
.btn-primary:hover { background: var(--accent-light); color: #fff; }
.btn-secondary {
    background: var(--bg-card);
    color: var(--ink-soft);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-raised); color: var(--ink); }
.btn:disabled, .btn[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Inputs ── */
input, textarea, select {
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--ink);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}
input:focus, textarea:focus, select:focus {
    border-color: var(--accent-text);
    background: var(--bg-raised);
}
input::placeholder, textarea::placeholder { color: var(--ink-faint); }

.search-input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-input);
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 14px;
    outline: none;
}
.search-input:focus {
    border-color: var(--accent-text);
    background: var(--bg-raised);
}

/* ── Tab bar (desktop) ── */
.tab-row {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-lg);
}
.tab-btn {
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-faint);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-family: var(--font-sans);
    letter-spacing: 0.2px;
    transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--ink-soft); }
.tab-btn.active {
    color: var(--accent-text);
    border-bottom-color: var(--accent-text);
}

/* ── Chips ── */
.chip {
    background: var(--bg-card);
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    transition: all 0.15s;
}
.chip:hover {
    border-color: var(--accent-text);
    color: var(--ink);
}
.chip.active {
    background: var(--accent-muted);
    border-color: var(--accent);
    color: var(--accent-text);
}

/* ── Badges / pills ── */
.badge {
    background: var(--border);
    color: var(--ink-soft);
    font-size: 10px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: inline-block;
}
.badge--accent { background: var(--accent-muted); color: var(--accent-text); }
.badge--amber  { background: var(--amber-muted);  color: var(--amber-text); }
.badge--red    { background: var(--red-muted);    color: var(--red); }

.pill {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    background: var(--bg-raised);
    color: var(--ink-soft);
    border: 1px solid var(--border);
    letter-spacing: 0.3px;
}
.pill--accent { background: var(--accent-muted); color: var(--accent-text); border-color: var(--accent); }

/* ── Empty state ── */
.empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--ink-faint);
    font-size: 14px;
    font-style: italic;
}

/* ── Page description (subtitle under h1) ── */
.page-desc {
    font-size: 14px;
    color: var(--ink-faint);
    margin-bottom: 24px;
}

/* ── Page actions ──
   Canonical "row of buttons at the end of a page" wrapper. Always includes
   its own top + bottom margin so the primary button never sits flush against
   the page footer (desktop) or the bottom nav (mobile). Use this instead of
   inline margin-top/bottom on the button's wrapper div.

   The bottom margin is --space-2xl (32px) so even when the viewport is tall
   enough to compress the page, there's still an obvious visual gap below
   the button. Combined with <main>'s padding-bottom, the button sits at
   least 64px above any border/footer/nav. */
.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-top: var(--space-xl);
    margin-bottom: var(--space-2xl);
}

/* ── Auth pages (login / signup / invite) ──
   Minimal centered card layout used by kit/templates/denovo/auth/*.html.
   Pair with <main> filling the viewport for a clean landing page feel. */
.login-wrap {
    width: 100%;
    max-width: 440px;
    margin: 64px auto;
    padding: 0 var(--space-lg);
}
.login-form {
    padding: 36px 36px 28px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 360px;
    justify-content: center;
}
.login-form h1 {
    text-align: center;
    font-size: 24px;
    margin-bottom: 8px;
}
.login-form .btn { margin-top: 8px; }
.login-form label {
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-faint);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.login-form input {
    padding: 12px 14px;
    background: var(--bg-input);
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 14px;
    outline: none;
}
.login-form input:focus {
    border-color: var(--accent-text);
    background: var(--bg-raised);
}
.login-error {
    color: var(--red);
    font-size: 13px;
    text-align: center;
    padding: 8px;
    background: var(--red-muted);
    border-radius: var(--radius);
}

/* ── Rail components ──
   Atomic pieces used inside .page-rail (see layout-desktop.css for the
   rail layout itself). Device-agnostic; rail wraps below content or
   hides on mobile depending on the app's CSS. */
.rail-presets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}
.rail-presets .chip {
    text-align: center;
    padding: 5px 8px;
    font-size: 12px;
    width: 100%;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rail-meta {
    font-size: 12px;
    color: var(--ink-faint);
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    font-variant-numeric: tabular-nums;
}
.rail-meta .tray-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
}
.rail-meta .tray-warning {
    font-size: 11px;
    font-weight: 600;
    margin-top: 4px;
}
.rail-selected-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding-right: 4px;
}
.rail-selected-empty {
    font-size: 12px;
    color: var(--ink-faint);
    font-style: italic;
    padding: 4px 0;
}
.rail-selected-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 11px;
    line-height: 1.2;
    min-width: 0;
}
.rail-selected-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink-soft);
    min-width: 0;
}
.rail-selected-remove {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--ink-faint);
    cursor: pointer;
    padding: 0 2px;
    font-size: 14px;
    line-height: 1;
}
.rail-selected-remove:hover { color: var(--red); }
.rail-action {
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    padding-top: 12px;
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.rail-action .btn { width: 100%; }

/* ── Flash messages ── (Flask get_flashed_messages) */
.flash {
    padding: 10px 14px;
    margin-bottom: 6px;
    border-radius: var(--radius);
    font-size: 14px;
}
.flash--ok    { background: var(--accent-muted); color: var(--accent-text); }
.flash--error { background: var(--red-muted);    color: var(--red); }

/* ── Theme toggle ──
   Drop-in <button class="theme-toggle"> used by the theme_toggle partial.
   Sun icon shows when dark is active (click → light), moon when light. */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: transparent;
    border: none;
    color: var(--ink);
    font: inherit;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    border-radius: var(--radius);
}
.theme-toggle:hover,
.theme-toggle:focus { outline: none; background: var(--bg-raised); }
.theme-icon { flex-shrink: 0; }
.theme-icon--sun  { color: #E5A93C; }
.theme-icon--moon { color: var(--ink-soft); }
:root[data-theme="dark"]  .theme-icon--moon { display: none; }
:root[data-theme="light"] .theme-icon--sun  { display: none; }
:root:not([data-theme="light"]) .theme-icon--moon { display: none; }

/* ── Modal framework ──
   Overlay + centered content. Use with kit/js/modal.js:
     window.denovoModal.open('my-modal-id');
     window.denovoModal.close('my-modal-id');
   Close on Escape and overlay click are handled by the helper. */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--space-lg);
}
.modal-overlay.is-open { display: flex; }
body.modal-open main { overflow: hidden; }
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90vw;
    max-width: 1100px;
    height: 85vh;
    max-height: 900px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.modal-header {
    flex-shrink: 0;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
}
.modal-header h2 {
    font-family: var(--font-serif);
    font-size: 18px;
    font-weight: 500;
    margin: 0;
}
.modal-close {
    background: transparent;
    border: none;
    color: var(--ink-soft);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius);
}
.modal-close:hover { background: var(--bg-raised); color: var(--ink); }
.modal-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.modal-footer {
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    padding: 12px var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-md);
    background: var(--bg-raised);
}

/* ── Admin row (Active users / Pending invites) ──
   Single-row card on desktop: name+email column grows, then a Pending/Active
   pill, a date, and one-or-two action buttons. Mobile override lives in
   layout-mobile.css and reflows into name+email → pill+date → buttons rows. */
.admin-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 12px 16px;
    margin-bottom: 6px;
}
.admin-row__main { flex: 1; min-width: 0; }
.admin-row__name { font-weight: 600; color: var(--ink); }
.admin-row__email { color: var(--ink-soft); font-size: 13px; }
.admin-row__meta { color: var(--ink-faint); font-size: 12px; }
.admin-row__you  { color: var(--ink-faint); font-size: 12px; padding: 6px 12px; }
.admin-row__form { margin: 0; }
/* Wraps 1-2 action forms (Resend / Revoke / Remove). display:contents makes
   the forms behave as direct flex children of .admin-row on desktop (same
   layout as before the wrapper existed). Mobile override in layout-mobile.css
   converts __actions into its own flex row so two buttons can share 50/50
   cleanly instead of one getting orphaned on a trailing line. */
.admin-row__actions { display: contents; }
/* Compact variant of .btn for row-action buttons. Desktop rows are dense;
   mobile override in layout-mobile.css restores tap-friendly sizing.
   Uses .btn.admin-row__btn (specificity 0,2,0) so it wins against any
   downstream .btn / .btn-secondary duplicates in consumer stylesheets. */
.btn.admin-row__btn {
    padding: 6px 12px;
    font-size: 13px;
    min-height: 0;
}

/* ── Tooltip ──
   Singleton bubble managed by kit/js/tooltip.js. Any element with
   [data-tooltip="..."] gets auto-wired. One .dk-tooltip lives at
   document.body and is reused for every trigger. */
.dk-tooltip {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10000;
    max-width: 260px;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-raised);
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-family: var(--font-sans);
    font-size: 13px;
    line-height: 1.5;
    pointer-events: none;
    opacity: 0;
    transform: translateY(2px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    visibility: hidden;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.dk-tooltip.is-visible {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
}
.dk-tooltip__text {
    display: block;
}
.dk-tooltip__arrow {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    transform: rotate(45deg);
    pointer-events: none;
}
/* Arrow below the bubble (bubble above trigger) — hide top-left borders */
.dk-tooltip--above .dk-tooltip__arrow {
    bottom: -6px;
    margin-left: -5px;
    border-top-color: transparent;
    border-left-color: transparent;
}
/* Arrow above the bubble (bubble below trigger) — hide bottom-right borders */
.dk-tooltip--below .dk-tooltip__arrow {
    top: -6px;
    margin-left: -5px;
    border-bottom-color: transparent;
    border-right-color: transparent;
}
/* Tap-to-dismiss friendliness and suppress iOS long-press artifacts. */
[data-tooltip] {
    -webkit-touch-callout: none;
}
@media (prefers-reduced-motion: reduce) {
    .dk-tooltip {
        transition: none;
        transform: none;
    }
}
.btn.admin-row__btn--danger { color: var(--red); }
