/**
 * MuzikaPlus Frontend Styles
 *
 * Styles for Elementor widgets and frontend components.
 * Based on FRONTEND_CONTEXT.md design system.
 *
 * @package Muzikaplus
 * @since   1.0.0
 */

/* ===========================================
   CSS CUSTOM PROPERTIES
   =========================================== */
:root {
    /* Backgrounds - Dark Slate with Purple Tint */
    --fe-bg-primary: #1a1a2e;
    --fe-bg-secondary: #16162a;
    --fe-bg-card: #252538;
    --fe-bg-card-hover: #2d2d44;
    --fe-bg-elevated: #1e1e32;
    --fe-bg-input: #202036;

    /* Accent - Orange (Primary Actions) */
    --fe-accent: #f97316;
    --fe-accent-hover: #ea580c;
    --fe-accent-light: #fb923c;
    --fe-accent-glow: rgba(249, 115, 22, 0.25);
    --fe-accent-subtle: rgba(249, 115, 22, 0.1);

    /* Text Colors */
    --fe-text-primary: #ffffff;
    --fe-text-secondary: #b4b4c4;
    --fe-text-muted: #7c7c8a;
    --fe-text-disabled: #4a4a58;

    /* Semantic Colors */
    --fe-success: #22c55e;
    --fe-error: #ef4444;
    --fe-warning: #eab308;
    --fe-info: #3b82f6;

    /* Borders & Dividers */
    --fe-border: #2a2a40;
    --fe-border-light: #3a3a52;
    --fe-divider: #232338;

    /* Spacing Scale */
    --fe-space-1: 0.25rem;
    --fe-space-2: 0.5rem;
    --fe-space-3: 0.75rem;
    --fe-space-4: 1rem;
    --fe-space-5: 1.25rem;
    --fe-space-6: 1.5rem;
    --fe-space-8: 2rem;
    --fe-space-10: 2.5rem;
    --fe-space-12: 3rem;

    /* Border Radius */
    --fe-radius-sm: 4px;
    --fe-radius-md: 8px;
    --fe-radius-lg: 12px;
    --fe-radius-xl: 16px;
    --fe-radius-full: 9999px;

    /* Shadows */
    --fe-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --fe-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --fe-shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
    --fe-shadow-glow: 0 0 30px var(--fe-accent-glow);
    --fe-shadow-card: 0 4px 20px rgba(0, 0, 0, 0.3);

    /* Transitions */
    --fe-transition-fast: 150ms ease;
    --fe-transition-normal: 250ms ease;
    --fe-transition-slow: 350ms ease;

    /* Typography */
    --fe-font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --fe-font-hebrew: 'Heebo', 'Inter', sans-serif;
}

/* ===========================================
   FEATURED PLAYLISTS WIDGET
   =========================================== */

.mf-featured-playlists-widget {
    font-family: var(--fe-font-primary);
}

/* Section Header with Action Bar */
.fe-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--fe-space-6);
    flex-wrap: wrap;
    gap: var(--fe-space-4);
}

.fe-section__title {
    color: var(--fe-text-primary);
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.2;
}

.fe-action-bar {
    display: flex;
    align-items: center;
    gap: var(--fe-space-4);
}

.fe-selection-count {
    color: var(--fe-text-secondary);
    font-size: 0.875rem;
}

.fe-selection-count .fe-count {
    font-weight: 600;
    color: var(--fe-accent);
}

/* ===========================================
   GRID LAYOUT
   =========================================== */

.fe-grid-playlists {
    display: grid;
    grid-template-columns: repeat(var(--columns, 5), 1fr);
    gap: var(--fe-space-6);
}

/* ===========================================
   CARD STYLES
   =========================================== */

.fe-card {
    background: var(--fe-bg-card);
    border-radius: var(--fe-radius-lg);
    overflow: hidden;
    text-decoration: none;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                background 0.3s ease,
                box-shadow 0.3s ease;
    will-change: transform;
    cursor: pointer;
}

.fe-card:hover {
    background: var(--fe-bg-card-hover);
    transform: translateY(-6px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35),
                0 8px 12px rgba(0, 0, 0, 0.22);
}

/* Card Image */
.fe-card__image-wrapper {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
}

.fe-card__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                filter 0.3s ease;
}

.fe-card:hover .fe-card__image {
    transform: scale(1.08);
    filter: brightness(1.05);
}

/* Selection Checkmark Overlay */
.fe-selected-overlay {
    position: absolute;
    top: var(--fe-space-3);
    right: var(--fe-space-3);
    width: 32px;
    height: 32px;
    background: var(--fe-accent);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--fe-shadow-md);
    z-index: 2;
}

.fe-playlist-card.is-selected .fe-selected-overlay {
    display: flex;
    animation: fe-pop-in 0.2s ease-out;
}

