/**
 * PopRace.org - Modern View Density Controls (2025 Standards)
 *
 * Features:
 * - Segmented control design
 * - Icon-based navigation
 * - Smooth transitions
 * - Touch-friendly sizing
 * - Accessibility-first
 */

/* ============================================
   VIEW DENSITY CONTROLS CONTAINER
   ============================================ */

.view-density-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem;
    background: rgba(30, 58, 95, 0.4);
    border-radius: 0.75rem;
    border: 2px solid var(--gold, var(--gold));
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

/* ============================================
   VIEW DENSITY BUTTONS
   ============================================ */

.view-density-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    height: 2.5rem;
    padding: 0 0.75rem;
    background: transparent;
    border: none;
    border-radius: 0.5rem;
    color: var(--text-muted, #4a6785);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    user-select: none;
}

/* Hover State */
.view-density-btn:hover:not(.active) {
    background: rgba(212, 165, 116, 0.2);
    color: var(--cream, var(--cream));
    transform: translateY(-1px);
}

/* Active State */
.view-density-btn.active {
    background: linear-gradient(135deg, var(--gold, var(--gold)), var(--bright-gold, var(--bright-gold)));
    color: var(--dark-navy, var(--dark-navy));
    box-shadow:
        0 4px 12px rgba(244, 196, 48, 0.4),
        0 2px 8px rgba(212, 165, 116, 0.3);
    font-weight: 600;
}

/* Focus State */
.view-density-btn:focus-visible {
    outline: 2px solid var(--bright-gold, var(--bright-gold));
    outline-offset: 2px;
}

/* ============================================
   ICON STYLING
   ============================================ */

.view-density-btn svg {
    width: 1.125rem;
    height: 1.125rem;
    transition: transform 0.2s ease;
}

.view-density-btn:hover svg {
    transform: scale(1.1);
}

.view-density-btn.active svg {
    transform: scale(1.05);
}

/* ============================================
   BUTTON TEXT (OPTIONAL)
   ============================================ */

.view-density-btn-text {
    margin-left: 0.375rem;
    font-size: 0.8125rem;
}

/* Hide text on small screens */
@media (max-width: 640px) {
    .view-density-btn-text {
        display: none;
    }

    .view-density-btn {
        min-width: 2.25rem;
        height: 2.25rem;
        padding: 0 0.5rem;
    }

    .view-density-controls {
        padding: 0.25rem;
    }
}

/* ============================================
   TOOLTIP (for icon-only buttons)
   ============================================ */

.view-density-btn[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 0.5rem);
    left: 50%;
    transform: translateX(-50%);
    padding: 0.375rem 0.75rem;
    background: var(--color-surface, #0f172a);
    color: white;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    border-radius: var(--radius-md, 0.375rem);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 50;
    pointer-events: none;
    animation: tooltip-fade-in 0.2s ease;
}

.view-density-btn[title]:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 0.125rem);
    left: 50%;
    transform: translateX(-50%);
    border: 0.375rem solid transparent;
    border-top-color: var(--color-surface, #0f172a);
    z-index: 50;
    pointer-events: none;
    animation: tooltip-fade-in 0.2s ease;
}

@keyframes tooltip-fade-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Disable tooltips on mobile */
@media (max-width: 640px) {
    .view-density-btn[title]:hover::after,
    .view-density-btn[title]:hover::before {
        display: none;
    }
}

/* ============================================
   LOADING STATE
   ============================================ */

.view-density-controls.loading {
    pointer-events: none;
    opacity: 0.6;
}

.view-density-controls.loading .view-density-btn {
    cursor: wait;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Mobile - Stack vertically on very small screens */
@media (max-width: 480px) {
    .view-density-controls {
        flex-direction: row;
        justify-content: center;
        width: 100%;
    }

    .view-density-btn {
        flex: 1;
    }
}

/* ============================================
   COMPACT VARIANT
   ============================================ */

.view-density-controls.compact {
    padding: 0.25rem;
    gap: 0.25rem;
}

.view-density-controls.compact .view-density-btn {
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
}

.view-density-controls.compact .view-density-btn svg {
    width: 1rem;
    height: 1rem;
}

/* ============================================
   PILL VARIANT (Alternative Style)
   ============================================ */

.view-density-controls.pill {
    border-radius: var(--radius-full, 9999px);
    padding: 0.25rem;
}

.view-density-controls.pill .view-density-btn {
    border-radius: var(--radius-full, 9999px);
}

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

/* High contrast mode support */
@media (prefers-contrast: high) {
    .view-density-btn {
        border: 1px solid currentColor;
    }

    .view-density-btn.active {
        border-width: 2px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .view-density-btn,
    .view-density-btn svg,
    .view-density-controls {
        transition: none !important;
        animation: none !important;
    }

    .view-density-btn:hover {
        transform: none;
    }

    .view-density-btn:hover svg {
        transform: none;
    }
}

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

@media print {
    .view-density-controls {
        display: none !important;
    }
}

/* ============================================
   ADDITIONAL CONTROL ELEMENTS
   ============================================ */

/* View count indicator */
.view-count {
    padding: 0 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text-secondary, #94a3b8);
    white-space: nowrap;
}

/* Separator */
.view-separator {
    width: 1px;
    height: 1.5rem;
    background: var(--color-border, #334155);
}

/* ============================================
   INTEGRATION WITH FILTER BAR
   ============================================ */

/* When placed in a filter/toolbar */
.filter-toolbar .view-density-controls {
    margin-left: auto; /* Push to right side */
}

/* ============================================
   ANIMATION UTILITIES
   ============================================ */

@keyframes view-change-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(0.98);
        opacity: 0.9;
    }
}

.view-changing .view-density-btn.active {
    animation: view-change-pulse 0.3s ease;
}
