/* ==========================================================================
   Privatka UI v2 — design system (opt-in per page via <body class="ui-v2">)
   Calm, monochrome, Apple-like: typography and spacing carry the hierarchy,
   colour is reserved for meaning (status, project colour dot, focus, links).
   Every rule is scoped under body.ui-v2 so other pages are untouched.
   ========================================================================== */

body.ui-v2 {
    /* surfaces — airy: near-white page, white cards, very light fills */
    --v2-bg: #fbfbfd;
    --v2-surface: #ffffff;
    --v2-surface-2: #f7f8fa;
    --v2-fill: rgba(0, 20, 60, .035);
    --v2-fill-2: rgba(0, 20, 60, .06);
    /* accent — Apple blue; "tinted" = soft fill + accent text */
    --v2-accent: #007aff;
    --v2-accent-hover: #0066d6;
    --v2-accent-text: #0062cc;
    --v2-accent-soft: rgba(0, 122, 255, .10);
    --v2-accent-soft-2: rgba(0, 122, 255, .16);
    --v2-focus-border: rgba(0, 20, 60, .26);
    /* text */
    --v2-text: #1d1d1f;
    --v2-text-2: #6e6e73;
    --v2-text-3: #8e8e93;
    /* lines */
    --v2-line: rgba(0, 20, 60, .08);
    --v2-line-2: rgba(0, 20, 60, .13);
    /* roles (primary = the solid accent, used sparingly for the final action) */
    --v2-primary: var(--v2-accent);
    --v2-on-primary: #ffffff;
    --v2-link: #0062cc;
    --v2-focus: rgba(0, 122, 255, .35);
    --v2-danger: #d70015;
    --v2-danger-fill: rgba(215, 0, 21, .07);
    --v2-success: #248a3d;
    --v2-warning: #b25000;
    /* shape + motion */
    --v2-r-sm: 8px;
    --v2-r: 12px;
    --v2-r-lg: 18px;
    --v2-shadow-card: 0 1px 2px rgba(0, 20, 60, .05);
    --v2-shadow-pop: 0 12px 32px rgba(0, 20, 60, .12), 0 1px 3px rgba(0, 20, 60, .06);
    --v2-shadow-sheet: 0 24px 64px rgba(0, 20, 60, .16), 0 2px 6px rgba(0, 20, 60, .05);
    --v2-ease: cubic-bezier(.25, .1, .25, 1);
    --v2-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    --v2-font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", Roboto, sans-serif;

    /* map legacy tokens so the shared shell (sidebar, header) follows v2 */
    --bg-primary: var(--v2-bg);
    --bg-secondary: var(--v2-surface);
    --bg-card: var(--v2-surface);
    --bg-sidebar: var(--v2-surface-2);
    --bg-sidebar-hover: var(--v2-fill);
    --bg-sidebar-active: var(--v2-accent-soft);
    --text-primary: var(--v2-text);
    --text-secondary: var(--v2-text-2);
    --text-tertiary: var(--v2-text-3);
    --text-sidebar: var(--v2-text-2);
    --text-sidebar-hover: var(--v2-text);
    --text-sidebar-active: var(--v2-accent-text);
    --border-color: var(--v2-line);
    --border-light: var(--v2-line);
    --hover-bg: var(--v2-fill);
    --bg-hover: var(--v2-fill);
    /* --accent is used by legacy UI both as text and as a fill under white text,
       so it must stay dark enough for white text in both themes. */
    --accent: var(--v2-accent);
    --accent-color: var(--v2-accent);
    --active-border: var(--v2-accent);
    --accent-soft: var(--v2-accent-soft);

    font-family: var(--v2-font);
    background: var(--v2-bg);
    color: var(--v2-text);
    letter-spacing: -0.006em;
}

