/* ========================================
   PREMIUM FILTER CHIPS SYSTEM
   Frosted glass chips with smooth animations
   Matches existing design language
   ======================================== */

/* Chip Container */
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
    min-height: 42px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(6px);
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    align-items: center;
}

/* Subtle category color glow */
.filter-chips::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--category-primary);
    opacity: 0.06;
    border-radius: inherit;
    pointer-events: none;
    transition: opacity 0.6s ease;
}

/* Empty state styling */
.filter-chips:empty {
    min-height: 0;
    padding: 0;
    margin-bottom: 0;
    border: none;
    background: transparent;
    backdrop-filter: none;
}

.filter-chips:empty::before {
    display: none;
}

/* Individual Chip */
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 8px 16px;

    /* Frosted glass effect */
    background: rgba(61, 90, 128, 0.85);
    backdrop-filter: blur(9px) saturate(120%);
    -webkit-backdrop-filter: blur(9px) saturate(120%);

    /* Borders and shadows */
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    box-shadow:
        0 6px 18px rgba(61, 90, 128, 0.15),
        0 2px 6px rgba(44, 44, 44, 0.09),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);

    /* Typography */
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.9em;
    font-weight: 600;
    color: white;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 3px rgba(44, 44, 44, 0.18);

    /* Animation */
    cursor: default;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: chipAppear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    z-index: 1;
    user-select: none;
}

/* Chip hover state */
.filter-chip:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow:
        0 10px 24px rgba(61, 90, 128, 0.21),
        0 4px 10px rgba(44, 44, 44, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* Chip text */
.filter-chip-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* Remove button - nearly invisible by default, reveals on chip hover */
.filter-chip-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: transparent;
    color: transparent;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.25s cubic-bezier(0.4, 0, 0.2, 1), color 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    box-shadow: none;
}

.filter-chip:hover .filter-chip-remove {
    color: #9ca3af;
    background: rgba(44, 44, 44, 0.06);
}

.filter-chip-remove:hover {
    background: rgba(255, 255, 255, 0.95);
    color: #2C4A6E;
    transform: scale(1.15) rotate(90deg);
    box-shadow: 0 3px 10px rgba(44, 44, 44, 0.15);
}

.filter-chip-remove:active {
    transform: scale(0.95) rotate(90deg);
}

/* Appear animation */
@keyframes chipAppear {
    from {
        opacity: 0;
        transform: scale(0.7) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Disappear animation */
@keyframes chipDisappear {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.7) translateY(-10px);
    }
}

.filter-chip.removing {
    animation: chipDisappear 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Textbook chips - orange/gold gradient */
.filter-chip.textbook-chip {
    background: rgba(251, 188, 5, 0.9);
    box-shadow:
        0 6px 18px rgba(251, 188, 5, 0.18),
        0 2px 6px rgba(44, 44, 44, 0.09),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.filter-chip.textbook-chip:hover {
    box-shadow:
        0 10px 24px rgba(251, 188, 5, 0.24),
        0 4px 10px rgba(44, 44, 44, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* Lesson chips - JP accent gradient */
.filter-chip.lesson-chip {
    background: rgba(61, 90, 128, 0.85);
    box-shadow:
        0 6px 18px rgba(61, 90, 128, 0.15),
        0 2px 6px rgba(44, 44, 44, 0.09),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.filter-chip.lesson-chip:hover {
    box-shadow:
        0 10px 24px rgba(61, 90, 128, 0.21),
        0 4px 10px rgba(44, 44, 44, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* Clear all button */
.filter-clear-all {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(44, 44, 44, 0.08);
    border-radius: 18px;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.85em;
    font-weight: 500;
    color: #57534e;  /* Warm stone — visible on light background */
    cursor: pointer;
    transition: background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-left: auto;
}

.filter-clear-all:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(44, 44, 44, 0.12);
    color: #2C2C2C;  /* Darker on hover */
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(44, 44, 44, 0.09);
}

.filter-clear-all:active {
    transform: translateY(0) scale(0.98);
}

/* Hide clear button when no chips */
.filter-chips:empty + .filter-clear-all {
    display: none;
}

/* Update dropdown styling when chips are present */
.filter-group:has(.filter-chips:not(:empty)) .premium-select {
    border-color: rgba(61, 90, 128, 0.4);
    box-shadow: 0 0 0 3px rgba(61, 90, 128, 0.05);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .filter-chip {
        font-size: 0.85em;
        padding: 6px 10px 6px 14px;
    }

    .filter-chip-text {
        max-width: 150px;
    }

    .filter-chip-remove {
        width: 18px;
        height: 18px;
        min-width: 44px;
        min-height: 44px;
        padding: 13px;
        margin: -13px;
        font-size: 12px;
        position: relative;
    }
}

/* Accessibility */
.filter-chip:focus-within {
    outline: 2px solid rgba(61, 90, 128, 0.6);
    outline-offset: 2px;
}

.filter-chip-remove:focus {
    outline: 2px solid white;
    outline-offset: 1px;
}

/* Smooth word count badge pulse when filters change */
@keyframes filterPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.08);
    }
}

.word-count-badge.pulse {
    animation: filterPulse 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
