/**
 * Edizioni AI - Frontend Styles
 */

/* Widget */
.eai-widget {
    position: relative !important;
    max-width: 100% !important;
}

/* Spot Progress Bar (Yellow) */
.eai-spot-progress {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 4px !important;
    background: rgba(0, 0, 0, 0.5) !important;
    z-index: 20 !important;
}

.eai-spot-progress-bar {
    height: 100% !important;
    background: #fbbf24 !important;
    width: 0 !important;
    transition: width 0.1s linear !important;
}

.eai-spot-label {
    position: absolute !important;
    bottom: 14px !important;
    left: 12px !important;
    font-size: 11px !important;
    color: #fbbf24 !important;
    text-transform: uppercase !important;
    font-weight: 700 !important;
    letter-spacing: 0.05em !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    z-index: 21 !important;
}

/* Spot Overlay - copre solo la barra controlli in basso per impedire seek/skip */
.eai-spot-overlay {
    display: none !important;
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 50px !important;
    z-index: 15 !important;
    cursor: not-allowed !important;
}

/* Inline Player */
.eai-inline-player {
    position: relative !important;
    aspect-ratio: 16/9 !important;
    background: #000 !important;
    border-radius: 0 !important;
    overflow: hidden !important;
}

.eai-inline-player iframe {
    width: 100% !important;
    height: 100% !important;
    border: 0 !important;
}

/* Custom Play Button Overlay */
.eai-play-overlay {
    position: absolute !important;
    inset: 0 !important;
    z-index: 25 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    background: rgba(0, 0, 0, 0.15) !important;
    transition: background 0.2s ease !important;
}

.eai-play-overlay:hover {
    background: rgba(0, 0, 0, 0.25) !important;
}

.eai-play-overlay .eai-play-btn {
    width: 72px !important;
    height: 72px !important;
    background: rgba(255, 255, 255, 0.92) !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3) !important;
    transition: transform 0.2s ease, background 0.2s ease !important;
}

.eai-play-overlay:hover .eai-play-btn {
    transform: scale(1.08) !important;
    background: #fff !important;
}

.eai-play-overlay .eai-play-btn svg {
    width: 32px !important;
    height: 32px !important;
    margin-left: 4px !important;
}

/* Nasconde play overlay quando il widget è espanso (modale) */
.eai-widget-inline.eai-expanded .eai-play-overlay {
    display: none !important;
}

/* Nasconde spot overlay/progress vecchi in modalità espansa (no controlli nativi) */
.eai-widget-inline.eai-expanded .eai-spot-overlay,
.eai-widget-inline.eai-expanded .eai-spot-progress {
    display: none !important;
}

/* ============================================================
   CUSTOM VIDEO CONTROLS - Solo visibili in modalità modale
   ============================================================ */

/* Interaction overlay (trasparente, cattura mouse/touch sopra iframe) */
.eai-controls-interaction {
    display: none !important;
    position: absolute !important;
    inset: 0 !important;
    z-index: 26 !important;
    cursor: pointer !important;
    background: transparent !important;
}

.eai-widget-inline.eai-expanded .eai-controls-interaction {
    display: block !important;
}

/* Center play/pause button */
.eai-center-playpause {
    display: none !important;
    position: absolute !important;
    inset: 0 !important;
    z-index: 30 !important;
    align-items: center !important;
    justify-content: center !important;
    pointer-events: none !important;
    opacity: 1 !important;
    transition: opacity 0.3s ease !important;
}

.eai-widget-inline.eai-expanded .eai-center-playpause {
    display: flex !important;
}

.eai-center-playpause.eai-controls-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
}

.eai-center-playpause-btn {
    width: 64px !important;
    height: 64px !important;
    background: rgba(0, 0, 0, 0.55) !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #fff !important;
    pointer-events: auto !important;
    cursor: pointer !important;
    transition: background 0.2s ease, transform 0.15s ease !important;
}

.eai-center-playpause-btn:hover {
    background: rgba(0, 0, 0, 0.7) !important;
    transform: scale(1.08) !important;
}

