/**
 * TrendHomi Voice Player - Frontend Styles
 * Version: 2.5.0 - Perfect Alignment Final
 */

:root {
    --thv-primary: #2196F3;
    --thv-primary-dark: #1976D2;
    --thv-primary-light: #64B5F6;
    --thv-secondary: #FF9800;
    --thv-gray-50: #FAFAFA;
    --thv-gray-100: #F5F5F5;
    --thv-gray-200: #EEEEEE;
    --thv-gray-300: #E0E0E0;
    --thv-gray-600: #757575;
    --thv-gray-800: #424242;
    --thv-white: #FFFFFF;
}

/* ==================== Reset ==================== */
.thv-player-container,
.thv-player,
.thv-player-container *,
.thv-player * {
    box-sizing: border-box !important;
}

.thv-player-container button,
.thv-player button {
    font-family: inherit;
    border: none;
    background: none;
    cursor: pointer;
    outline: none;
}

/* ==================== Container ==================== */
.thv-player-container,
.thv-player {
    font-family: 'IRANSans', 'Vazirmatn', sans-serif !important;
    direction: rtl !important;
    text-align: right !important;
    background: #FFFFFF !important;
    border-radius: 16px !important;
    padding: 16px 20px !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08) !important;
    border: 1px solid #EEEEEE !important;
    transition: all 0.3s ease !important;
}

.thv-player-container:hover,
.thv-player:hover {
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.15) !important;
    transform: translateY(-2px) !important;
}

/* ==================== Title ==================== */
.thv-player-title,
.thv-title {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    margin: 0 0 12px 0 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #424242 !important;
}

.thv-player-title::before,
.thv-title::before,
.thv-title-icon {
    display: none !important;
}

/* ==================== Controls - تراز کامل ==================== */
.thv-player-controls {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
}

/* ==================== Play Button ==================== */
.thv-play-button {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    border-radius: 50px !important;
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.15) !important;
    flex-shrink: 0 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
}

.thv-play-button:hover {
    transform: scale(1.08) !important;
}

.thv-play-button svg {
    width: 20px !important;
    height: 20px !important;
    fill: #FFFFFF !important;
    color: #FFFFFF !important;
}

.thv-play-button .thv-icon-pause,
.thv-play-button .thv-icon-loading {
    display: none !important;
}

.thv-play-button[data-playing="true"] .thv-icon-play,
.thv-play-button[data-state="playing"] .thv-icon-play {
    display: none !important;
}

.thv-play-button[data-playing="true"] .thv-icon-pause,
.thv-play-button[data-state="playing"] .thv-icon-pause {
    display: block !important;
}

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

.thv-play-button.thv-loading .thv-icon-loading {
    animation: thv-spin 1s linear infinite !important;
}

/* ==================== Player Info ==================== */
.thv-player-info {
    flex: 1 !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
}

/* ==================== Progress Container ==================== */
.thv-progress-container {
    width: 100% !important;
    cursor: pointer !important;
    padding: 6px 0 !important;
    user-select: none !important;
}

/* ==================== Progress Track ==================== */
.thv-progress-track {
    width: 100% !important;
    height: 6px !important;
    background: #EEEEEE !important;
    border-radius: 50px !important;
    position: relative !important;
    overflow: visible !important;
    transition: height 0.2s ease !important;
}

.thv-progress-container:hover .thv-progress-track,
.thv-progress-container.thv-dragging .thv-progress-track {
    height: 8px !important;
}

