/* ============================================================================
   PKV Floating Comparison Bar - Compact Pill
   Bottom-right positioned pill that expands to show selected products.
   Solid background with shadow. Pill trigger + expandable panel.
   ============================================================================ */

.pkv-floating-bar {
    position: fixed;
    bottom: clamp(0.75rem, 2vw, 1.25rem);
    right: clamp(0.75rem, 2vw, 1.25rem);
    left: auto;
    z-index: 999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}


/* --- Pill trigger --- */

.pkv-floating-bar__pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.125rem;
    min-width: 160px;
    min-height: 44px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: 9999px;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.05),
        0 2px 4px -2px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: inherit;
    line-height: 1.3;
    white-space: nowrap;
    transition: box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html.dark .pkv-floating-bar__pill {
    background: rgba(30, 30, 30, 0.75);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.2),
        0 2px 4px -2px rgba(0, 0, 0, 0.15);
}

.pkv-floating-bar__pill:hover {
    border-color: var(--accent);
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.04),
        0 6px 16px rgba(0, 0, 0, 0.08),
        0 16px 36px rgba(0, 0, 0, 0.14);
}

html.dark .pkv-floating-bar__pill:hover {
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.2),
        0 6px 16px rgba(0, 0, 0, 0.35),
        0 16px 36px rgba(0, 0, 0, 0.55);
}

.pkv-floating-bar__pill-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    flex-shrink: 0;
}

.pkv-floating-bar__pill-icon svg {
    width: 16px;
    height: 16px;
}

.pkv-floating-bar__pill-text {
    flex: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pkv-floating-bar__pill-chevron {
    font-size: 0.5rem;
    color: var(--text-muted);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

/* SVG chevron variant */
.pkv-floating-bar__pill-chevron svg {
    width: 16px;
    height: 16px;
}

.pkv-floating-bar__pill-chevron--open {
    transform: rotate(180deg);
}


/* --- Expandable panel --- */

.pkv-floating-bar__panel {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.04),
        0 4px 8px rgba(0, 0, 0, 0.06),
        0 16px 32px rgba(0, 0, 0, 0.08);
    padding: 0.75rem;
    width: min(340px, calc(100vw - 2rem));
    overflow: hidden;
}

html.dark .pkv-floating-bar__panel {
    background: rgba(30, 30, 30, 0.9);
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.15),
        0 4px 8px rgba(0, 0, 0, 0.25),
        0 16px 32px rgba(0, 0, 0, 0.35);
}


/* --- Tab strip (multi-type navigation) --- */

.pkv-floating-bar__tabs {
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.pkv-floating-bar__tabs::-webkit-scrollbar {
    display: none;
}

.pkv-floating-bar__tab {
    display: flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
    white-space: nowrap;
    background: var(--bg-secondary);
    border: 1px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    scroll-snap-align: start;
    flex-shrink: 0;
    font-family: inherit;
    transition: background 0.2s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.pkv-floating-bar__tab:hover {
    border-color: var(--border);
}

.pkv-floating-bar__tab--active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.pkv-floating-bar__tab--active:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}


/* --- Product items --- */

.pkv-floating-bar__items {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin-bottom: 0.625rem;
    max-height: 240px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.pkv-floating-bar__items::-webkit-scrollbar {
    width: 4px;
}

.pkv-floating-bar__items::-webkit-scrollbar-track {
    background: transparent;
}

.pkv-floating-bar__items::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.pkv-floating-bar__items::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.pkv-floating-bar__item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.5rem;
    background: var(--bg-secondary);
    border-radius: 0.5rem;
}

.pkv-floating-bar__item-image {
    width: 36px;
    height: 36px;
    border-radius: 0.375rem;
    object-fit: contain;
    background: var(--bg-primary);
    padding: 2px;
    flex-shrink: 0;
}

html.dark .pkv-floating-bar__item-image {
    background: rgba(255, 255, 255, 0.06);
}

.pkv-floating-bar__item-name {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
    line-height: 1.3;
}

.pkv-floating-bar__item-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 0.875rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
        background 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.pkv-floating-bar__item-remove:hover {
    color: var(--error);
    background: rgba(var(--error-rgb), 0.08);
}

html.dark .pkv-floating-bar__item-remove:hover {
    color: var(--error);
    background: rgba(var(--error-rgb), 0.1);
}

.pkv-floating-bar__item-remove:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}


