/**
 * Product Actions & Favorite Button Styles
 *
 * Follows existing dropdown patterns from:
 * - .user-dropdown (theme-vars.css)
 * - .builds-dropdown (builder.css)
 *
 * Uses ONLY CSS variables from theme-vars.css
 *
 * @package Flavor
 */

/* ============================================
   PRODUCT ACTIONS DROPDOWN
   ============================================ */

/* Container */
.product-actions {
    position: relative;
    display: inline-flex;
}

/* Trigger Button - matches .header-action-btn pattern */
.product-actions__trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.product-actions__trigger:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.product-actions__trigger:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Dropdown Menu - matches .user-dropdown pattern */
.product-actions__dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 100;
    min-width: 200px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    padding: 8px;
}

/* Position variant for left-aligned dropdown */
.product-actions--left .product-actions__dropdown {
    right: auto;
    left: 0;
}

/* Dropdown Items - matches .user-dropdown__item pattern */
.product-actions__item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.product-actions__item:hover {
    background-color: var(--bg-hover);
}

.product-actions__item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

/* Item icons */
.product-actions__item svg {
    flex-shrink: 0;
    color: var(--text-muted);
    transition: color 0.15s ease;
}

.product-actions__item:hover svg {
    color: var(--text-primary);
}

/* Favorite active state - matches .user-dropdown__item--logout pattern */
.product-actions__item--active {
    color: var(--error);
}

.product-actions__item--active svg {
    color: var(--error);
}

.product-actions__item--active:hover {
    background-color: var(--error-bg);
}


/* ============================================
   FAVORITE BUTTON (Standalone)
   ============================================ */

.favorite-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.favorite-btn:hover {
    background-color: var(--bg-hover);
    border-color: var(--border-light);
    color: var(--text-primary);
}

.favorite-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Active/Favorited state */
.favorite-btn--active {
    color: var(--error);
    border-color: var(--error);
    background-color: var(--error-bg);
}

.favorite-btn--active:hover {
    background-color: var(--error-bg);
    border-color: var(--error);
}

/* Loading state */
.favorite-btn--loading {
    pointer-events: none;
    opacity: 0.7;
}

.favorite-btn__spinner {
    animation: favorite-spin 0.8s linear infinite;
}

@keyframes favorite-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Icon transitions */
.favorite-btn__icon {
    transition: transform 0.2s ease;
}

.favorite-btn:hover .favorite-btn__icon {
    transform: scale(1.1);
}

.favorite-btn:active .favorite-btn__icon {
    transform: scale(0.95);
}

/* Size variants */
.favorite-btn--small {
    border-radius: 6px;
}

.favorite-btn--large {
    border-radius: 10px;
}


/* ============================================
   DROPDOWN TRANSITIONS
   (Using same pattern as theme-vars.css)
   ============================================ */

.dropdown-enter {
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.dropdown-enter-start {
    opacity: 0;
    transform: translateY(-4px);
}

.dropdown-enter-end {
    opacity: 1;
    transform: translateY(0);
}

.dropdown-leave {
    transition: opacity 0.1s ease, transform 0.1s ease;
}

.dropdown-leave-start {
    opacity: 1;
    transform: translateY(0);
}

.dropdown-leave-end {
    opacity: 0;
    transform: translateY(-4px);
}


/* ============================================
   MOBILE ADJUSTMENTS
   ============================================ */

@media (max-width: 768px) {
    .product-actions__dropdown {
        min-width: 180px;
    }

    .product-actions__item {
        padding: 12px;
        font-size: 0.9375rem;
    }
}


/* ============================================
   PRICE ALERT BUTTON & POPOVER
   ============================================ */

/* Wrapper for alert button and popover */
.product-alert-wrapper {
    position: relative;
    display: inline-flex;
}

/* Alert button active state */
.product-info__icon-btn.is-alert-active {
    color: var(--accent);
    background-color: rgba(var(--accent-rgb), 0.1);
}

.product-info__icon-btn.is-alert-active:hover {
    background-color: rgba(var(--accent-rgb), 0.15);
}

/* Alert Popover */
.product-alert-popover {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 1000;
    min-width: 300px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg, 12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.product-alert-popover__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.product-alert-popover__title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.product-alert-popover__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm, 6px);
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    transition: all 150ms ease;
}

.product-alert-popover__close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.product-alert-popover__body {
    padding: 1rem;
}

.product-alert-popover__description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0 0 1rem 0;
    line-height: 1.5;
}