body.ui-v2.dark-theme {
    --v2-bg: #0b0b0d;
    --v2-surface: #1c1c1e;
    --v2-surface-2: #141416;
    --v2-fill: rgba(255, 255, 255, .06);
    --v2-fill-2: rgba(255, 255, 255, .10);
    --v2-accent: #0a84ff;
    --v2-accent-hover: #3b9bff;
    --v2-accent-text: #4da3ff;
    --v2-accent-soft: rgba(10, 132, 255, .16);
    --v2-accent-soft-2: rgba(10, 132, 255, .24);
    --v2-focus-border: rgba(255, 255, 255, .28);
    --v2-text: #f5f5f7;
    --v2-text-2: #a1a1a6;
    --v2-text-3: #6e6e73;
    --v2-line: rgba(255, 255, 255, .09);
    --v2-line-2: rgba(255, 255, 255, .16);
    --v2-primary: var(--v2-accent);
    --v2-on-primary: #ffffff;
    --v2-link: #4da3ff;
    --v2-focus: rgba(10, 132, 255, .45);
    --v2-danger: #ff453a;
    --v2-danger-fill: rgba(255, 69, 58, .12);
    --v2-success: #30d158;
    --v2-warning: #ff9f0a;
    --v2-shadow-card: none;
    --v2-shadow-pop: 0 12px 34px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .06);
    --v2-shadow-sheet: 0 30px 80px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .07);
}

body.ui-v2 ::selection { background: rgba(0, 122, 255, .18); }
body.ui-v2 :focus-visible { outline: 2px solid var(--v2-focus); outline-offset: 2px; }
/* Text fields: no glow ring on focus — a calm border + white field is enough. */
body.ui-v2 input:not([type=checkbox]):not([type=radio]):not([type=range]):focus-visible,
body.ui-v2 textarea:focus-visible, body.ui-v2 select:focus-visible { outline: none; }

/* ── Shell: sidebar ───────────────────────────────────────────────────── */
body.ui-v2 .sidebar { border-right: 1px solid var(--v2-line); }
body.ui-v2 .sidebar-logo-mark {
    background: none;
    box-shadow: none;
    border-radius: 7px;
}
body.ui-v2 .sidebar-logo-mark svg { color: var(--v2-on-primary); }
body.ui-v2 .sidebar-logo-text { font-weight: 650; letter-spacing: -.02em; }
body.ui-v2 .sidebar-logo-dot { color: inherit; }
body.ui-v2 .sidebar-logo-beta,
body.ui-v2.dark-theme .sidebar-logo-beta {
    background: var(--v2-fill-2); color: var(--v2-text-2); border-color: transparent;
    text-transform: none; letter-spacing: 0; font-size: 9px; font-weight: 600;
}
body.ui-v2 .sidebar-section-label,
body.ui-v2.dark-theme .sidebar-section-label {
    text-transform: none; letter-spacing: 0; font-size: 11.5px; font-weight: 600;
    color: var(--v2-text-3); padding: 18px 22px 6px;
}
body.ui-v2 .nav-item {
    font-size: 13.5px; font-weight: 500; padding: 8px 12px; margin: 1px 10px;
    transition: background-color .15s var(--v2-ease), color .15s var(--v2-ease);
}
body.ui-v2 .nav-item.active {
    background: var(--v2-accent-soft); color: var(--v2-accent-text); font-weight: 600; box-shadow: none;
}
body.ui-v2 .nav-item.active svg { stroke: var(--v2-accent-text); }

/* ── Typography ───────────────────────────────────────────────────────── */
body.ui-v2 .v2-display {
    font-family: var(--v2-font-display);
    font-size: 34px; line-height: 1.12; font-weight: 700; letter-spacing: -0.022em;
    color: var(--v2-text); margin: 0;
}
body.ui-v2 .v2-subtle { color: var(--v2-text-2); }

