/* ============================================================================
   COLLECTION CONTROLS 2025 - Modern Button System

   Part of PopRace.org 2025 UI Modernization

   Features:
   - Semantic HTML structure with proper ARIA
   - CSS variable-based design system
   - Primary/secondary/tertiary button hierarchy
   - Responsive design (mobile/tablet/desktop)
   - Disabled and loading states
   - Badge component for collection count
   - GPU-accelerated animations
   - Dark mode support
   - Touch-friendly targets (min 44px)

   Browser Support: Chrome 90+, Firefox 88+, Safari 15.4+, Edge 90+
   ============================================================================ */

/* ======================================
   COLLECTION MANAGEMENT BAR
   ====================================== */

.collection-management-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
    background: rgba(30, 58, 95, 0.4);
    border: 2px solid var(--gold);
    border-radius: 0.75rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

/* Mobile: Stack vertically */
@media (max-width: 640px) {
    .collection-management-bar {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.875rem;
    }
}

/* ======================================
   BUTTON GROUP
   ====================================== */

.collection-button-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Mobile: Full width buttons */
@media (max-width: 640px) {
    .collection-button-group {
        width: 100%;
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* ======================================
   COLLECTION COUNT BADGE
   ====================================== */

.collection-count-display {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    background: rgba(15, 30, 46, 0.6);
    border: 2px solid var(--gold);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--cream);
    white-space: nowrap;
}

.collection-count-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #4a6785;
}

.collection-count-value {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 1.75rem;
    padding: 0 0.5rem;
    background: linear-gradient(135deg, var(--gold), var(--bright-gold));
    color: var(--dark-navy);
    font-size: 0.875rem;
    font-weight: 700;
    border-radius: 0.375rem;
    letter-spacing: -0.01em;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(244, 196, 48, 0.3);
}

/* Pulse animation when count changes */
@keyframes collection-count-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.collection-count-value.updated {
    animation: collection-count-pulse 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Empty state (0 models) */
.collection-count-value[data-count="0"] {
    background: rgba(30, 58, 95, 0.6);
    color: #4a6785;
    box-shadow: none;
}

/* Mobile */
@media (max-width: 640px) {
    .collection-count-display {
        width: 100%;
        justify-content: space-between;
        padding: 0.625rem 0.75rem;
    }
}

/* ======================================
   BUTTON BASE STYLES
   ====================================== */

.collection-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.125rem;
    min-height: 2.75rem; /* 44px - touch target */
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    border: 2px solid var(--gold);
    border-radius: 0.5rem;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    transform: translateZ(0); /* GPU acceleration */
    will-change: transform, box-shadow;
}

.collection-btn:focus {
    outline: none;
}

.collection-btn:focus-visible {
    outline: 2px solid var(--bright-gold);
    outline-offset: 2px;
}

/* Icon sizing */
.collection-btn svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

/* Mobile: Full width */
@media (max-width: 640px) {
    .collection-btn {
        width: 100%;
        padding: 0.75rem 1rem;
    }
}

/* ======================================
   BUTTON VARIANTS
   ====================================== */

/* Primary Button - View Collection */
.collection-btn--primary {
    background: linear-gradient(135deg, var(--gold), var(--bright-gold));
    color: var(--dark-navy);
    border-color: var(--gold);
    box-shadow:
        0 4px 12px rgba(244, 196, 48, 0.3),
        0 2px 8px rgba(212, 165, 116, 0.2);
}

.collection-btn--primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--bright-gold), var(--gold));
    box-shadow:
        0 6px 16px rgba(244, 196, 48, 0.4),
        0 3px 10px rgba(212, 165, 116, 0.3);
    transform: translateY(-2px) translateZ(0);
}

.collection-btn--primary:active:not(:disabled) {
    background: linear-gradient(135deg, var(--gold), var(--bright-gold));
    box-shadow:
        0 2px 8px rgba(244, 196, 48, 0.3);
    transform: translateY(0) translateZ(0);
}