/* --- Actions --- */

.pkv-floating-bar__actions {
    display: flex;
    gap: 0.5rem;
}

.pkv-floating-bar__count {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.pkv-floating-bar__compare-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: #fff;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 700;
    text-decoration: none;
    border: none;
    cursor: pointer;
    min-height: 36px;
    font-family: inherit;
    transition: background 0.2s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.1s cubic-bezier(0.4, 0, 0.2, 1);
}

.pkv-floating-bar__compare-btn:hover {
    background: var(--accent-hover);
    color: #fff;
    box-shadow: 0 2px 8px rgba(var(--accent-rgb), 0.3);
}

.pkv-floating-bar__compare-btn:active {
    transform: scale(0.97);
    box-shadow: none;
}

.pkv-floating-bar__clear-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    min-height: 36px;
    flex-shrink: 0;
    font-family: inherit;
    transition: border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
        color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.pkv-floating-bar__clear-btn:hover {
    border-color: var(--error);
    color: var(--error);
}

html.dark .pkv-floating-bar__clear-btn:hover {
    border-color: var(--error);
    color: var(--error);
}


/* --- Footer (below items) --- */

.pkv-floating-bar__footer {
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    display: flex;
    justify-content: center;
}

.pkv-floating-bar__clear-all-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    min-height: 36px;
    font-family: inherit;
    transition: border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
        color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.pkv-floating-bar__clear-all-btn:hover {
    border-color: var(--error);
    color: var(--error);
}

html.dark .pkv-floating-bar__clear-all-btn:hover {
    border-color: var(--error);
    color: var(--error);
}

.pkv-floating-bar__clear-all-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}


/* --- Alpine.js Slide-up Transition --- */
/* Class-based only. Do NOT use [x-transition\:...] attribute selectors --
   those attributes are always present on the element (Alpine directives)
   and would permanently apply enter-start styles (opacity:0, translateY). */

.pkv-floating-bar--enter,
.pkv-floating-bar--leave {
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
        opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.pkv-floating-bar--enter-start {
    transform: translateY(20px);
    opacity: 0;
}

.pkv-floating-bar--enter-end {
    transform: translateY(0);
    opacity: 1;
}

.pkv-floating-bar--leave-start {
    transform: translateY(0);
    opacity: 1;
}

.pkv-floating-bar--leave-end {
    transform: translateY(20px);
    opacity: 0;
}


/* --- Mobile: compact positioning --- */

@media (max-width: 640px) {
    .pkv-floating-bar {
        bottom: 0.5rem;
        right: 0.5rem;
    }

    .pkv-floating-bar__panel {
        width: calc(100vw - 1rem);
    }

    .pkv-floating-bar__pill {
        padding: 0.5rem 0.875rem;
        min-width: 140px;
        min-height: 44px;
        font-size: 0.75rem;
    }

    .pkv-floating-bar__tab {
        padding: 0.25rem 0.5rem;
        font-size: 0.625rem;
    }

    .pkv-floating-bar__items {
        max-height: 180px;
    }
}


/* --- Reduced Motion --- */

@media (prefers-reduced-motion: reduce) {

    .pkv-floating-bar__pill,
    .pkv-floating-bar__pill-chevron,
    .pkv-floating-bar__item-remove,
    .pkv-floating-bar__compare-btn,
    .pkv-floating-bar__clear-btn,
    .pkv-floating-bar__clear-all-btn,
    .pkv-floating-bar__tab,
    .pkv-floating-bar--enter,
    .pkv-floating-bar--leave {
        transition: none;
    }

    .pkv-floating-bar__compare-btn:active {
        transform: none;
    }

    .pkv-floating-bar__panel {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: var(--bg-primary);
    }

    html.dark .pkv-floating-bar__panel {
        background: var(--bg-primary);
    }
}