/* ========================================
   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: linear-gradient(135deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.04) 100%);
    backdrop-filter: blur(10px);
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: all 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: linear-gradient(135deg, var(--category-primary), var(--category-secondary));
    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: linear-gradient(135deg,
        rgba(102, 126, 234, 0.85) 0%,
        rgba(118, 75, 162, 0.85) 100%);
    backdrop-filter: blur(15px) saturate(120%);
    -webkit-backdrop-filter: blur(15px) saturate(120%);

    /* Borders and shadows */
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    box-shadow:
        0 6px 18px rgba(102, 126, 234, 0.25),
        0 2px 6px rgba(0, 0, 0, 0.15),
        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(0, 0, 0, 0.3);

    /* Animation */
    cursor: default;
    transition: all 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(102, 126, 234, 0.35),
        0 4px 10px rgba(0, 0, 0, 0.2),
        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 */
.filter-chip-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    color: white;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

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

.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: linear-gradient(135deg,
        rgba(251, 188, 5, 0.9) 0%,
        rgba(255, 152, 0, 0.9) 100%);
    box-shadow:
        0 6px 18px rgba(251, 188, 5, 0.3),
        0 2px 6px rgba(0, 0, 0, 0.15),
        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.4),
        0 4px 10px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* Lesson chips - pink/red gradient */
.filter-chip.lesson-chip {
    background: linear-gradient(135deg,
        rgba(240, 147, 251, 0.85) 0%,
        rgba(245, 87, 108, 0.85) 100%);
    box-shadow:
        0 6px 18px rgba(240, 147, 251, 0.25),
        0 2px 6px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.filter-chip.lesson-chip:hover {
    box-shadow:
        0 10px 24px rgba(240, 147, 251, 0.35),
        0 4px 10px rgba(0, 0, 0, 0.2),
        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.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 18px;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.85em;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-left: auto;
}

.filter-clear-all:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.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(102, 126, 234, 0.4);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.08);
}

/* 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;
        font-size: 12px;
    }
}

/* Dark mode adjustments */
body.dark-mode .filter-chips {
    background: linear-gradient(135deg, rgba(0,0,0,0.25) 0%, rgba(0,0,0,0.15) 100%);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .filter-chip {
    box-shadow:
        0 6px 18px rgba(102, 126, 234, 0.2),
        0 2px 6px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

body.dark-mode .filter-clear-all {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.85);
}

/* Accessibility */
.filter-chip:focus-within {
    outline: 2px solid rgba(102, 126, 234, 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);
}