/* Secondary Button - Export CSV */
.collection-btn--secondary {
    background: rgba(30, 58, 95, 0.6);
    color: var(--cream);
    border-color: var(--gold);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.collection-btn--secondary:hover:not(:disabled) {
    background: rgba(30, 58, 95, 0.8);
    border-color: var(--bright-gold);
    box-shadow:
        0 4px 12px rgba(244, 196, 48, 0.2),
        0 2px 8px rgba(212, 165, 116, 0.2);
    transform: translateY(-1px) translateZ(0);
}

.collection-btn--secondary:active:not(:disabled) {
    background: rgba(30, 58, 95, 0.6);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transform: translateY(0) translateZ(0);
}

/* Tertiary Button - Compare Models */
.collection-btn--tertiary {
    background: rgba(212, 165, 116, 0.3);
    color: var(--cream);
    border-color: var(--gold);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.collection-btn--tertiary:hover:not(:disabled) {
    background: rgba(212, 165, 116, 0.5);
    border-color: var(--bright-gold);
    box-shadow:
        0 4px 12px rgba(244, 196, 48, 0.2),
        0 2px 8px rgba(212, 165, 116, 0.2);
    transform: translateY(-1px) translateZ(0);
}

.collection-btn--tertiary:active:not(:disabled) {
    background: rgba(212, 165, 116, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transform: translateY(0) translateZ(0);
}

/* ======================================
   BUTTON STATES
   ====================================== */

/* Disabled State */
.collection-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Loading State */
.collection-btn--loading {
    pointer-events: none;
    position: relative;
    color: transparent !important;
}

.collection-btn--loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1rem;
    height: 1rem;
    margin: -0.5rem 0 0 -0.5rem;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: collection-btn-spin 0.6s linear infinite;
}

.collection-btn--primary.collection-btn--loading::after {
    border-color: white;
    border-top-color: transparent;
}

.collection-btn--secondary.collection-btn--loading::after {
    border-color: var(--cream);
    border-top-color: transparent;
}

.collection-btn--tertiary.collection-btn--loading::after {
    border-color: var(--cream);
    border-top-color: transparent;
}

@keyframes collection-btn-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Active/Pressed State */
.collection-btn[aria-pressed="true"] {
    background: linear-gradient(135deg, var(--gold), var(--bright-gold));
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.2);
}

/* ======================================
   BUTTON TEXT - RESPONSIVE
   ====================================== */

.collection-btn-text--full {
    display: inline;
}

.collection-btn-text--short {
    display: none;
}

/* Tablet: Show shortened text */
@media (max-width: 768px) and (min-width: 641px) {
    .collection-btn-text--full {
        display: none;
    }

    .collection-btn-text--short {
        display: inline;
    }
}

/* Mobile: Show full text (buttons are full width) */
@media (max-width: 640px) {
    .collection-btn-text--full {
        display: inline;
    }

    .collection-btn-text--short {
        display: none;
    }
}

/* ======================================
   ACCESSIBILITY
   ====================================== */

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .collection-btn,
    .collection-count-value,
    .collection-management-bar {
        transition: none;
        animation: none;
    }

    .collection-btn:hover:not(:disabled) {
        transform: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .collection-btn {
        border: 2px solid currentColor;
    }

    .collection-btn--primary {
        background: #0000cc;
    }

    .collection-btn--secondary {
        background: white;
        color: #0000cc;
    }
}

/* Focus visible for keyboard navigation */
.collection-btn:focus-visible {
    outline: 3px solid var(--color-primary, #2563eb);
    outline-offset: 3px;
}

/* ======================================
   UTILITY CLASSES
   ====================================== */

/* Hide text, show only icon (for compact view) */
.collection-btn--icon-only .collection-btn-text--full,
.collection-btn--icon-only .collection-btn-text--short {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.collection-btn--icon-only {
    min-width: 2.75rem;
    padding: 0.625rem;
}

/* ======================================
   ANIMATIONS
   ====================================== */

/* Slide in from top on page load */
@keyframes collection-bar-slide-in {
    from {
        opacity: 0;
        transform: translateY(-1rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.collection-management-bar {
    animation: collection-bar-slide-in 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Success feedback animation */
@keyframes collection-success-flash {
    0%, 100% {
        background: var(--color-primary, #2563eb);
    }
    50% {
        background: #10b981; /* Green */
    }
}

.collection-btn--success {
    animation: collection-success-flash 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ======================================
   PRINT STYLES
   ====================================== */

@media print {
    .collection-management-bar {
        display: none;
    }
}
