/* Pack Widget Styles */

.pack-widget {
    position: relative;
    margin-right: 16px;
    display: inline-flex;
    align-items: center;
}

#pack-trigger {
    position: relative;
    z-index: 101;
}

#pack-count-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: #b3261e;
    /* Explicit Red */
    color: #ffffff;
    border: 2px solid #ffffff;
    /* White border for contrast */
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 102;
    pointer-events: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

#pack-count-badge.hidden {
    display: none;
}

.hidden {
    display: none !important;
}

/* Dropdown */
.pack-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 12px;
    width: 320px;
    background: rgba(255, 255, 255, 1);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.05);
    padding: 20px;
    z-index: 100;
    transform-origin: top right;
    transition: opacity 0.2s, transform 0.2s;
}

.pack-dropdown.hidden {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
}

.pack-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding-bottom: 12px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pack-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.pack-status {
    font-size: 0.8rem;
    color: var(--md-sys-color-on-surface-variant);
}

/* Slots */
/* Slots Wrapper */
.pack-slots {
    display: flex;
    flex-direction: row;
    /* Side by side */
    gap: 0;
    position: relative;
    padding-left: 0;
    /* Reset */
}

.slots-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-width: 0;
    /* Critical for flex child truncation */
    width: 100%;
    /* Ensure it takes available space but no more */
    padding-bottom: 6px;
    /* Align with 222px marker height (216px + 6px) */
}

/* Vertical Discount Tracker */
.discount-tracker {
    position: relative;
    /* Relative within the flex item */
    width: 45px;
    /* Fixed width column */
    flex-shrink: 0;
    margin-right: 8px;
}

.tracker-bar {
    position: absolute;
    top: 0;
    /* Align with top of first slot */
    bottom: 0;
    right: 8px;
    /* Bar line position in column */
    width: 4px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    /* Height calculation: 7 slots = 7*64 + 6*12 = 448 + 72 = 520px */
    height: 520px;
    transition: height 0.3s ease;
    /* Smooth resize */
}

/* Collapsed State (0-2 songs, 3 slots visible) */
.discount-tracker.collapsed .tracker-bar {
    height: 222px;
    /* Bottom of 3rd slot */
}

/* Mid-Collapsed State (3-4 songs, 5 slots visible) */
.discount-tracker.mid-collapsed .tracker-bar {
    height: 368px;
    /* Bottom of 5th slot */
}

/* Expanded State (5+ songs, 7 slots visible) -> Uses default 520px */

.tracker-progress {
    position: absolute;
    top: 0;
    right: 8px;
    width: 4px;
    height: 0%;
    /* JS controlled */
    background: var(--md-sys-color-primary);
    border-radius: 4px;
    transition: height 0.3s ease;
}

.tracker-marker {
    position: absolute;
    right: 18px;
    /* Closer to the bar */
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    white-space: nowrap;
    height: 12px;
    transition: opacity 0.3s ease, top 0.3s ease;
}

/* Visibility Logic for Markers */
/* Collapsed: Hide 25% and 30% */
.discount-tracker.collapsed .marker-25,
.discount-tracker.collapsed .marker-30 {
    opacity: 0;
    pointer-events: none;
}

/* Mid-Collapsed: Hide 30% */
.discount-tracker.mid-collapsed .marker-30 {
    opacity: 0;
    pointer-events: none;
}


.tracker-marker::after {
    content: '';
    position: absolute;
    right: -12px;
    /* Centered on the bar */
    width: 8px;
    height: 8px;
    background: var(--md-sys-color-surface);
    border: 2px solid var(--md-sys-color-on-surface-variant);
    border-radius: 50%;
    z-index: 2;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.tracker-marker.reached::after {
    background: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-primary);
    transform: scale(1.2);
}

.marker-label {
    font-size: 0.65rem;
    /* Smaller size */
    font-weight: 700;
    color: var(--md-sys-color-on-surface-variant);
    opacity: 0.6;
    transition: opacity 0.3s;
    margin-right: 4px;
}

.tracker-marker::before {
    display: none;
}

/* Marker 20% (After 3 slots) */
.marker-20 {
    top: 222px;
}

/* Collapsed: 20% is at bottom */
.discount-tracker.collapsed .marker-20 {
    top: 100%;
}

/* Marker 25% (After 5 slots) */
.marker-25 {
    top: 368px;
}

/* Mid-Collapsed: 25% is at bottom */
.discount-tracker.mid-collapsed .marker-25 {
    top: 100%;
}