/* ── Buttons ──────────────────────────────────────────────────────────── */
body.ui-v2 .v2-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 34px; padding: 0 14px; border-radius: 999px;
    font: 500 13.5px/1 var(--v2-font); letter-spacing: -0.01em; white-space: nowrap;
    border: 1px solid transparent; cursor: pointer; text-decoration: none;
    transition: background-color .15s var(--v2-ease), border-color .15s var(--v2-ease), color .15s var(--v2-ease), opacity .15s;
}
body.ui-v2 .v2-btn svg { flex-shrink: 0; }
body.ui-v2 .v2-btn:disabled { opacity: .5; cursor: default; }
/* primary = tinted (light, airy); solid = the one final action in a dialog */
body.ui-v2 .v2-btn--primary { background: var(--v2-accent-soft); color: var(--v2-accent-text); font-weight: 600; }
body.ui-v2 .v2-btn--primary:hover:not(:disabled) { background: var(--v2-accent-soft-2); }
body.ui-v2 .v2-btn--solid { background: var(--v2-accent); color: #fff; font-weight: 600; }
body.ui-v2 .v2-btn--solid:hover:not(:disabled) { background: var(--v2-accent-hover); }
body.ui-v2 .v2-btn--secondary { background: var(--v2-surface); color: var(--v2-text); border-color: var(--v2-line-2); }
body.ui-v2 .v2-btn--secondary:hover:not(:disabled) { background: var(--v2-fill); }
body.ui-v2 .v2-btn--ghost { background: transparent; color: var(--v2-text-2); }
body.ui-v2 .v2-btn--ghost:hover:not(:disabled) { background: var(--v2-fill); color: var(--v2-text); }
body.ui-v2 .v2-btn--danger { background: var(--v2-danger); color: #fff; }
body.ui-v2 .v2-btn--danger:hover:not(:disabled) { opacity: .88; }
body.ui-v2 .v2-icon-btn {
    width: 30px; height: 30px; padding: 0; border-radius: 999px; border: none;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent; color: var(--v2-text-2); cursor: pointer;
    transition: background-color .15s var(--v2-ease), color .15s var(--v2-ease);
}
body.ui-v2 .v2-icon-btn:hover, body.ui-v2 .v2-icon-btn[aria-expanded="true"] { background: var(--v2-fill-2); color: var(--v2-text); }

/* ── Segmented control ────────────────────────────────────────────────── */
body.ui-v2 .v2-segmented {
    display: inline-flex; padding: 2px; gap: 2px; border-radius: 9px; background: var(--v2-fill-2);
}
body.ui-v2 .v2-segmented button {
    height: 28px; padding: 0 14px; border: none; border-radius: 7px; background: transparent;
    font: 500 13px/1 var(--v2-font); color: var(--v2-text-2); cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px;
    transition: background-color .18s var(--v2-ease), color .18s var(--v2-ease), box-shadow .18s;
}
body.ui-v2 .v2-segmented button[aria-selected="true"] {
    background: var(--v2-surface); color: var(--v2-accent-text); font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .10), 0 0 0 .5px rgba(0, 0, 0, .04);
}
body.ui-v2.dark-theme .v2-segmented button[aria-selected="true"] { background: #3a3a3c; box-shadow: none; }
body.ui-v2 .v2-segmented .v2-count { font-size: 12px; color: var(--v2-text-3); font-variant-numeric: tabular-nums; }

/* ── Inputs ───────────────────────────────────────────────────────────── */
body.ui-v2 .v2-search {
    position: relative; display: inline-flex; align-items: center;
}
body.ui-v2 .v2-search svg { position: absolute; left: 10px; color: var(--v2-text-3); pointer-events: none; }
body.ui-v2 .v2-search input {
    height: 34px; width: 220px; padding: 0 12px 0 32px; border-radius: 999px;
    border: 1px solid transparent; background: var(--v2-fill-2); color: var(--v2-text);
    font: 400 13.5px/1 var(--v2-font); outline: none;
    transition: background-color .15s, border-color .15s, box-shadow .15s, width .2s var(--v2-ease);
}
body.ui-v2 .v2-search input::placeholder { color: var(--v2-text-3); }
body.ui-v2 .v2-search input:focus { background: var(--v2-surface); border-color: var(--v2-line-2); box-shadow: var(--v2-shadow-card); }

body.ui-v2 .v2-field { display: flex; flex-direction: column; gap: 6px; }
body.ui-v2 .v2-label { font-size: 13px; font-weight: 500; color: var(--v2-text-2); }
body.ui-v2 .v2-input, body.ui-v2 .v2-textarea {
    width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 10px;
    border: 1px solid var(--v2-line-2); background: var(--v2-surface); color: var(--v2-text);
    font: 400 15px/1.4 var(--v2-font); outline: none;
    transition: border-color .15s, box-shadow .15s;
}
body.ui-v2 .v2-textarea { resize: vertical; min-height: 84px; }
body.ui-v2 .v2-input::placeholder, body.ui-v2 .v2-textarea::placeholder { color: var(--v2-text-3); }
body.ui-v2 .v2-input:focus, body.ui-v2 .v2-textarea:focus { border-color: var(--v2-focus-border); box-shadow: none; }
body.ui-v2.dark-theme .v2-input, body.ui-v2.dark-theme .v2-textarea { background: #2c2c2e; border-color: transparent; color-scheme: dark; }

/* ── Menu (popover) ───────────────────────────────────────────────────── */
body.ui-v2 .v2-menu {
    position: fixed; z-index: 10060; min-width: 180px; padding: 5px;
    background: var(--v2-surface); border-radius: 12px; box-shadow: var(--v2-shadow-pop);
    border: 1px solid var(--v2-line);
    opacity: 0; transform: scale(.97); transform-origin: top right; pointer-events: none;
    transition: opacity .14s var(--v2-ease), transform .14s var(--v2-ease);
}
body.ui-v2 .v2-menu.is-open { opacity: 1; transform: none; pointer-events: auto; }
body.ui-v2.dark-theme .v2-menu { background: #2c2c2e; }
body.ui-v2 .v2-menu-item {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px;
    border: none; background: none; border-radius: 8px; cursor: pointer; text-align: left;
    font: 400 13.5px/1.2 var(--v2-font); color: var(--v2-text);
}
body.ui-v2 .v2-menu-item svg { color: var(--v2-text-2); flex-shrink: 0; }
body.ui-v2 .v2-menu-item:hover, body.ui-v2 .v2-menu-item:focus-visible { background: var(--v2-fill-2); outline: none; }
body.ui-v2 .v2-menu-item.is-danger, body.ui-v2 .v2-menu-item.is-danger svg { color: var(--v2-danger); }
body.ui-v2 .v2-menu-sep { height: 1px; margin: 4px 6px; background: var(--v2-line); }

/* ── Sheet (modal) + confirm ──────────────────────────────────────────── */
body.ui-v2 .v2-overlay {
    position: fixed; inset: 0; z-index: 10050; display: flex; align-items: center; justify-content: center; padding: 20px;
    background: rgba(0, 0, 0, .28);
    opacity: 0; pointer-events: none; transition: opacity .18s var(--v2-ease);
}
body.ui-v2.dark-theme .v2-overlay { background: rgba(0, 0, 0, .6); }
body.ui-v2 .v2-overlay.is-open { opacity: 1; pointer-events: auto; }
body.ui-v2 .v2-sheet {
    width: 100%; max-width: 480px; max-height: calc(100vh - 40px); overflow: auto;
    background: var(--v2-surface); border-radius: var(--v2-r-lg); box-shadow: var(--v2-shadow-sheet);
    transform: translateY(8px) scale(.985); transition: transform .2s var(--v2-ease);
}
body.ui-v2 .v2-overlay.is-open .v2-sheet { transform: none; }
body.ui-v2 .v2-sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 6px; }
body.ui-v2 .v2-sheet-title { margin: 0; font: 650 19px/1.25 var(--v2-font-display); letter-spacing: -0.015em; color: var(--v2-text); }
body.ui-v2 .v2-sheet-body { padding: 12px 22px 6px; display: flex; flex-direction: column; gap: 16px; }
body.ui-v2 .v2-sheet-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 18px 22px 20px; }
body.ui-v2 .v2-sheet--alert { max-width: 340px; text-align: center; }
body.ui-v2 .v2-sheet--alert .v2-sheet-head { justify-content: center; padding-top: 24px; }
body.ui-v2 .v2-sheet--alert .v2-sheet-body { padding-top: 4px; font-size: 13.5px; line-height: 1.45; color: var(--v2-text-2); }
body.ui-v2 .v2-sheet--alert .v2-sheet-foot { justify-content: stretch; }
body.ui-v2 .v2-sheet--alert .v2-sheet-foot .v2-btn { flex: 1; }

/* ── Toast ────────────────────────────────────────────────────────────── */
body.ui-v2 .v2-toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 10070; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
body.ui-v2 .v2-toast {
    max-width: min(440px, calc(100vw - 32px)); padding: 10px 16px; border-radius: 999px;
    background: rgba(29, 29, 31, .94); color: #fff; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
    opacity: 0; transform: translateY(6px); transition: opacity .2s var(--v2-ease), transform .2s var(--v2-ease);
}
body.ui-v2.dark-theme .v2-toast { background: rgba(245, 245, 247, .96); color: #1d1d1f; }
body.ui-v2 .v2-toast.is-in { opacity: 1; transform: none; }
body.ui-v2 .v2-toast.is-error::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #ff453a; margin-right: 8px; vertical-align: 1px; }

@media (prefers-reduced-motion: reduce) {
    body.ui-v2 *, body.ui-v2 *::before, body.ui-v2 *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