/* ==================== Progress Fill ==================== */
.thv-progress-fill {
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    height: 100% !important;
    background: linear-gradient(90deg, #2196F3 0%, #64B5F6 100%) !important;
    border-radius: 50px !important;
    width: 0% !important;
    transition: width 0.1s linear !important;
    z-index: 1 !important;
}

/* ==================== Progress Handle ==================== */
.thv-progress-handle {
    position: absolute !important;
    top: 50% !important;
    right: 0% !important;
    left: auto !important;
    transform: translate(50%, -50%) scale(0) !important;
    width: 16px !important;
    height: 16px !important;
    background: #FFFFFF !important;
    border: 3px solid #2196F3 !important;
    border-radius: 50px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
    transition: transform 0.2s ease !important;
    z-index: 2 !important;
    cursor: grab !important;
}

.thv-progress-container:hover .thv-progress-handle,
.thv-progress-container.thv-dragging .thv-progress-handle {
    transform: translate(50%, -50%) scale(1) !important;
}

.thv-progress-handle:hover {
    transform: translate(50%, -50%) scale(1.2) !important;
}

/* ==================== Time Display - پایین تر ==================== */
.thv-time-display {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    direction: ltr !important;
    color: #757575 !important;
    line-height: 1 !important;
    margin-top: 2px !important;
    padding-top: 0 !important;
}

.thv-current-time {
    color: #2196F3 !important;
    font-weight: 600 !important;
}

.thv-time-separator {
    margin: 0 4px !important;
}

/* ==================== Volume Container - بالاتر ==================== */
.thv-volume-container {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    flex-shrink: 0 !important;
    margin-top: -5px !important;
}

/* ==================== Volume Button - تراز شده ==================== */
.thv-volume-button {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    border-radius: 8px !important;
    background: #F5F5F5 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease !important;
    flex-shrink: 0 !important;
    border: 1px solid transparent !important;
}

.thv-volume-button:hover {
    background: #EEEEEE !important;
    border-color: #E0E0E0 !important;
}

.thv-volume-button svg {
    width: 18px !important;
    height: 18px !important;
    color: #757575 !important;
    fill: #757575 !important;
}

.thv-volume-button .thv-icon-mute {
    display: none !important;
}

.thv-volume-button[data-muted="true"] .thv-icon-volume {
    display: none !important;
}

.thv-volume-button[data-muted="true"] .thv-icon-mute {
    display: block !important;
    color: #2196F3 !important;
    fill: #2196F3 !important;
}

/* ==================== Volume Slider - اصلاح شده ==================== */
.thv-volume-slider-container {
    width: 80px !important;
    height: 36px !important;
    display: flex !important;
    align-items: center !important;
    flex-shrink: 0 !important;
}

.thv-volume-slider {
    width: 100% !important;
    height: 6px !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    background: transparent !important;
    border-radius: 50px !important;
    outline: none !important;
    cursor: pointer !important;
    margin: 0 !important;
    padding: 0 !important;
}

.thv-volume-slider::-webkit-slider-runnable-track {
    width: 100% !important;
    height: 6px !important;
    background: #EEEEEE !important;
    border-radius: 50px !important;
}

.thv-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none !important;
    width: 14px !important;
    height: 14px !important;
    background: #2196F3 !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15) !important;
    margin-top: -4px !important;
}

.thv-volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15) !important;
    box-shadow: 0 3px 8px rgba(33, 150, 243, 0.3) !important;
}

.thv-volume-slider::-moz-range-track {
    width: 100% !important;
    height: 6px !important;
    background: #EEEEEE !important;
    border-radius: 50px !important;
    border: none !important;
}

.thv-volume-slider::-moz-range-thumb {
    width: 14px !important;
    height: 14px !important;
    background: #2196F3 !important;
    border: none !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15) !important;
}

.thv-volume-slider::-moz-range-thumb:hover {
    transform: scale(1.15) !important;
    box-shadow: 0 3px 8px rgba(33, 150, 243, 0.3) !important;
}

/* ==================== Speed Button - بالاتر ==================== */
.thv-speed-button {
    min-width: 48px !important;
    height: 36px !important;
    padding: 0 12px !important;
    border-radius: 8px !important;
    background: #F5F5F5 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    color: #757575 !important;
    transition: all 0.2s ease !important;
    flex-shrink: 0 !important;
    border: 1px solid transparent !important;
    line-height: 1 !important;
    margin-top: -5px !important;
}

.thv-speed-button:hover {
    background: #EEEEEE !important;
    color: #2196F3 !important;
    border-color: #E0E0E0 !important;
}

/* ==================== Transcript Button - بالاتر ==================== */
.thv-transcript-toggle {
    width: auto !important;
    min-width: 60px !important;
    height: 36px !important;
    padding: 0 12px !important;
    border-radius: 8px !important;
    background: #F5F5F5 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    flex-shrink: 0 !important;
    cursor: pointer !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    color: #757575 !important;
    border: 1px solid transparent !important;
    white-space: nowrap !important;
    line-height: 1 !important;
    margin-top: -5px !important;
}

.thv-transcript-toggle:hover {
    background: #EEEEEE !important;
    color: #2196F3 !important;
    border-color: #E0E0E0 !important;
}

.thv-transcript-toggle[aria-expanded="true"],
.thv-transcript-toggle.thv-active {
    background: #2196F3 !important;
    color: #FFFFFF !important;
    border-color: #2196F3 !important;
}

