/* ============================================================================
   Veraius Corporate Polish
   ----------------------------------------------------------------------------
   Loaded after veraius-mixed.css. Enforces token-driven rounding on legacy
   brutalist scoped CSS, softens hovers, and adds restrained brand accent.
   Selectors prefixed with [data-theme] beat scoped .class[b-id] (0,2,0 > 0,1,1).
   ============================================================================ */

:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) {
    --radius-interactive: var(--btn-radius);
    --radius-surface: var(--card-radius);
    --radius-shell: var(--panel-radius);
    --hover-bg: color-mix(in srgb, var(--primary) 8%, var(--surface-container-high));
    --hover-bg-strong: color-mix(in srgb, var(--primary) 14%, var(--surface-container-high));
}

/* ── Foundation controls ─────────────────────────────────────────────────── */
:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) kbd,
:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) .kbd,
:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) .kbd-item kbd {
    border-radius: var(--btn-radius) !important;
}

:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) .heatmap-cell {
    border-radius: var(--btn-radius) !important;
}

:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) .mini-chart-bar {
    border-radius: var(--btn-radius) var(--btn-radius) 0 0 !important;
}

:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) .mini-chart-sparkline .mini-chart-bar {
    border-radius: var(--btn-radius) !important;
}

:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) .ring-fill {
    stroke-linecap: round;
}

/* ── Cards, panels, surfaces ─────────────────────────────────────────────── */
:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) :is(
    .card, .card-elevated, .card-interactive, .vcard,
    .glass-panel, .session-card, .alert-card,
    .mobile-menu, .notification-panel, .quick-create-panel,
    .sidebar-panel, .sidebar-flyout, .sidebar-rail-flyout,
    .nexus-canvas-toolbar, .workflow-node, .property-panel,
    .scenario-card, .stat-card-lg, .adoption-item,
    .app-content-surface, .va-login-form-card,
    .register-container, .forgot-password-screen
) {
    border-radius: var(--card-radius);
}

/* ── Buttons, tabs, nav, menu rows ───────────────────────────────────────── */
:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) :is(
    .btn, .button, .btn-primary, .btn-secondary, .btn-ghost, .btn-danger, .btn-chip,
    .ghost-button, .topbar-btn, .topbar-hamburger,
    .sidebar-rail__icon, .sidebar-rail__logo, .sidebar-rail__profile,
    .sidebar-rail__search, .sidebar-rail__collapse,
    .sidebar-nav-item, .sidebar-nav-badge, .sidebar-panel__collapse,
    .nav-item, .nav-link, .menu-item, .dropdown-item,
    .quick-create-item, .canvas-tab, .canvas-tool-btn,
    .notification-item, .chat-sidebar-item, .chat-thread-item,
    .va-login-sso__button, .va-login-submit, .va-login-checkbox__box,
    .cmd-result-item, .cmd-esc, .help-btn, .bottom-nav-item,
    .mobile-menu-close, .segment-btn, .filter-chip, .status-chip,
    .infra-chip, .badge, .tag, .pill, .chip
) {
    border-radius: var(--btn-radius);
}

:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) :is(
    .env-badge, .step-badge, .step-status, .step-score,
    .source-ref-badge, .va-source-badge, .va-mode-badge,
    .landing-action-badge, .landing-result-tag, .hud-badge
) {
    border-radius: var(--chip-radius, var(--btn-radius));
}

/* ── Inputs & fields ─────────────────────────────────────────────────────── */
:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) :is(
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
    select, textarea, .field-input, .form-control,
    .va-login-underline__input, .rag-search, .a2ui-form__input,
    .search-input, .filter-input, .config-search
) {
    border-radius: var(--input-radius);
}

/* ── Chat & command surfaces ───────────────────────────────────────────────── */
:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) :is(
    .msg-user-bubble, .va-user-message-bubble, .msg-assistant-body,
    .va-ask-card, .transparency-card, .thinking-panel,
    .code-sandbox-wrapper, .msg-pinned-context, .msg-user-edit-input,
    .msg-text pre, .msg-text .code-block-container, .msg-text .mermaid-container,
    .command-input-wrap, .command-dock, .command-palette-input-wrap,
    .model-dropdown, .mission-briefing-hero, .chat-input-shell,
    .chat-composer, .input-dock, .va-dock-mode-group,
    .landing-search, .landing-results, .landing-action-card,
    .va-route-preview, .va-more-menu, .va-slash-popover,
    .chat-error-banner, .chat-slash-banner, .va-thinking-collapsed
) {
    border-radius: var(--card-radius) !important;
}

:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) :is(
    .msg-text code, .msg-text .citation-chip, .action-btn,
    .va-seg-btn, .model-dropdown-item, .skeleton-line,
    .chat-sidebar-badge, .chat-action-btn, .mode-chip, .va-more-item
) {
    border-radius: var(--btn-radius) !important;
}

/* ── Pattern-based (scoped Blazor class names) ───────────────────────────── */
:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) [class*="__button"],
:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) [class*="__btn"],
:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) [class*="-btn"],
:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) [class*="__chip"],
:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) [class*="__badge"],
:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) [class*="__tab"],
:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) [class*="__pill"] {
    border-radius: var(--btn-radius);
}

:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) [class*="__card"],
:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) [class*="__panel"],
:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) [class*="__surface"],
:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) [class*="__bubble"],
:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) [class*="__dropdown"],
:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) [class*="__menu"]:not([class*="__menu-item"]) {
    border-radius: var(--card-radius);
}

:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) [class*="__input"],
:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) [class*="__field"] {
    border-radius: var(--input-radius);
}

/* ── Corporate hover affordance (rounded highlight blocks) ─────────────────── */
:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) :is(
    button, [role="button"], .btn, .topbar-btn, .sidebar-rail__icon,
    .sidebar-nav-item, .cmd-result-item, .user-menu-item, .tenant-switcher-item,
    .quick-create-item, .notification-item, .canvas-tab, .bottom-nav-item,
    .va-login-sso__button, .ghost-button
):not(:disabled):not([aria-disabled="true"]) {
    transition:
        background-color var(--transition-btn),
        color var(--transition-btn),
        box-shadow var(--transition-btn),
        transform var(--transition-btn),
        border-radius var(--transition-btn);
}

:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) :is(
    .sidebar-rail__icon:hover,
    .sidebar-nav-item:hover,
    .topbar-btn:hover,
    .cmd-result-item:hover,
    .cmd-result-item.selected,
    .user-menu-item:hover,
    .tenant-switcher-item:hover,
    .quick-create-item:hover,
    .notification-item:hover,
    .canvas-tab:hover,
    .bottom-nav-item:hover,
    .ghost-button:hover
) {
    background: var(--hover-bg);
}

:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) :is(
    .sidebar-nav-item.active,
    .sidebar-rail__icon.active,
    .bottom-nav-item.active,
    .canvas-tab.active
) {
    background: var(--hover-bg-strong);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 25%, transparent);
}

/* AKTİF ÖĞENİN İKONU DA ZEMİNLE BİRLİKTE UYARLANMALI.
   ÖLÇÜLEN KUSUR (2026-09-07, headed Playwright): yukarıdaki kural aktif gezinti öğesinin
   ZEMİNİNİ `--hover-bg-strong` yapıyor (light temada AÇIK bir ton), ama ikonun rengine
   dokunmuyordu. İkon `veraius-components.css`'te `--sidebar-primary` (#9ad0d3) alıyor —
   o renk KOYU sidebar zemini için tasarlanmış.
   Ölçüm: zemin `color(srgb 0.87 0.92 0.93)`, ikon #9ad0d3 → kontrast 1.40. WCAG 1.4.3 AA
   eşiği 4.5. Üç workflow rotasında da aynı ihlal çıktı (account_tree · library_books ·
   monitoring). `--brand-teal-text` (#106064) aynı zeminde 6.00 verir.
   NOT: guard bunu "beyaz zemin, oran 1.7" diye bildiriyordu — `color(srgb …)` biçimini
   ayrıştıramayıp varsayılana düşüyor. Gerçek zemin ölçülünce oran daha da kötü çıktı;
   yani bulgu gerçekti, yalnız sayısı iyimserdi. */
:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) :is(
    .sidebar-nav-item.active,
    .sidebar-rail__icon.active,
    .bottom-nav-item.active,
    .canvas-tab.active
) :is(.sidebar-item-icon, .sidebar-group-icon) {
    color: var(--brand-teal-text, var(--primary));
    filter: none;
}

/* ── Light theme: subtle brand wash on page canvas ───────────────────────── */
[data-theme="light"] .app-body {
    background:
        radial-gradient(120% 80% at 0% 0%, color-mix(in srgb, var(--brand-teal) 6%, transparent), transparent 55%),
        radial-gradient(90% 60% at 100% 100%, color-mix(in srgb, var(--brand-gold) 5%, transparent), transparent 50%),
        var(--surface-container-lowest);
}

[data-theme="light"] .app-content-surface {
    box-shadow:
        var(--shadow-xs),
        0 12px 40px color-mix(in srgb, var(--brand-teal) 6%, transparent);
}

/* ── Dark theme: restrained teal depth on shell ────────────────────────────── */
[data-theme="dark"] .app-body {
    background:
        radial-gradient(100% 70% at 0% 0%, color-mix(in srgb, var(--brand-teal) 8%, transparent), transparent 50%),
        var(--surface-container-lowest);
}

/* ── Skip link & auth polish ───────────────────────────────────────────────── */
:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) .skip-to-content {
    border-radius: 0 0 var(--btn-radius) var(--btn-radius);
}

:is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) .mobile-menu {
    border-radius: 0 var(--panel-radius) var(--panel-radius) 0;
}

@media (min-width: 768px) {
    :is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) .app-content-surface {
        border-radius: var(--panel-radius);
    }
}

@media (max-width: 767px) {
    :is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) .app-content-surface {
        border-radius: var(--card-radius) var(--card-radius) 0 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    :is([data-theme="dark"], [data-theme="light"], [data-theme="mixed"]) :is(
        button, [role="button"], .btn, .topbar-btn, .sidebar-rail__icon, .sidebar-nav-item
    ) {
        transition: none !important;
    }
}
