/**
 * TXAPlayer Styles
 * Glassmorphism design with modern UI
 */

/* ==================== Base Player Styles ==================== */
.txa-player {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    overscroll-behavior-x: none;
}

/* ==================== Video Container ==================== */
.txa-video-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.txa-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ==================== Ambient Light ==================== */
.txa-ambient-light {
    position: absolute;
    top: 0;
    left: 0;
    width: 50px;
    height: 50px;
    pointer-events: none;
    opacity: 0;
}

/* ==================== Subtitle Overlay ==================== */
.txa-subtitle-overlay {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 80%;
    text-align: center;
    color: #fff;
    font-size: 24px;
    font-weight: 600;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.9);
    pointer-events: none;
    z-index: 10;
    line-height: 1.4;
    transition: bottom 0.3s ease;
}

.txa-controls.visible~.txa-subtitle-overlay {
    bottom: 100px;
}

/* ==================== Branding ==================== */
.txa-branding {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    opacity: 0.8;
    transition: opacity 0.3s ease;
    z-index: 5;
    pointer-events: none;
}

.txa-branding.playing {
    opacity: 0.3;
}

.txa-branding.visible {
    opacity: 0.8;
}

.txa-logo {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}

/* ==================== Loading Spinner ==================== */
.txa-loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    z-index: 20;
    pointer-events: none;
}

.txa-loading-spinner.active {
    display: block;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==================== Play Overlay ==================== */
.txa-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 15;
    pointer-events: none;
}

.txa-play-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.txa-big-play-btn {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.txa-big-play-btn svg {
    width: 32px;
    height: 32px;
    color: #6366f1;
    margin-left: 4px;
}

.txa-big-play-btn:hover {
    transform: scale(1.1);
    background: #fff;
}

/* ==================== Controls ==================== */
.txa-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, transparent 100%);
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 25;
}

.txa-controls.visible {
    opacity: 1;
    visibility: visible;
}

/* Progress Bar */
.txa-progress-container {
    position: relative;
    width: 100%;
    height: 6px;
    margin-bottom: 20px;
    cursor: pointer;
    touch-action: none;
}

.txa-progress-bar {
    position: relative;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: visible;
    /* To see handle */
    transition: height 0.1s ease;
}

.txa-progress-container:hover .txa-progress-bar {
    height: 8px;
}

.txa-progress-buffer {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
    transition: width 0.1s linear;
    border-radius: 3px;
}

.txa-progress-played {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    transition: width 0.05s linear;
    border-radius: 3px;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

.txa-progress-handle {
    position: absolute;
    top: 50%;
    right: -7px;
    /* Adjust based on width/2 */
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    transform: translateY(-50%) scale(0);
    transition: transform 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    z-index: 2;
}

.txa-progress-container:hover .txa-progress-handle,
.txa-progress-container.dragging .txa-progress-handle {
    transform: translateY(-50%) scale(1);
}

.txa-progress-tooltip {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
    font-weight: 500;
}

.txa-progress-container:hover .txa-progress-tooltip {
    opacity: 1;
    visibility: visible;
    bottom: 15px;
}

/* Controls Row */
.txa-controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.txa-controls-left,
.txa-controls-right {
    display: flex;
    align-items: center;
    gap: 15px;
    /* Increased gap */
}

/* Time Display */
.txa-time {
    display: flex;
    align-items: center;
    gap: 5px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
    min-width: 110px;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
}

.txa-time-separator {
    opacity: 0.5;
    font-size: 12px;
}

/* Buttons */
.txa-btn {
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    border-radius: 8px;
    /* Square with rounded corners looks better */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: rgba(255, 255, 255, 0.9);
    position: relative;
    overflow: hidden;
}

.txa-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    transform: translateY(-2px);
}

.txa-btn:active {
    transform: translateY(0);
}

.txa-btn svg {
    width: 24px;
    height: 24px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.txa-btn-play .icon-pause {
    display: none;
}

.txa-btn-play.playing .icon-play {
    display: none;
}

.txa-btn-play.playing .icon-pause {
    display: block;
}

/* Vertical Volume Control */
.txa-volume-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
}

.txa-volume-slider {
    position: absolute;
    bottom: 50px;
    /* Hiển thị phía trên nút volume */
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 0;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    padding: 10px 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    z-index: 50;
}

.txa-volume-container:hover .txa-volume-slider {
    height: 150px;
    opacity: 1;
    visibility: visible;
    bottom: 55px;
}

.txa-volume-input {
    width: 110px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    cursor: pointer;
    outline: none;
    transform: rotate(-90deg);
    /* Xoay dọc slider */
    margin: 55px 0;
}