.eai-center-playpause-btn svg {
    width: 28px !important;
    height: 28px !important;
}

.eai-center-playpause .eai-icon-pause,
.eai-center-playpause.is-playing .eai-icon-play {
    display: none !important;
}

.eai-center-playpause.is-playing .eai-icon-pause {
    display: block !important;
}

/* Bottom controls bar */
.eai-bottom-controls {
    display: none !important;
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 31 !important;
    height: 44px !important;
    padding: 0 12px !important;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.75)) !important;
    align-items: center !important;
    gap: 10px !important;
    opacity: 1 !important;
    transition: opacity 0.3s ease !important;
    pointer-events: auto !important;
}

.eai-widget-inline.eai-expanded .eai-bottom-controls {
    display: flex !important;
}

.eai-bottom-controls.eai-controls-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Small play/pause button in bottom bar */
.eai-ctrl-playpause {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    color: #fff !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    border-radius: 4px !important;
    transition: background 0.15s ease !important;
}

.eai-ctrl-playpause:hover {
    background: rgba(255, 255, 255, 0.15) !important;
}

.eai-ctrl-playpause:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3) !important;
}

.eai-ctrl-playpause svg {
    width: 20px !important;
    height: 20px !important;
}

.eai-bottom-controls .eai-icon-pause,
.eai-bottom-controls.is-playing .eai-icon-play {
    display: none !important;
}

.eai-bottom-controls.is-playing .eai-icon-pause {
    display: block !important;
}

/* Time labels */
.eai-ctrl-time {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, monospace;
    font-size: 13px !important;
    color: #fff !important;
    line-height: 1 !important;
    flex-shrink: 0 !important;
    user-select: none !important;
    min-width: 34px !important;
    text-align: center !important;
}

/* Spot label in bottom controls - visibile solo durante spot */
.eai-ctrl-spot-label {
    display: none !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 11px !important;
    font-weight: 700 !important;
    color: #fbbf24 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.08em !important;
    line-height: 1 !important;
    flex-shrink: 0 !important;
    user-select: none !important;
    padding: 2px 6px !important;
    background: rgba(251, 191, 36, 0.15) !important;
    border: 1px solid rgba(251, 191, 36, 0.4) !important;
    border-radius: 3px !important;
}

.eai-bottom-controls.is-spot-mode .eai-ctrl-spot-label {
    display: inline-flex !important;
}

/* Seek bar */
.eai-ctrl-seekbar {
    flex: 1;
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
    cursor: pointer !important;
    position: relative !important;
}

.eai-ctrl-seekbar-track {
    width: 100% !important;
    height: 4px !important;
    background: rgba(255, 255, 255, 0.3) !important;
    border-radius: 2px !important;
    position: relative !important;
    overflow: hidden !important;
    transition: height 0.15s ease !important;
}

.eai-ctrl-seekbar:hover .eai-ctrl-seekbar-track {
    height: 6px !important;
}

.eai-ctrl-seekbar-fill {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    height: 100% !important;
    width: 0%;
    background: #fff !important;
    border-radius: 2px !important;
    transition: width 0.1s linear !important;
}

/* Seek bar disabled during spot */
.eai-ctrl-seekbar.is-spot-active {
    cursor: not-allowed !important;
}

.eai-ctrl-seekbar.is-spot-active .eai-ctrl-seekbar-track {
    background: rgba(255, 255, 255, 0.12) !important;
}

.eai-ctrl-seekbar.is-spot-active .eai-ctrl-seekbar-fill {
    background: #fbbf24 !important;
    box-shadow: 0 0 6px rgba(251, 191, 36, 0.5) !important;
}

/* Expandable: backdrop e close button nascosti di default */
.eai-expand-backdrop {
    display: none !important;
}

.eai-expand-close {
    display: none !important;
}

/* Expandable: quando il widget è espanso, diventa visivamente un modale */
.eai-widget-inline.eai-expanded {
    position: fixed !important;
    inset: 0 !important;
    z-index: 999999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    max-width: none !important;
    border-radius: 0 !important;
    animation: eai-fadeIn 0.2s ease !important;
}