.thv-transcript-toggle[aria-expanded="true"]:hover {
    background: #1976D2 !important;
    border-color: #1976D2 !important;
}

.thv-transcript-toggle svg,
.thv-icon-arrow-down {
    width: 16px !important;
    height: 16px !important;
    color: currentColor !important;
    fill: none !important;
    stroke: currentColor !important;
    transition: transform 0.3s ease !important;
    flex-shrink: 0 !important;
}

.thv-transcript-toggle[aria-expanded="true"] svg,
.thv-transcript-toggle[aria-expanded="true"] .thv-icon-arrow-down,
.thv-transcript-toggle.thv-active svg {
    transform: rotate(180deg) !important;
}

.thv-transcript-label {
    font-size: 12px !important;
    font-weight: 600 !important;
    color: inherit !important;
    white-space: nowrap !important;
    line-height: 1 !important;
}

/* ==================== Transcript Container ==================== */
.thv-transcript-container {
    margin-top: 12px !important;
    padding: 14px 16px !important;
    background: #FAFAFA !important;
    border-radius: 12px !important;
    border: 1px solid #EEEEEE !important;
    max-height: 250px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    opacity: 1 !important;
    display: block !important;
}

.thv-transcript-container.thv-collapsed {
    max-height: 0 !important;
    padding: 0 16px !important;
    margin-top: 0 !important;
    opacity: 0 !important;
    border-width: 0 !important;
    overflow: hidden !important;
    display: none !important;
}

.thv-transcript-container.thv-expanded {
    display: block !important;
    animation: thv-slideDown 0.3s ease !important;
}

@keyframes thv-slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.thv-transcript-text {
    font-size: 13px !important;
    line-height: 1.8 !important;
    color: #424242 !important;
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    text-align: justify !important;
    direction: rtl !important;
}

.thv-transcript-text p {
    margin: 0 0 10px 0 !important;
}

.thv-transcript-text p:last-child {
    margin-bottom: 0 !important;
}

/* ==================== Hidden ==================== */
.thv-audio-element {
    display: none !important;
    visibility: hidden !important;
    position: absolute !important;
    left: -9999px !important;
}

.thv-player-description,
.thv-description {
    display: none !important;
}

/* ==================== Scrollbar ==================== */
.thv-transcript-container::-webkit-scrollbar {
    width: 6px !important;
}

.thv-transcript-container::-webkit-scrollbar-track {
    background: #F5F5F5 !important;
    border-radius: 50px !important;
}

.thv-transcript-container::-webkit-scrollbar-thumb {
    background: #E0E0E0 !important;
    border-radius: 50px !important;
}

.thv-transcript-container::-webkit-scrollbar-thumb:hover {
    background: #BDBDBD !important;
}

/* ==================== Responsive ==================== */
@media (max-width: 600px) {
    .thv-player-container,
    .thv-player {
        padding: 12px 14px !important;
    }
    
    .thv-player-controls {
        gap: 8px !important;
    }
    
    .thv-play-button {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
    }
    
    .thv-play-button svg {
        width: 18px !important;
        height: 18px !important;
    }
    
    .thv-volume-slider-container {
        width: 60px !important;
    }
    
    .thv-speed-button {
        min-width: 42px !important;
        height: 32px !important;
        padding: 0 10px !important;
        font-size: 11px !important;
        margin-top: -3px !important;
    }
    
    .thv-transcript-toggle {
        min-width: 50px !important;
        height: 32px !important;
        padding: 0 10px !important;
        font-size: 11px !important;
        margin-top: -3px !important;
    }
    
    .thv-transcript-toggle svg {
        width: 14px !important;
        height: 14px !important;
    }
    
    .thv-transcript-label {
        font-size: 11px !important;
    }
    
    .thv-volume-button {
        width: 32px !important;
        height: 32px !important;
        margin-top: 0 !important;
    }
    
    .thv-volume-container {
        margin-top: -3px !important;
    }
    
    .thv-time-display {
        margin-top: 1px !important;
    }
}

/* ==================== Print ==================== */
@media print {
    .thv-player-container,
    .thv-player {
        display: none !important;
    }
}

/* ==================== Accessibility ==================== */
.thv-player button:focus-visible {
    outline: 2px solid #2196F3 !important;
    outline-offset: 2px !important;
}

.thv-progress-track:focus-visible {
    outline: 2px solid #2196F3 !important;
    outline-offset: 2px !important;
}

/* ==================== End ==================== */