/* Price box - prominent display */
.product-alert-popover__price-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 8px);
    text-align: center;
}

.product-alert-popover__price-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.product-alert-popover__price-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.2;
}

/* Legacy support */
.product-alert-popover__current {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.625rem 0.875rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm, 6px);
}

.product-alert-popover__current-label {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.product-alert-popover__current-value {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Alert type selection */
.product-alert-popover__types {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.product-alert-popover__type {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 150ms ease;
}

.product-alert-popover__type input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.product-alert-popover__type.is-selected {
    background: rgba(var(--accent-rgb), 0.1);
    border-color: var(--accent);
    color: var(--accent);
}

.product-alert-popover__type:hover:not(.is-selected) {
    background: var(--bg-primary);
    border-color: var(--text-muted);
}

/* Alert input groups */
.product-alert-popover__input-group {
    margin-bottom: 1rem;
}

.product-alert-popover__input-group label {
    display: block;
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.product-alert-popover__input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.product-alert-popover__input {
    flex: 1;
    min-height: 40px;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px);
    color: var(--text-primary);
    font-size: 0.9375rem;
    transition: all 150ms ease;
}

.product-alert-popover__input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.1);
}

.product-alert-popover__input-suffix,
.product-alert-popover__input-prefix {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* Alert error message */
.product-alert-popover__error {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem;
    background: rgba(var(--error-rgb), 0.1);
    border-radius: var(--radius-sm, 6px);
    margin-bottom: 1rem;
}

.product-alert-popover__error svg {
    flex-shrink: 0;
    color: var(--error);
}

.product-alert-popover__error span {
    font-size: 0.8125rem;
    color: var(--error);
    line-height: 1.4;
}

/* Alert popover footer */
.product-alert-popover__footer {
    display: flex;
    gap: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.product-alert-popover__btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm, 6px);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 150ms ease;
}

.product-alert-popover__btn--cancel {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.product-alert-popover__btn--cancel:hover {
    background: var(--bg-primary);
    border-color: var(--text-muted);
}

.product-alert-popover__btn--create {
    background: var(--accent);
    border: 1px solid var(--accent);
    color: var(--bg-primary);
}

.product-alert-popover__btn--create:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.product-alert-popover__btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Active alert info - CONSISTENT WITH BUILDER */
.product-alert-popover__active-info {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
    padding: 12px;
    background-color: rgba(var(--accent-rgb, 48, 119, 166), 0.1);
    border: 1px solid rgba(var(--accent-rgb, 48, 119, 166), 0.2);
    border-radius: 8px;
}

.product-alert-popover__active-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.product-alert-popover__active-text {
    flex: 1;
}

.product-alert-popover__active-text p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.product-alert-popover__active-text strong {
    color: var(--accent);
}

/* Delete button - CONSISTENT WITH BUILDER */
.product-alert-popover__btn--delete {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    background: transparent;
    border: 1px solid var(--error);
    color: var(--error);
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.product-alert-popover__btn--delete:hover:not(:disabled) {
    background-color: var(--error);
    color: #fff;
}

.product-alert-popover__btn--delete:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.product-alert-popover__footer--single {
    border-top: none;
    padding-top: 0;
}

/* Account link */
.product-alert-popover__account-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.8125rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 150ms ease;
}

.product-alert-popover__account-link:hover {
    color: var(--accent);
}

.product-alert-popover__account-link svg {
    opacity: 0.7;
}

/* Dark mode enhancements */
.dark .product-alert-popover,
html.dark .product-alert-popover,
[data-theme="dark"] .product-alert-popover {
    background: var(--bg-primary);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

/* Mobile: Bottom sheet style */
@media (max-width: 640px) {
    .product-alert-popover {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        min-width: 100%;
        max-width: 100%;
        border-radius: var(--radius-xl, 16px) var(--radius-xl, 16px) 0 0;
        box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.25);
        z-index: 9999;
    }

    .product-alert-popover__header {
        padding: 1.25rem 1.25rem 1rem;
    }

    .product-alert-popover__body {
        padding: 1.25rem;
        max-height: 60vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .product-alert-popover__types {
        flex-direction: column;
        gap: 0.75rem;
    }

    .product-alert-popover__type {
        padding: 1rem;
    }

    .product-alert-popover__input {
        min-height: 48px;
        font-size: 1rem;
    }

    .product-alert-popover__btn {
        min-height: 48px;
        font-size: 1rem;
    }

    .product-alert-popover__footer {
        padding: 1rem 1.25rem;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    }
}