@keyframes eai-fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.eai-widget-inline.eai-expanded .eai-expand-backdrop {
    display: block !important;
    position: absolute !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.92) !important;
    z-index: 0 !important;
}

.eai-widget-inline.eai-expanded .eai-inline-player {
    position: relative !important;
    z-index: 1 !important;
    width: 100% !important;
    max-width: min(1200px, 90vw) !important;
    max-height: 90vh !important;
    border-radius: 12px !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
    animation: eai-slideUp 0.3s ease !important;
}

@keyframes eai-slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.eai-widget-inline.eai-expanded .eai-expand-close {
    display: flex !important;
    position: absolute !important;
    z-index: 2 !important;
    top: 16px !important;
    right: 16px !important;
    width: 44px !important;
    height: 44px !important;
    border: none !important;
    background: rgba(0, 0, 0, 0.6) !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.2s ease, transform 0.15s ease !important;
    padding:0px !important;
}

.eai-widget-inline.eai-expanded .eai-expand-close:hover {
    background: rgba(0, 0, 0, 0.8) !important;
    transform: scale(1.08) !important;
}

.eai-widget-inline.eai-expanded .eai-expand-close:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4) !important;
}

.eai-widget-inline.eai-expanded .eai-expand-close svg {
    width: 22px !important;
    height: 22px !important;
    stroke: #fff !important;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

/* La X usa stroke="currentColor" sul <path>: l'attributo di presentazione vince
   sull'ereditarietà dello stroke dall'<svg>, quindi forziamo il bianco sul path
   (altrimenti resta nera su sfondo nero). */
.eai-widget-inline.eai-expanded .eai-expand-close svg path {
    stroke: #fff !important;
}

/* Empty State */
.eai-widget-empty {
    padding: 40px 20px !important;
    text-align: center !important;
    background: #f5f5f5 !important;
    border-radius: 8px !important;
    color: #666 !important;
    font-size: 14px !important;
}

/* Loading State */
.eai-player-loading {
    position: absolute !important;
    inset: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #000 !important;
}

.eai-player-loading::after {
    content: '';
    width: 40px !important;
    height: 40px !important;
    border: 3px solid rgba(255, 255, 255, 0.2) !important;
    border-top-color: #fff !important;
    border-radius: 50% !important;
    animation: eai-spin 0.8s linear infinite !important;
}

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

/* Responsive */
@media (max-width: 768px) {
    .eai-widget-inline.eai-expanded .eai-inline-player {
        border-radius: 8px !important;
    }

    .eai-widget-inline.eai-expanded .eai-expand-close {
        top: 10px !important;
        right: 10px !important;
        width: 40px !important;
        height: 40px !important;
    }

    .eai-play-overlay .eai-play-btn {
        width: 56px !important;
        height: 56px !important;
    }

    .eai-play-overlay .eai-play-btn svg {
        width: 24px !important;
        height: 24px !important;
        margin-left: 3px !important;
    }

    .eai-center-playpause-btn {
        width: 52px !important;
        height: 52px !important;
    }

    .eai-center-playpause-btn svg {
        width: 24px !important;
        height: 24px !important;
    }

    .eai-bottom-controls {
        height: 40px !important;
        padding: 0 8px !important;
        gap: 8px !important;
    }

    .eai-ctrl-playpause {
        width: 36px !important;
        height: 36px !important;
    }

    .eai-ctrl-time {
        font-size: 12px !important;
    }

    .eai-ctrl-seekbar {
        height: 36px !important;
    }

    .eai-ctrl-spot-label {
        font-size: 10px !important;
        padding: 1px 4px !important;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .eai-spot-progress-bar,
    .eai-widget-inline.eai-expanded,
    .eai-widget-inline.eai-expanded .eai-inline-player,
    .eai-play-overlay,
    .eai-play-overlay .eai-play-btn,
    .eai-center-playpause,
    .eai-center-playpause-btn,
    .eai-bottom-controls,
    .eai-ctrl-seekbar-track,
    .eai-ctrl-seekbar-fill {
        animation: none !important;
        transition: none !important;
    }
}
