/* ============================================================
   FUTURE UI LAYER — HTMX swap choreography, glass panels, radar UX
   Theme-agnostic enhancements; pairs with neoradar + default
   ============================================================ */

/* ── HTMX swap animations ─────────────────────────────────── */
.htmx-swapping {
    opacity: 0;
    transform: translateY(6px) scale(0.992);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.htmx-settling {
    opacity: 1;
    transform: none;
}

.htmx-added {
    animation: tk-future-enter 0.38s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes tk-future-enter {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
        filter: blur(4px);
    }
    to {
        opacity: 1;
        transform: none;
        filter: none;
    }
}

/* ── Glass panels ─────────────────────────────────────────── */
.tk-glass-panel {
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(14px) saturate(1.25);
    -webkit-backdrop-filter: blur(14px) saturate(1.25);
    border: 1px solid rgba(120, 150, 180, 0.22);
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.08);
}

html[data-theme="neoradar"] .tk-glass-panel {
    background: rgba(12, 20, 34, 0.68);
    border-color: rgba(0, 229, 255, 0.16);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.tk-glow-focus:focus-within {
    box-shadow: 0 0 0 1px rgba(13, 110, 253, 0.35), 0 0 20px rgba(13, 110, 253, 0.12);
}

html[data-theme="neoradar"] .tk-glow-focus:focus-within {
    box-shadow: 0 0 0 1px rgba(0, 229, 255, 0.45), 0 0 24px rgba(0, 229, 255, 0.18);
}

/* ── Global futuristic indicator ──────────────────────────── */
.tk-future-indicator {
    position: fixed;
    top: calc(var(--nav-h, 56px) + 10px);
    right: 14px;
    z-index: 1085;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.tk-future-indicator.htmx-request {
    opacity: 1;
    transform: scale(1);
}

.tk-radar-spinner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(0, 229, 255, 0.15);
    border-top-color: var(--tk-primary, #0d6efd);
    animation: tk-radar-spin 0.75s linear infinite;
    box-shadow: 0 0 16px rgba(0, 229, 255, 0.25);
}

html[data-theme="neoradar"] .tk-radar-spinner {
    border-color: rgba(0, 229, 255, 0.12);
    border-top-color: #00e5ff;
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.35);
}

@keyframes tk-radar-spin {
    to { transform: rotate(360deg); }
}

/* ── HTMX modal root ──────────────────────────────────────── */
.tk-htmx-modal-root {
    position: fixed;
    inset: 0;
    z-index: 1090;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    pointer-events: none;
}

.tk-htmx-modal-root:not(:empty) {
    pointer-events: auto;
    background: rgba(4, 8, 16, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: tk-modal-backdrop-in 0.25s ease;
}

@keyframes tk-modal-backdrop-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.tk-htmx-modal-shell {
    width: min(560px, 100%);
    max-height: min(88vh, 720px);
    overflow: auto;
    border-radius: 1rem;
    animation: tk-future-enter 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.tk-htmx-modal-shell .modal-header {
    border-bottom-color: rgba(120, 150, 180, 0.2);
}

/* ── Guided flow rail ─────────────────────────────────────── */
.tk-flow-rail {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.tk-flow-step-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid rgba(120, 150, 180, 0.25);
    background: rgba(255, 255, 255, 0.55);
    color: #5c6570;
    transition: all 0.25s ease;
}

.tk-flow-step-pill.is-active {
    border-color: var(--tk-primary, #0d6efd);
    background: rgba(13, 110, 253, 0.12);
    color: var(--tk-primary, #0d6efd);
    box-shadow: 0 0 16px rgba(13, 110, 253, 0.15);
}

.tk-flow-step-pill.is-done {
    border-color: rgba(25, 135, 84, 0.35);
    background: rgba(25, 135, 84, 0.1);
    color: #198754;
}

html[data-theme="neoradar"] .tk-flow-step-pill.is-active {
    border-color: rgba(0, 229, 255, 0.5);
    background: rgba(0, 229, 255, 0.1);
    color: #7ee8ff;
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.2);
}

.tk-flow-hint {
    font-size: 0.82rem;
    padding: 0.55rem 0.75rem;
    border-radius: 0.65rem;
    border-left: 3px solid var(--tk-primary, #0d6efd);
    background: rgba(13, 110, 253, 0.06);
    margin-bottom: 0.75rem;
}

html[data-theme="neoradar"] .tk-flow-hint {
    background: rgba(0, 229, 255, 0.07);
    border-left-color: #00e5ff;
}

/* ── Flow sections ────────────────────────────────────────── */
.tk-flow-section {
    border-radius: 0.85rem;
    padding: 0.85rem;
    margin-bottom: 0.65rem;
    border: 1px solid transparent;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.tk-flow-section.is-active {
    border-color: rgba(13, 110, 253, 0.25);
    box-shadow: 0 4px 20px rgba(13, 110, 253, 0.06);
}

html[data-theme="neoradar"] .tk-flow-section.is-active {
    border-color: rgba(0, 229, 255, 0.22);
    box-shadow: 0 6px 28px rgba(0, 229, 255, 0.08);
}

/* ── Dynamic submit button states ─────────────────────────── */
.tk-btn-future {
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.25s ease;
}

.tk-btn-future::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.22) 50%, transparent 60%);
    transform: translateX(-120%);
    transition: transform 0.5s ease;
}

.tk-btn-future:hover::after {
    transform: translateX(120%);
}

.tk-btn-future.is-ready {
    animation: tk-pulse-ready 2.4s ease-in-out infinite;
}

@keyframes tk-pulse-ready {
    0%, 100% { box-shadow: 0 0 0 0 rgba(13, 110, 253, 0); }
    50%      { box-shadow: 0 0 0 6px rgba(13, 110, 253, 0.12); }
}

html[data-theme="neoradar"] .tk-btn-future.is-ready {
    animation-name: tk-pulse-ready-neo;
}

@keyframes tk-pulse-ready-neo {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 229, 255, 0); }
    50%      { box-shadow: 0 0 0 8px rgba(0, 229, 255, 0.15); }
}

/* ── Suggestion lists (commessa / attività) ───────────────── */
.tk-suggest-panel {
    border-radius: 0.65rem;
    overflow: hidden;
    border: 1px solid rgba(120, 150, 180, 0.2);
    backdrop-filter: blur(10px);
}

.tk-suggest-panel .list-group-item {
    transition: background 0.15s ease, padding-left 0.15s ease;
}

.tk-suggest-panel .list-group-item:hover {
    padding-left: 0.85rem !important;
    background: rgba(13, 110, 253, 0.08) !important;
}

html[data-theme="neoradar"] .tk-suggest-panel .list-group-item:hover {
    background: rgba(0, 229, 255, 0.1) !important;
}

/* ── Admin filter card enhancement ──────────────────────────── */
.filters-card.tk-glass-panel .filters-body-tight {
    background: transparent !important;
}

/* ── Cognitive flow — second pass (2026-06-29) ─────────────── */

/* Regional HTMX loading — indicator exactly on the swapping container */
.tk-htmx-region {
    position: relative;
}

.tk-htmx-region.tk-region-loading::after,
.tk-htmx-region.htmx-request::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 11;
    background: color-mix(in srgb, var(--tk-bg-card, #fff) 68%, transparent);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    pointer-events: none;
    animation: tk-modal-backdrop-in 0.18s ease;
}

.tk-htmx-region.tk-region-loading::before,
.tk-htmx-region.htmx-request::before {
    content: "";
    position: absolute;
    top: 1.25rem;
    left: 50%;
    z-index: 12;
    width: 26px;
    height: 26px;
    margin-left: -13px;
    border-radius: 50%;
    border: 2px solid rgba(13, 110, 253, 0.14);
    border-top-color: var(--tk-primary, #0d6efd);
    animation: tk-radar-spin 0.75s linear infinite;
    pointer-events: none;
}

html[data-theme="neoradar"] .tk-htmx-region.tk-region-loading::before,
html[data-theme="neoradar"] .tk-htmx-region.htmx-request::before {
    border-color: rgba(0, 229, 255, 0.12);
    border-top-color: #00e5ff;
}

.tk-region-loader {
    position: absolute;
    inset: 0;
    z-index: 12;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 2.5rem;
    background: color-mix(in srgb, var(--tk-bg-card, #fff) 72%, transparent);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

.tk-htmx-region.htmx-request .tk-region-loader,
.tk-htmx-region.tk-region-loading .tk-region-loader {
    opacity: 1;
}

.tk-radar-spinner--sm {
    width: 28px;
    height: 28px;
}

/* Edit row — progressive backdrop blur on surrounding chrome */
.tk-edit-focus-shell {
    position: relative;
    isolation: isolate;
}

.tk-edit-focus-shell::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 5;
    background: rgba(4, 8, 16, 0.42);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    pointer-events: none;
    animation: tk-modal-backdrop-in 0.22s ease;
}

html[data-theme="neoradar"] .tk-edit-focus-shell::before {
    background: rgba(2, 6, 14, 0.55);
}

.tk-edit-focus-shell tbody tr:is(.table-warning, .table-success, .table-info) {
    position: relative;
    z-index: 8;
    box-shadow: 0 0 0 1px rgba(13, 110, 253, 0.25), 0 8px 28px rgba(15, 23, 42, 0.12);
}

html[data-theme="neoradar"] .tk-edit-focus-shell tbody tr:is(.table-warning, .table-success, .table-info) {
    box-shadow: 0 0 0 1px rgba(0, 229, 255, 0.35), 0 8px 32px rgba(0, 0, 0, 0.45);
}

/* Inline field validation hints */
.tk-field-hint-slot {
    min-height: 1.15rem;
    margin-top: 0.2rem;
}

.tk-field-hint {
    display: inline-flex;
    align-items: center;
    font-size: 0.72rem;
    line-height: 1.2;
    padding: 0.15rem 0.45rem;
    border-radius: 0.4rem;
    animation: tk-future-enter 0.28s ease both;
}

.tk-field-hint--ok {
    color: #198754;
    background: rgba(25, 135, 84, 0.1);
}

.tk-field-hint--warn {
    color: #b45309;
    background: rgba(245, 158, 11, 0.12);
}

.tk-field-hint--error {
    color: #b91c1c;
    background: rgba(220, 38, 38, 0.1);
}

.tk-field-hint--neutral {
    color: var(--tk-text-muted, #6c757d);
    background: rgba(108, 117, 125, 0.08);
}

html[data-theme="neoradar"] .tk-field-hint--ok {
    color: #6ee7b7;
    background: rgba(16, 185, 129, 0.12);
}

html[data-theme="neoradar"] .tk-field-hint--warn {
    color: #fcd34d;
    background: rgba(245, 158, 11, 0.14);
}

html[data-theme="neoradar"] .tk-field-hint--error {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.12);
}

/* Empty state — guided next action */
.tk-empty-next {
    border-radius: 0.65rem;
    background: color-mix(in srgb, var(--tk-bg-surface, #f8f9fa) 88%, transparent);
    border: 1px dashed var(--tk-border-soft, rgba(0, 0, 0, 0.08));
}

.tk-empty-next-icon {
    opacity: 0.35;
}

.tk-empty-next-btn {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.tk-empty-next-btn:hover {
    transform: translateY(-1px);
}

/* Progressive disclosure — advanced filters panel */
.fg-advanced-panel {
    transition: max-height 0.32s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.28s ease;
}

.fg-advanced-panel:not(.show) {
    opacity: 0.92;
}

/* Dim filter chrome while table refreshes (eye stays on table skeleton) */
#table_container.tk-table-refreshing #filter-container {
    opacity: 0.88;
    transition: opacity 0.2s ease;
    pointer-events: none;
}