.txa-volume-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s;
}

.txa-volume-input::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Settings Panel - CENTERED */
.txa-settings-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 380px;
    max-height: 85vh;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(30px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
    border-radius: 24px;
    padding: 30px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 100;
}

/* Nút Close cho Panels */
.txa-panel-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: #fff;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
}

.txa-panel-close:hover {
    background: #ef4444;
    border-color: #ef4444;
    transform: rotate(90deg);
}

.txa-settings-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.txa-settings-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.txa-setting-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.txa-setting-label {
    color: #94a3b8;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-left: 4px;
}

.txa-setting-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.txa-option-btn {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.txa-option-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
}

.txa-option-btn.active {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Subtitle Style Controls */
.txa-subtitle-style-group {
    display: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 20px;
}

.txa-subtitle-style-group.active {
    display: flex;
}

.txa-style-controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.txa-style-control {
    display: grid;
    grid-template-columns: 80px 1fr;
    align-items: center;
    gap: 12px;
}

.txa-style-control label {
    color: #cbd5e1;
    font-size: 13px;
}

.txa-style-control input[type="range"],
.txa-style-control input[type="color"],
.txa-style-control select {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 6px 10px;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
}

/* Stats Panel - CENTERED */
.txa-stats-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 400px;
    max-height: 80vh;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 24px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 100;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.txa-stats-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.txa-stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-family: 'JetBrains Mono', monospace;
}

.txa-stats-label {
    color: #94a3b8;
    font-size: 12px;
}

.txa-stats-value {
    color: #a5b4fc;
    font-size: 12px;
}