/* Marker 30% (After 7 slots) */
.marker-30 {
    top: 520px;
}

/* Marker 30% (After 7 slots) */
.marker-30 {
    top: 520px;
}

/* Base/Default (Blue) is already set by --md-sys-color-primary */

/* Theme Green (25%) */
.discount-tracker.theme-green .tracker-progress {
    background: #2e7d32;
    /* Green 800 */
}

.discount-tracker.theme-green .tracker-marker.reached::after {
    background: #2e7d32;
    border-color: #2e7d32;
}

.discount-tracker.theme-green .tracker-marker.reached .marker-label {
    color: #2e7d32;
}

/* Theme Orange (30%) */
.discount-tracker.theme-orange .tracker-progress {
    background: #e65100;
    /* Orange 900 */
}

.discount-tracker.theme-orange .tracker-marker.reached::after {
    background: #e65100;
    border-color: #e65100;
}

.discount-tracker.theme-orange .tracker-marker.reached .marker-label {
    color: #e65100;
}

.tracker-marker.reached .marker-label {
    color: var(--md-sys-color-primary);
    opacity: 1;
}



.pack-slot {
    height: 64px;
    border-radius: 12px;
    background: var(--md-sys-color-surface-container);
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
    cursor: pointer;
    width: 100%;
    /* Force fit */
    box-sizing: border-box;
    /* Include padding/border in width */
}

.pack-slot.empty {
    border: 2px dashed rgba(0, 0, 0, 0.1);
    background: transparent;
    justify-content: center;
}

.pack-slot.empty:hover {
    background: rgba(0, 0, 0, 0.02);
    border-color: var(--md-sys-color-primary);
    transform: translateY(-1px);
}

.slot-placeholder {
    color: var(--md-sys-color-on-surface-variant);
    opacity: 0.5;
}

.slot-content {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    height: 100%;
    padding-right: 4px;
}

.slot-content.hidden {
    display: none;
}

.slot-thumb {
    width: 64px;
    height: 64px;
    object-fit: cover;
    margin-right: 12px;
}

.slot-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.slot-title {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.slot-price {
    font-size: 0.8rem;
    color: var(--md-sys-color-primary);
    font-weight: 700;
}

.slot-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--md-sys-color-on-surface-variant);
    opacity: 0.7;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.slot-remove:hover {
    background: rgba(0, 0, 0, 0.05);
    opacity: 1;
}

.slot-remove md-icon {
    font-size: 18px;
}

/* Footer */
.pack-footer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    text-align: right;
}

.pack-pricing {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.pricing-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.total-row .label {
    font-size: 1rem;
    font-weight: 600;
}

.price-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.subtotal {
    text-decoration: line-through;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.9rem;
    opacity: 0.7;
}

.subtotal.hidden {
    display: none;
}

.final-price {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--md-sys-color-on-surface);
}

.final-price.discounted {
    color: #1b5e20;
    /* Green for deal */
}

/* Discount Info */
.discount-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    font-size: 0.85rem;
}

.discount-row.hidden {
    display: none;
}

.discount-badge {
    background: #e8f5e9;
    color: #1b5e20;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.savings-text {
    color: #1b5e20;
    font-weight: 500;
}

#pack-buy-btn {
    width: 100%;
}

/* Flyer Animation Class (Fallback/Override) */
.flyer-anim {
    position: fixed;
    z-index: 99999;
    border-radius: 50%;
    background-color: var(--md-sys-color-primary);
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(59, 116, 224, 0.5);
    display: block !important;
}

/* Boost Dropdown Z-Index */
.pack-dropdown {
    z-index: 9999;
}

/* Pulse Highlight for discovery */
@keyframes pulse-highlight {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(59, 116, 224, 0.7);
    }

    50% {
        transform: scale(1.1);
        box-shadow: 0 0 0 15px rgba(59, 116, 224, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(59, 116, 224, 0);
    }
}



/* Extra Slot Animation */
.pack-slot.extra-slot {
    animation: slideDown 0.3s ease-out forwards;
}

.pack-slot.extra-slot.hidden {
    display: none;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .pack-dropdown {
        position: fixed;
        top: 64px;
        /* Below topbar */
        left: 16px;
        right: 16px;
        width: auto;
        max-height: calc(100vh - 80px);
        /* Prevent full height blocking */
        overflow-y: auto;
        /* Scroll if needed */
        margin-top: 0;
        transform-origin: top center;
    }
}