@keyframes fe-pop-in {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Card Content */
.fe-card__content {
    padding: var(--fe-space-4);
    text-align: right;
    direction: rtl;
}

.fe-card__title {
    color: var(--fe-text-primary);
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.fe-card__subtitle {
    color: var(--fe-text-secondary);
    font-size: 0.875rem;
    margin: 0 0 8px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.fe-card__meta {
    color: var(--fe-text-muted);
    font-size: 0.75rem;
    display: block;
    margin-bottom: var(--fe-space-3);
}

/* ===========================================
   BUTTONS
   =========================================== */

/* Add to Player Button */
.fe-btn-add-playlist {
    width: 100%;
    padding: var(--fe-space-2) var(--fe-space-4);
    background: transparent;
    border: 1px solid var(--fe-border-light);
    border-radius: var(--fe-radius-full);
    color: var(--fe-text-secondary);
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.25s ease,
                border-color 0.25s ease,
                color 0.25s ease,
                transform 0.15s ease,
                box-shadow 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--fe-space-2);
    position: relative;
    z-index: 10;
    pointer-events: auto !important;
}

.fe-btn-add-playlist:hover {
    background: var(--fe-accent);
    border-color: var(--fe-accent);
    color: var(--fe-bg-primary);
    transform: translateY(-1px);
}

.fe-btn-add-playlist:active {
    transform: scale(0.97) translateY(0);
}

.fe-btn-add-playlist .fe-icon-plus {
    flex-shrink: 0;
    transition: transform 0.25s ease;
}

.fe-btn-add-playlist:hover .fe-icon-plus {
    transform: rotate(90deg);
}

/* Selected State - Add Button */
.fe-playlist-card.is-selected .fe-btn-add-playlist {
    background: var(--fe-accent);
    border-color: var(--fe-accent);
    color: white;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

.fe-playlist-card.is-selected .fe-btn-add-playlist:hover {
    background: var(--fe-accent-hover);
    box-shadow: 0 6px 16px rgba(249, 115, 22, 0.4);
}

/* Selected Card Outline */
.fe-playlist-card.is-selected {
    outline: 2px solid var(--fe-accent);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.15);
}

/* Activate Player Button */
.fe-activate-player {
    padding: var(--fe-space-3) var(--fe-space-6);
    background: var(--fe-accent);
    border: none;
    border-radius: var(--fe-radius-full);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.25s ease,
                transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                box-shadow 0.25s ease,
                opacity 0.3s ease;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

/* Shine effect on hover */
.fe-activate-player::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: left 0.5s ease;
}

.fe-activate-player:not(:disabled):hover::before {
    left: 100%;
}

.fe-activate-player:disabled {
    background: var(--fe-bg-card);
    color: var(--fe-text-muted);
    cursor: not-allowed;
    opacity: 0.7;
}

.fe-activate-player:not(:disabled):hover {
    background: var(--fe-accent-hover);
    box-shadow: 0 8px 24px rgba(249, 115, 22, 0.4),
                0 0 0 3px rgba(249, 115, 22, 0.15);
    transform: translateY(-3px);
}

.fe-activate-player:not(:disabled):active {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

/* ===========================================
   EMPTY STATE
   =========================================== */

.fe-empty-state {
    text-align: center;
    padding: var(--fe-space-12) var(--fe-space-6);
    color: var(--fe-text-muted);
}

.fe-empty-state p {
    margin: 0;
    font-size: 1rem;
}

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

@media (max-width: 1280px) {
    .fe-grid-playlists {
        --columns: 4;
    }
}

@media (max-width: 1024px) {
    .fe-grid-playlists {
        --columns: 3;
    }

    .fe-section__title {
        font-size: 1.25rem;
    }
}

@media (max-width: 768px) {
    .fe-grid-playlists {
        --columns: 2;
        gap: var(--fe-space-4);
    }

    .fe-section__header {
        flex-direction: column;
        align-items: flex-start;
    }

    .fe-action-bar {
        width: 100%;
        justify-content: space-between;
    }

    .fe-activate-player {
        flex: 1;
        text-align: center;
    }

    .fe-card__content {
        padding: var(--fe-space-3);
    }

    .fe-card__title {
        font-size: 0.9375rem;
    }

    .fe-card__subtitle {
        font-size: 0.8125rem;
        -webkit-line-clamp: 1;
    }

    .fe-btn-add-playlist {
        padding: var(--fe-space-2) var(--fe-space-3);
        font-size: 0.8125rem;
    }
}

@media (max-width: 480px) {
    .fe-grid-playlists {
        gap: var(--fe-space-3);
    }

    .fe-activate-player {
        padding: var(--fe-space-2) var(--fe-space-4);
        font-size: 0.9375rem;
    }
}

/* ===========================================
   RTL SUPPORT (Hebrew)
   =========================================== */

[dir="rtl"] .mf-featured-playlists-widget {
    font-family: var(--fe-font-hebrew);
}

[dir="rtl"] .fe-card__meta {
    direction: ltr;
    unicode-bidi: isolate;
}

[dir="rtl"] .fe-selected-overlay {
    right: auto;
    left: var(--fe-space-3);
}

[dir="rtl"] .fe-btn-add-playlist {
    flex-direction: row-reverse;
}

/* ===========================================
   ELEMENTOR EDITOR FIXES
   =========================================== */

.elementor-editor-active .fe-activate-player:disabled {
    pointer-events: none;
}

/* Preview placeholder styling */
.elementor-editor-preview .fe-card__image[style*="background"] {
    display: flex !important;
}

/* ===========================================
   OVERRIDE REDUCED MOTION FOR WIDGET
   =========================================== */

/* Re-enable transitions for MuzikaPlus widget */
@media (prefers-reduced-motion: reduce) {
    .mf-featured-playlists-widget,
    .mf-featured-playlists-widget * {
        transition-duration: 0.25s !important;
        transition-delay: 0s !important;
    }
}