/* Lockdown Overlay */
.txa-lockdown-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.98);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.txa-lockdown-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Context Menu */
.txa-context-menu {
    position: fixed;
    z-index: 9999;
    min-width: 220px;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transform: scale(0.95);
    transform-origin: top left;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.txa-context-menu.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.txa-ctx-header {
    padding: 12px;
    margin-bottom: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.txa-ctx-header span {
    color: #fff;
    font-weight: 600;
    font-size: 14px;
}

.txa-ctx-item {
    padding: 10px 12px;
    color: #cbd5e1;
    font-size: 13px;
    border-radius: 6px;
    transition: all 0.1s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.txa-ctx-item:hover {
    background: rgba(99, 102, 241, 0.2);
    color: #fff;
}

.txa-ctx-item-sub {
    margin-left: auto;
    font-size: 11px;
    opacity: 0.6;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

.txa-ctx-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 4px 0;
}

/* Tooltip */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    margin-bottom: 10px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 50;
}

[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ==================== MOBILE RESPONSIVE ==================== */

/* Tablet & Small Desktop */
@media (max-width: 768px) {
    .txa-controls {
        padding: 12px 14px;
    }

    .txa-controls-left,
    .txa-controls-right {
        gap: 6px;
    }

    .txa-btn {
        width: 44px;
        height: 44px;
    }

    .txa-btn svg {
        width: 20px;
        height: 20px;
    }

    .txa-time {
        font-size: 12px;
        gap: 3px;
    }

    .txa-branding {
        width: 40px;
        height: 40px;
        top: 12px;
        right: 12px;
    }

    .txa-big-play-btn {
        width: 64px;
        height: 64px;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    .txa-big-play-btn svg {
        width: 26px;
        height: 26px;
    }

    .txa-subtitle-overlay {
        font-size: 16px;
        max-width: 90%;
        bottom: 60px;
    }

    .txa-controls.visible~.txa-subtitle-overlay {
        bottom: 80px;
    }

    .txa-progress-container {
        margin-bottom: 14px;
    }

    /* Settings Panel - fullwidth on mobile */
    .txa-settings-panel {
        width: 90vw;
        max-width: 340px;
        padding: 20px;
        border-radius: 18px;
    }

    .txa-option-btn {
        padding: 7px 12px;
        font-size: 12px;
    }

    /* Stats Panel */
    .txa-stats-panel {
        width: 90vw;
        max-width: 340px;
        padding: 18px;
    }

    /* Volume - Design a better mobile interaction */
    .txa-volume-slider {
        display: none !important;
    }

    /* Make volume button toggle mute only on mobile */
    .is-mobile .txa-volume-slider-wrap {
        display: none !important;
    }

    .txa-volume-container:hover .txa-volume-slider {
        display: none !important;
    }

    /* Context Menu - fit mobile screens */
    .txa-context-menu {
        min-width: 180px;
        max-width: calc(100vw - 40px);
    }

    /* Progress tooltip */
    .txa-progress-tooltip {
        font-size: 11px;
        padding: 4px 8px;
    }

    /* Spinner */
    .spinner {
        width: 40px;
        height: 40px;
    }
}

/* Phone */
@media (max-width: 480px) {
    .txa-controls {
        padding: 8px 10px;
    }

    .txa-controls-left,
    .txa-controls-right {
        gap: 2px;
    }

    .txa-btn {
        width: 34px;
        height: 34px;
        border-radius: 6px;
    }

    .txa-btn svg {
        width: 18px;
        height: 18px;
    }

    .txa-time {
        font-size: 11px;
    }

    .txa-branding {
        width: 32px;
        height: 32px;
        top: 8px;
        right: 8px;
    }

    /* Hide redundant icons on mobile */
    .txa-btn-pro {
        display: none !important;
    }

    .txa-time {
        min-width: 90px;
        font-size: 10px;
    }

    .txa-big-play-btn {
        width: 56px;
        height: 56px;
        position: absolute;
        top: calc(50% - 28px);
        left: calc(50% - 28px);
    }

    .txa-big-play-btn svg {
        width: 22px;
        height: 22px;
    }

    .txa-subtitle-overlay {
        font-size: 13px;
        max-width: 94%;
        bottom: 50px;
        text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.9);
    }

    .txa-controls.visible~.txa-subtitle-overlay {
        bottom: 65px;
    }

    /* Progress Bar - Massive Touch Area */
    .txa-progress-container {
        margin-bottom: 12px;
        height: 4px;
        /* Visual height */
        padding-top: 15px;
        /* Touch area padding top */
        padding-bottom: 15px;
        /* Touch area padding bottom */
        background-clip: content-box;
        /* Only show background in content box */
    }

    .txa-progress-bar {
        height: 100%;
        border-radius: 2px;
    }

    .txa-progress-bg {
        background: rgba(255, 255, 255, 0.2);
    }

    .txa-progress-handle {
        width: 14px;
        height: 14px;
        right: -7px;
        transform: translateY(-50%) scale(0);
        /* Hide by default on mobile unless dragging */
        transition: transform 0.1s;
    }

    .txa-progress-container.dragging .txa-progress-handle,
    .active-ui .txa-progress-handle {
        transform: translateY(-50%) scale(1);
        /* Show when dragging or UI active */
    }

    /* 2x Speed Overlay - Artplayer Style */
    .txa-speed-overlay {
        position: absolute;
        top: 25%;
        left: 50%;
        transform: translateX(-50%) translateY(20px);
        background: var(--txa-glass);
        backdrop-filter: blur(20px);
        padding: 12px 24px;
        border-radius: 100px;
        color: #fff;
        font-size: 16px;
        font-weight: 800;
        display: flex;
        align-items: center;
        gap: 12px;
        opacity: 0;
        pointer-events: none;
        transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        z-index: 500;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
        border: 1px solid var(--txa-border);
    }

    .txa-speed-overlay.show {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }

    .txa-speed-overlay i {
        font-size: 12px;
    }

    /* Time Preview on Mobile Seek */
    .txa-mobile-seek-time {
        position: absolute;
        bottom: 40px;
        /* Above progress bar */
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0, 0, 0, 0.8);
        color: #fff;
        padding: 6px 12px;
        border-radius: 8px;
        font-size: 14px;
        font-weight: 700;
        display: none;
        z-index: 60;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    .txa-progress-container.dragging .txa-mobile-seek-time {
        display: block;
    }

    .txa-settings-panel {
        width: 94vw;
        max-width: none;
        padding: 16px;
        border-radius: 14px;
        max-height: 75vh;
    }

    .txa-setting-group {
        gap: 8px;
    }

    .txa-setting-label {
        font-size: 10px;
    }

    .txa-option-btn {
        padding: 6px 10px;
        font-size: 11px;
    }

    .txa-stats-panel {
        width: 94vw;
        max-width: none;
        padding: 14px;
        border-radius: 14px;
    }

    .txa-stats-row {
        padding: 8px 0;
    }

    .txa-stats-label,
    .txa-stats-value {
        font-size: 11px;
    }

    .spinner {
        width: 34px;
        height: 34px;
        border-width: 2px;
    }

    .txa-panel-close {
        width: 28px;
        height: 28px;
        font-size: 16px;
        top: 10px;
        right: 10px;
    }

    /* Style controls compact */
    .txa-style-control {
        grid-template-columns: 60px 1fr;
        gap: 8px;
    }

    .txa-style-control label {
        font-size: 11px;
    }
}