/* ###########################################################
   ###   2418521        Antony O'Neill                     ###
   ###   TEMPUS PRIVÉ - FILTER COUNTS STYLING MODULE       ###
   ###   Last Updated: 02-07-2025                          ###
   ########################################################### */

/*
===============================================
Dynamic count badges for product category filters
Animations and visual feedback for filter updates
Integrated with filter-counts.js for real-time updates
===============================================
*/

/* ###########################################################
   ###   1. Base Count Styling                             ###
   ########################################################### */

/* ====== Base Count Badge ====== */
.tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: inherit;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

/* Active filter tab count */
.filter-tab.active .tab-count {
    background: var(--imperial-gold);
    color: var(--crown-navy);
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.3);
}

/* Hover state */
.filter-tab:hover .tab-count {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.3);
}

/* ###########################################################
   ###   2. Count Update Animations                        ###
   ########################################################### */

/* ====== Animation Classes ====== */

/* Base animation class */
.count-updating {
    animation: countPulse 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Count increased animation */
.count-increased {
    animation: countIncrease 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Count decreased animation */
.count-decreased {
    animation: countDecrease 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Badge pulse animation */
.badge-pulse {
    animation: badgePulse 0.3s ease-out;
}

/* Badge active state */
.badge-active {
    animation: badgeActive 0.2s ease-out;
}

/* ====== Keyframe Definitions ====== */

@keyframes countPulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes countIncrease {
    0% {
        transform: scale(1) translateY(0);
        color: inherit;
    }
    50% {
        transform: scale(1.3) translateY(-2px);
        color: var(--success-green, #10B981);
    }
    100% {
        transform: scale(1) translateY(0);
        color: inherit;
    }
}

@keyframes countDecrease {
    0% {
        transform: scale(1) translateY(0);
        color: inherit;
    }
    50% {
        transform: scale(0.9) translateY(2px);
        color: var(--error-red, #EF4444);
    }
    100% {
        transform: scale(1) translateY(0);
        color: inherit;
    }
}

@keyframes badgePulse {
    0% {
        box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(212, 175, 55, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(212, 175, 55, 0);
    }
}

@keyframes badgeActive {
    0% {
        background: rgba(212, 175, 55, 0.2);
    }
    50% {
        background: var(--imperial-gold);
    }
    100% {
        background: rgba(255, 255, 255, 0.2);
    }
}

/* ###########################################################
   ###   3. Special States                                 ###
   ########################################################### */

/* ====== Loading State ====== */
.tab-count.loading {
    background: rgba(255, 255, 255, 0.1);
    color: transparent;
    position: relative;
}

.tab-count.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--imperial-gold);
    border-radius: 50%;
    animation: countLoading 0.8s linear infinite;
}

@keyframes countLoading {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ====== Zero Count Styling ====== */
.tab-count[data-count="0"] {
    opacity: 0.6;
    background: rgba(255, 255, 255, 0.1);
}

/* ====== High Count Styling ====== */
/* Emphasis for categories with 10+ items */
.tab-count[data-count="10"],
.tab-count[data-count="11"],
.tab-count[data-count="12"],
.tab-count[data-count="13"],
.tab-count[data-count="14"],
.tab-count[data-count="15"],
.tab-count[data-count="16"] {
    background: var(--imperial-gold);
    color: var(--crown-navy);
    font-weight: 700;
}

/* ###########################################################
   ###   4. Admin Panel Integration                        ###
   ########################################################### */

/* ====== Admin Badge Styling ====== */
.admin-stat-badge {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: rgba(212, 175, 55, 0.2);
    color: var(--imperial-gold);
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.admin-stat-badge.updating {
    animation: adminBadgeUpdate 0.5s ease-out;
}

@keyframes adminBadgeUpdate {
    0% { 
        background: rgba(212, 175, 55, 0.2);
        transform: scale(1);
    }
    50% { 
        background: var(--imperial-gold);
        color: var(--crown-navy);
        transform: scale(1.1);
    }
    100% { 
        background: rgba(212, 175, 55, 0.2);
        transform: scale(1);
    }
}


/* ###########################################################
   ###   5. Responsive optimisations                       ###
   ########################################################### */

/* ====== Mobile optimisations ====== */
@media (max-width: 768px) {
    .tab-count {
        min-width: 20px;
        height: 20px;
        font-size: 0.75rem;
        padding: 0 4px;
    }
    
    /* Disable complex animations on mobile for performance */
    .count-updating,
    .count-increased,
    .count-decreased {
        animation: none;
        transition: color 0.2s ease;
    }
}

/* ====== Reduced Motion Support ====== */
@media (prefers-reduced-motion: reduce) {
    .tab-count,
    .count-updating,
    .count-increased,
    .count-decreased,
    .badge-pulse,
    .badge-active {
        animation: none !important;
        transition: none !important;
    }
    
    /* Simple colour change for updates */
    .count-updating {
        color: var(--imperial-gold);
    }
}

/* ====== High Contrast Mode ====== */
@media (prefers-contrast: high) {
    .tab-count {
        border: 2px solid currentColor;
        font-weight: 700;
    }
    
    .filter-tab.active .tab-count {
        background: white;
        color: black;
        border-color: black;
    }
}

/* ###########################################################
   ###            END OF FILTER COUNTS STYLES              ###
   ########################################################### */
