/**
 * Mementor Text to Speech - Shared CSS
 * 
 * This file contains ALL styles for the audio player that are shared between
 * the admin preview player and the frontend player.
 * 
 * IMPORTANT: All player styles should be in this file only to ensure consistency
 * between the preview player in the admin area and the live player on the frontend.
 * Do not add player styles to admin/css/mementor-tts-admin.css.
 */

:root {
    /* Theme Colors */
    --mementor-tts-bg-color: #f6f7fb;
    --mementor-tts-border-color: #dcdcde;
    --mementor-tts-accent-color: #2271b1;
    --mementor-tts-accent-color-hover: #135e96;
    --mementor-tts-text-color: #50575e;

    /* Component Colors */
    --mementor-tts-play-button-bg: #ffffff;
    --mementor-tts-play-button-bg-hover: #f6f7f7;
    --mementor-tts-progress-default: #e0e0e0;
    --mementor-tts-progress-playing: #2271b1;
    --mementor-tts-timer-color: #50575e;

    /* Spacing */
    --mementor-tts-spacing-xs: 4px;
    --mementor-tts-spacing-sm: 8px;
    --mementor-tts-spacing-md: 12px;
    --mementor-tts-spacing-lg: 16px;
    
    /* Sizes */
    --mementor-tts-play-icon-size: 24px;
    --mementor-tts-icon-size: 20px;
    --mementor-tts-font-size: 14px;
    --mementor-tts-player-padding: 15px;

    /* Player Label */
    --mementor-tts-label-margin: 10px;
    --mementor-tts-label-size: 14px;
    --mementor-tts-label-weight: 400;
    --mementor-tts-label-color: #1d2327;
}

/* Preview Player Container */
.mementor-tts-preview-player {
    display: block;
    width: 100%;
    max-width: var(--mementor-tts-max-width);
    transition: max-width 0.3s ease;
}

.mementor-tts-preview-player .mementor-tts-player-container {
    display: block;
    width: 100%;
    transition: max-width 0.3s ease;
}

.mementor-tts-preview-player .mementor-tts-player {
    width: 100%;
    transition: max-width 0.3s ease;
}

/* Ensure preview player respects max-width with highest specificity */
html body .mementor-tts-preview-player,
html body .mementor-tts-preview-player .mementor-tts-player-container {
    max-width: var(--mementor-tts-max-width);
    width: 100%;
}

html body .mementor-tts-preview-player .mementor-tts-player {
    width: 100%;
}

/* Base player container with highest specificity */
html body .mementor-tts-player-container {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 1.5em;
    transition: max-width 0.3s ease;
    max-width: var(--mementor-tts-max-width);
}

/* Base player container styles */
html body .mementor-tts-player-container {
    margin: 1.5em 0;
    clear: both;
    display: block;
    position: relative;
    box-sizing: border-box;
}

/* Before Title Position */
html body .mementor-tts-player-container.mementor-tts-before-title,
html body .mementor-tts-player-container.mementor-tts-before-title-js {
    margin: 0 0 1.5em 0;
    clear: both;
    display: block;
}

/* After Title Before Excerpt Position */
html body .mementor-tts-player-container.mementor-tts-after-title-before-excerpt {
    margin: 1.5em 0;
    clear: both;
    display: block;
}

.entry-header + .mementor-tts-player-container.mementor-tts-after-title-before-excerpt {
    margin-top: 1em;
}

.mementor-tts-player-container.mementor-tts-after-title-before-excerpt + .entry-content,
.mementor-tts-player-container.mementor-tts-after-title-before-excerpt + .excerpt {
    margin-top: 1em;
}

/* After Title After Excerpt Position */
html body .mementor-tts-player-container.mementor-tts-after-title-after-excerpt {
    margin: 1.5em 0;
    clear: both;
    display: block;
}

.excerpt + .mementor-tts-player-container.mementor-tts-after-title-after-excerpt {
    margin-top: 1em;
}

.mementor-tts-player-container.mementor-tts-after-title-after-excerpt + .entry-content {
    margin-top: 1em;
}

/* After Title Position */
html body .mementor-tts-player-container.mementor-tts-after-title,
html body .mementor-tts-player-container.mementor-tts-after-title-js {
    margin: 1.5em 0;
    clear: both;
    display: block;
}

/* After Content Position */
html body .mementor-tts-player-container.mementor-tts-after-content {
    margin: 1.5em 0 0 0;
    clear: both;
    display: block;
}

/* Player wrapper */
.mementor-tts-player-wrapper {
    position: relative;
    margin-bottom: 10px;
    width: 100%;
}

/* Base player label styles */
.mementor-tts-player-label {
    display: block;
    margin-bottom: 5px;
    line-height: 1.4;
}

/* Label font size */
.mementor-tts-player-label.label-size-small {
    font-size: 12px;
}

.mementor-tts-player-label.label-size-default {
    font-size: 14px;
}

.mementor-tts-player-label.label-size-large {
    font-size: 16px;
}

/* Label font weight */
.mementor-tts-player-label.label-weight-normal {
    font-weight: 400;
}

.mementor-tts-player-label.label-weight-medium {
    font-weight: 500;
}

.mementor-tts-player-label.label-weight-bold {
    font-weight: 700;
}

/* Label colors */
.mementor-tts-player-label.label-color-dark {
    color: #1d2327;
}

.mementor-tts-player-label.label-color-white {
    color: #ffffff;
}

.mementor-tts-player-label.label-color-custom {
    color: var(--mementor-tts-custom-label-color, #1d2327);
}

/* Label alignment */
.mementor-tts-player-label.text-left {
    text-align: left;
}

.mementor-tts-player-label.text-center {
    text-align: center;
}

.mementor-tts-player-label.text-right {
    text-align: right;
}

/* Label position-specific styles */
.mementor-tts-player-label.mementor-tts-before-title,
.mementor-tts-player-label.mementor-tts-before-title-js {
    margin-bottom: 0.5em;
}

.mementor-tts-player-label.mementor-tts-after-title-before-excerpt {
    margin-bottom: 1em;
}

.mementor-tts-player-label.mementor-tts-after-title-after-excerpt {
    margin-bottom: 1em;
}

.mementor-tts-player-label.mementor-tts-after-content {
    margin-bottom: 1em;
}

/* Custom color support through CSS variables */
.mementor-tts-player-label[class*="label-color-custom-"] {
    color: var(--mementor-tts-custom-label-color);
}

/* Hide label when show_label is false */
.mementor-tts-preview-player[data-show-label="false"] .mementor-tts-player-label,
.mementor-tts-preview-player[data-show-label="0"] .mementor-tts-player-label {
    display: none !important;
}

/* Show label when show_label is true */
.mementor-tts-preview-player[data-show-label="true"] .mementor-tts-player-label,
.mementor-tts-preview-player[data-show-label="1"] .mementor-tts-player-label {
    display: block !important;
}

/* Force text alignment based on data attribute */
.mementor-tts-preview-player[data-label-position="left"] .mementor-tts-player-label {
    text-align: left !important;
}

.mementor-tts-preview-player[data-label-position="center"] .mementor-tts-player-label {
    text-align: center !important;
}

.mementor-tts-preview-player[data-label-position="right"] .mementor-tts-player-label {
    text-align: right !important;
}

/* Main player with proper width inheritance */
.mementor-tts-player {
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    max-width: none !important;
}

/* Custom controls container */
.mementor-tts-custom-controls {
    flex-wrap: wrap !important;
    justify-content: space-between !important;
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: none !important;
    display: flex !important;
    align-items: center;
    gap: var(--mementor-tts-spacing-sm, 8px);
    padding: var(--mementor-tts-player-padding, 15px);
    background-color: var(--mementor-tts-bg-color, #f6f7fb);
    border: 1px solid var(--mementor-tts-border-color, #dcdcde);
    border-radius: 4px;
    font-size: var(--mementor-tts-font-size, 14px);
    position: relative !important;
    z-index: 1 !important;
    overflow: visible !important;
}

/* Play button */
.mementor-tts-play-button {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: calc(var(--mementor-tts-play-icon-size, 24px) * 1.5);
    height: calc(var(--mementor-tts-play-icon-size, 24px) * 1.5);
    background-color: var(--mementor-tts-play-button-bg, #ffffff) !important;
    border: 1px solid var(--mementor-tts-border-color, #dcdcde) !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    padding: 0 !important;
    order: 1 !important;
    position: relative !important;
    transition: background-color 0.2s ease;
    outline: none;
}

.mementor-tts-play-button:focus {
    outline: none;
    box-shadow: none;
}

.mementor-tts-play-button:hover {
    background-color: var(--mementor-tts-play-button-bg-hover, #f6f7f7);
}

/* Play button icon */
.mementor-tts-play-button .dashicons {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-45%, -50%);
    margin: 0;
    padding: 0;
    font-size: var(--mementor-tts-play-icon-size, 24px) !important;
    width: var(--mementor-tts-play-icon-size, 24px) !important;
    height: var(--mementor-tts-play-icon-size, 24px) !important;
    display: inline-block !important;
    font-family: dashicons !important;
    line-height: 1;
    color: var(--mementor-tts-accent-color, #2271b1);
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
}

.dashicons-controls-pause:before {
    margin-left: -1px;
}

/* Time display */
.mementor-tts-time-display,
.mementor-tts-duration-display {
    font-family: monospace;
    font-size: var(--mementor-tts-font-size, 14px);
    color: var(--mementor-tts-timer-color, #50575e);
    min-width: 45px;
    flex-shrink: 0;
    text-align: center;
}

.mementor-tts-time-display {
    order: 2;
}

.mementor-tts-duration-display {
    order: 4;
}

/* Progress container */
.mementor-tts-progress-container {
    flex-grow: 1;
    height: 8px;
    background-color: var(--mementor-tts-progress-default, #e0e0e0) !important;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    order: 3;
    z-index: 10; /* Ensure it's above other elements for clicking */
    transition: background-color 0.2s ease;
}

/* Progress container hover effect */
.mementor-tts-progress-container:hover {
    background-color: #d0d0d0 !important;
}

/* Progress container variants */
.mementor-tts-progress-container.thin {
    height: 4px;
}

.mementor-tts-progress-container.thick {
    height: 8px;
}

/* Progress bar */
.mementor-tts-progress-bar {
    height: 100%;
    width: 0;
    background-color: var(--mementor-tts-progress-playing, #2271b1) !important;
    border-radius: 4px;
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none; /* Allow clicks to pass through to the container */
    transition: width 0.1s linear; /* Smooth progress updates */
}

/* Volume button */
.mementor-tts-volume-button {
    background: none !important;
    border: none !important;
    cursor: pointer !important;
    padding: 0 !important;
    order: 5 !important;
}

.mementor-tts-volume-button:hover {
    opacity: 0.8;
}

/* Volume button icon */
.mementor-tts-volume-button .dashicons {
    width: var(--mementor-tts-icon-size, 20px) !important;
    height: var(--mementor-tts-icon-size, 20px) !important;
    color: var(--mementor-tts-accent-color, #2271b1);
    display: inline-block !important;
    font-family: dashicons !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
}

/* Speed button */
.mementor-tts-speed-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px 8px;
    border-radius: 3px;
    color: var(--mementor-tts-accent-color, #2271b1);
    font-size: var(--mementor-tts-font-size, 14px) !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    order: 6;
}

.mementor-tts-speed-button:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Download button */
.mementor-tts-download-button {
    background: none !important;
    border: none !important;
    cursor: pointer !important;
    padding: 0 !important;
    order: 7 !important;
}

.mementor-tts-download-button:hover {
    opacity: 0.8;
}

/* Download button icon */
.mementor-tts-download-button .dashicons {
    width: var(--mementor-tts-icon-size, 20px) !important;
    height: var(--mementor-tts-icon-size, 20px) !important;
    color: var(--mementor-tts-accent-color, #2271b1);
    display: inline-block !important;
    font-family: dashicons !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
}

/* Info button */
.mementor-tts-info-button {
    background: none !important;
    border: none !important;
    cursor: pointer !important;
    padding: 0 !important;
    order: 8 !important;
    position: relative !important;
}

.mementor-tts-info-button:hover {
    opacity: 0.8;
}

/* Info button icon */
.mementor-tts-info-button .dashicons {
    width: var(--mementor-tts-icon-size, 20px) !important;
    height: var(--mementor-tts-icon-size, 20px) !important;
    color: var(--mementor-tts-accent-color, #2271b1);
    display: inline-block !important;
    font-family: dashicons !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
}

/* Info popup styles */
.mementor-tts-info-popup {
    display: none;
    position: fixed;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 10px 15px;
    width: 308px;
    max-width: 90vw;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
    z-index: 999999;
    font-size: 14px;
    line-height: 1.5;
    color: #444;
    text-align: left;
    /* Use CSS variables for positioning precision */
    --button-x: 0px;
    --button-y: 0px;
    --button-width: 0px;
    --button-right: 0px;
}

.mementor-tts-info-popup p {
    margin: 0;
    padding: 0;
}

/* Arrow pointing down from the popup */
.mementor-tts-info-popup:after {
    content: '';
    position: absolute;
    top: 100%;
    border-width: 8px;
    border-style: solid;
    border-color: white transparent transparent transparent;
}

/* Position top-left */
.mementor-tts-info-popup.position-top-left {
    left: var(--button-x);
    top: var(--button-y);
    transform: translate(0, -100%);
    margin-top: -8px;
}

.mementor-tts-info-popup.position-top-left:after {
    left: 15px;
}

/* Position top-center */
.mementor-tts-info-popup.position-top-center {
    left: calc(var(--button-x) + var(--button-width) / 2);
    top: var(--button-y);
    transform: translate(-50%, -100%);
    margin-top: -8px;
}

.mementor-tts-info-popup.position-top-center:after {
    left: 50%;
    transform: translateX(-50%);
}

/* Position top-right */
.mementor-tts-info-popup.position-top-right {
    left: var(--button-right);
    top: var(--button-y);
    transform: translate(-100%, -100%);
    margin-top: -27px;
}

.mementor-tts-info-popup.position-top-right:after {
    right: 15px;
}

/* Visible state */
.mementor-tts-info-popup.tooltip-visible {
    display: block;
}

/* Make sure all parent elements allow the popup to be visible */
.mementor-tts-player,
.mementor-tts-player-container,
.mementor-tts-custom-controls,
.mementor-tts-info-button {
    overflow: visible !important;
    position: relative !important;
}

body .mementor-tts-player,
body .mementor-tts-player-container,
body .mementor-tts-custom-controls {
    overflow: visible !important;
}

/* Force parent divs up the DOM tree to show overflow */
.mementor-tts-player-container *,
.mementor-tts-player * {
    pointer-events: auto !important;
}

/* Add a special global container for the popup that can't be affected by overflow */
.mementor-tts-info-popup-container {
    position: relative !important;
    overflow: visible !important;
}

/* Player width options */
.mementor-tts-player.content-width,
.mementor-tts-player.full-width {
    width: 100%;
}

/* Responsive adjustments */
@media screen and (max-width: 600px) {
    .mementor-tts-custom-controls {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px;
    }
    
    .mementor-tts-play-button {
        width: 32px;
        height: 32px;
    }
    
    .mementor-tts-time-display,
    .mementor-tts-duration-display {
        font-size: 12px;
        min-width: 40px;
    }
    
    .mementor-tts-progress-container {
        order: 1;
        width: 100%;
        flex-basis: 100%;
    }
    
    .mementor-tts-time-display {
        order: 2;
    }
    
    .mementor-tts-duration-display {
        order: 3;
    }
}

/* Ensure the player is visible in Elementor templates without changing the original layout */
.elementor-widget-container .mementor-tts-player-container {
    display: block;
    width: 100%;
    max-width: var(--mementor-tts-max-width);
}

/* Adjust player for Elementor page builder */
.elementor-section .mementor-tts-player {
    width: 100%;
    margin: 0 auto;
}

/* Disabled controls */
.mementor-tts-control-disabled,
button.mementor-tts-control-disabled,
.mementor-tts-custom-controls button.mementor-tts-control-disabled,
.mementor-tts-player button[style*="display: none"],
.mementor-tts-player button[style*="display:none"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    position: absolute !important;
    pointer-events: none !important;
}

/* Remove ALL conflicting width classes and consolidate */
/* Width classes with highest specificity */
html body .mementor-tts-player-container {
    width: 100%;
    box-sizing: border-box;
    display: block;
}

/* Full width variant */
html body .mementor-tts-player-container.mementor-tts-width-full {
    max-width: 100%;
}

/* Custom/Content width variant */
html body .mementor-tts-player-container.mementor-tts-width-custom,
html body .mementor-tts-player-container.mementor-tts-width-500,
html body .mementor-tts-player-container.mementor-tts-width-content_width {
    max-width: var(--mementor-tts-max-width);
}

/* Alignment with highest specificity */
html body .mementor-tts-player-container[data-alignment="left"] {
    margin-left: 0 !important;
    margin-right: auto !important;
}

html body .mementor-tts-player-container[data-alignment="center"] {
    margin-left: auto !important;
    margin-right: auto !important;
}

html body .mementor-tts-player-container[data-alignment="right"] {
    margin-left: auto !important;
    margin-right: 0 !important;
}

/* Remove any !important from max-width on these classes */
.mementor-tts-width-full,
.mementor-tts-preview-player .mementor-tts-width-full,
.mementor-tts-player.mementor-tts-width-full {
    width: 100%;
}

/* Loading animation for play button */
.mementor-tts-loading {
    opacity: 0.7;
    pointer-events: none;
}

.mementor-tts-spin {
    animation: mementor-tts-spin 2s linear infinite;
}

@keyframes mementor-tts-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Generating state styles */
.mementor-tts-generating {
    position: relative;
}

.mementor-tts-generating .dashicons {
    animation: mementor-tts-spin 2s linear infinite;
    color: var(--mementor-tts-accent-color-hover, #135e96) !important;
}

.mementor-tts-generate-button.mementor-tts-generating {
    background-color: rgba(34, 113, 177, 0.1) !important;
    cursor: not-allowed !important;
}

.mementor-tts-generate-button.mementor-tts-generating .dashicons {
    color: var(--mementor-tts-accent-color-hover, #135e96) !important;
}

/* Pulse animation for generating state */
@keyframes mementor-tts-pulse {
    0% { box-shadow: 0 0 0 0 rgba(34, 113, 177, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(34, 113, 177, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 113, 177, 0); }
}

.mementor-tts-player-container.is-generating .mementor-tts-play-button {
    animation: mementor-tts-pulse 1.5s infinite;
}

/* Fix for player layout issues */
.mementor-tts-player {
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    max-width: none !important;
}

.mementor-tts-custom-controls {
    flex-wrap: wrap !important; /* Allow controls to wrap on narrow screens */
    justify-content: space-between !important;
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: none !important;
}

/* Make sure the progress container is full width on mobile */
@media (max-width: 480px) {
    .mementor-tts-progress-container {
        width: 100% !important;
        flex-basis: 100% !important;
        order: 5 !important; /* Move below other controls on mobile */
        margin-top: 8px !important;
    }
    
    .mementor-tts-custom-controls {
        padding: 10px !important; /* Reduce padding on mobile */
    }
    
    /* Fix for play button alignment */
    .mementor-tts-play-button {
        width: 32px !important;
        height: 32px !important;
    }
    
    /* Smaller font size for time display */
    .mementor-tts-time-display,
    .mementor-tts-duration-display {
        font-size: 12px !important;
        min-width: auto !important;
    }
}

/* Fix for specific WordPress theme conflicts */
.entry-content .mementor-tts-player,
.post-content .mementor-tts-player,
.content .mementor-tts-player,
.wp-block .mementor-tts-player,
.elementor-widget-container .mementor-tts-player {
    width: 100%;
}

/* Ensure audio element is properly sized */
.mementor-tts-player audio {
    width: 1px !important;
    height: 1px !important;
    position: absolute !important;
    left: -9999px !important;
}

/* Hide player on non-singular pages as a fallback */
.home .mementor-tts-player-container,
.archive .mementor-tts-player-container,
.search .mementor-tts-player-container,
.blog .mementor-tts-player-container,
body:not(.single):not(.page):not(.singular) .mementor-tts-player-container {
    display: none !important;
}

/* Ensure width classes work in Elementor */
.elementor-widget-container .mementor-tts-player-container.mementor-tts-width-500,
.elementor-widget-container .mementor-tts-player-container.mementor-tts-width-custom,
.elementor-widget-container .mementor-tts-player-container.mementor-tts-width-full {
    width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

.elementor-widget-container .mementor-tts-player {
    width: 100%;
}

/* Ensure width classes have high specificity */
body .mementor-tts-player-container.mementor-tts-width-500,
body .mementor-tts-preview-player .mementor-tts-width-500 {
    max-width: var(--mementor-tts-max-width) !important;
    width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

body .mementor-tts-player-container.mementor-tts-width-custom,
body .mementor-tts-preview-player .mementor-tts-width-custom {
    max-width: var(--mementor-tts-max-width) !important;
    width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

body .mementor-tts-player-container.mementor-tts-width-full,
body .mementor-tts-preview-player .mementor-tts-width-full {
    width: 100% !important;
}

/* Ensure proper width inheritance */
.mementor-tts-player-container {
    max-width: var(--mementor-tts-max-width) !important;
    width: 100% !important;
    box-sizing: border-box !important;
    display: block !important;
}

.mementor-tts-player {
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Hide empty paragraph tags */
.mementor-tts-player-container p:empty {
    display: none !important;
}

.mementor-tts-player-container p:empty + p:empty {
    display: none !important;
}

.mementor-tts-player p {
    margin: 0 !important;
    padding: 0 !important;
}

/* Player alignment styles - high specificity */
body .mementor-tts-player-container[data-alignment="left"],
.mementor-tts-player-container[data-alignment="left"] {
    margin-left: 0 !important;
    margin-right: auto !important;
}

body .mementor-tts-player-container[data-alignment="center"],
.mementor-tts-player-container[data-alignment="center"] {
    margin-left: auto !important;
    margin-right: auto !important;
}

body .mementor-tts-player-container[data-alignment="right"],
.mementor-tts-player-container[data-alignment="right"] {
    margin-left: auto !important;
    margin-right: 0 !important;
}

/* Player width styles */
.mementor-tts-player-container.mementor-tts-width-content_width {
    max-width: var(--mementor-tts-max-width) !important;
}

.mementor-tts-player-container.mementor-tts-width-full_width {
    max-width: 100%;
}

/* Ensure proper width inheritance with high specificity */
html body .mementor-tts-player-container {
    max-width: var(--mementor-tts-max-width);
    width: 100%;
    box-sizing: border-box;
    display: block;
}

/* Player alignment styles with highest specificity */
html body .mementor-tts-player-container[data-alignment="left"] {
    margin-left: 0 !important;
    margin-right: auto !important;
}

html body .mementor-tts-player-container[data-alignment="center"] {
    margin-left: auto !important;
    margin-right: auto !important;
}

html body .mementor-tts-player-container[data-alignment="right"] {
    margin-left: auto !important;
    margin-right: 0 !important;
}

/* Player width styles */
.mementor-tts-player-container.mementor-tts-width-content_width {
    max-width: var(--mementor-tts-max-width) !important;
}

.mementor-tts-player-container.mementor-tts-width-full_width {
    max-width: 100%;
}

/* Ensure preview player respects max-width */
html body .mementor-tts-preview-player .mementor-tts-player-container {
    max-width: var(--mementor-tts-max-width);
    width: 100%;
}

/* Remove any conflicting max-width rules */
.mementor-tts-preview-player .mementor-tts-player,
.mementor-tts-preview-player .mementor-tts-player * {
    max-width: none !important;
}

/* Preview player container base styles */
.mementor-tts-preview-player .mementor-tts-player-container {
    display: block;
    width: 100%;
    max-width: var(--mementor-tts-max-width);
}

/* Preview player alignment styles - highest specificity */
html body .mementor-tts-preview-player .mementor-tts-player-container[data-alignment="left"] {
    margin-left: 0 !important;
    margin-right: auto !important;
}

html body .mementor-tts-preview-player .mementor-tts-player-container[data-alignment="center"] {
    margin-left: auto !important;
    margin-right: auto !important;
}

html body .mementor-tts-preview-player .mementor-tts-player-container[data-alignment="right"] {
    margin-left: auto !important;
    margin-right: 0 !important;
}

/* Preview player alignment styles */
.mementor-tts-preview-player[data-alignment="left"] {
    margin-left: 0 !important;
    margin-right: auto !important;
}

.mementor-tts-preview-player[data-alignment="center"] {
    margin-left: auto !important;
    margin-right: auto !important;
}

.mementor-tts-preview-player[data-alignment="right"] {
    margin-right: 0 !important;
    margin-left: auto !important;
}

/* Ensure parent containers don't clip the popup */
.mementor-tts-custom-controls,
.mementor-tts-player,
.mementor-tts-player-container {
    overflow: visible !important;
    position: relative !important;
}

/* Player alignment classes */
html body .mementor-tts-player-container.mementor-tts-align-left {
    margin-right: auto;
    margin-left: 0;
}

html body .mementor-tts-player-container.mementor-tts-align-center {
    margin-left: auto;
    margin-right: auto;
}

html body .mementor-tts-player-container.mementor-tts-align-right {
    margin-left: auto;
    margin-right: 0;
}

/* Alignment Classes */
html body .mementor-tts-player-container.mementor-tts-align-left {
    margin-right: auto;
    text-align: left;
}

html body .mementor-tts-player-container.mementor-tts-align-center {
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

html body .mementor-tts-player-container.mementor-tts-align-right {
    margin-left: auto;
    text-align: right;
}

/* Width Classes */
html body .mementor-tts-player-container.mementor-tts-width-content_width {
    max-width: 500px;
}

html body .mementor-tts-player-container.mementor-tts-width-full_width {
    width: 100%;
}

/* Ensure proper spacing with theme elements */
.entry-header + .mementor-tts-player-container,
.entry-content + .mementor-tts-player-container,
.excerpt + .mementor-tts-player-container {
    margin-top: 1em;
}

.mementor-tts-player-container + .entry-content,
.mementor-tts-player-container + .excerpt {
    margin-top: 1em;
}

/* Dynamic Placement Context Classes */

/* Adjacent to specific elements */
.mementor-tts-adjacent-to-entry-title {
    margin: 1.5em 0;
}

.mementor-tts-adjacent-to-entry-header {
    margin: 1.5em 0;
}

.mementor-tts-adjacent-to-post-title {
    margin: 1.5em 0;
}

/* Before/After Excerpt Context */
.mementor-tts-before-entry-content,
.mementor-tts-before-post-content,
.mementor-tts-before-excerpt {
    margin: 1.5em 0 1em;
}

.mementor-tts-after-entry-excerpt,
.mementor-tts-after-excerpt,
.mementor-tts-after-post-excerpt {
    margin: 1em 0 1.5em;
}

/* Fallback Cases */
.mementor-tts-no-excerpt {
    margin: 1em 0 1.5em;
}

.mementor-tts-no-excerpt-no-content {
    margin: 1em 0 1.5em;
}

/* Theme-specific adjustments */
.elementor-widget-container .mementor-tts-player-container {
    margin: 1em 0;
}

.elementor-widget-theme-post-content .mementor-tts-player-container {
    margin: 1.5em 0;
}

/* Ensure proper spacing with various theme elements */
.entry-header + .mementor-tts-player-container {
    margin-top: 1em;
}

.mementor-tts-player-container + .entry-content {
    margin-top: 1.5em;
}

.excerpt + .mementor-tts-player-container {
    margin-top: 1em;
}

.mementor-tts-player-container + .excerpt {
    margin-top: 1em;
}

/* Position-specific margins */
.mementor-tts-before-title-js {
    margin-bottom: 1.5em;
}

.mementor-tts-after-title-js {
    margin-top: 1em;
    margin-bottom: 1.5em;
}

.mementor-tts-after-title-before-excerpt {
    margin: 1em 0 1.5em;
}

.mementor-tts-after-title-after-excerpt {
    margin: 1.5em 0 1em;
}

.mementor-tts-after-content {
    margin-top: 1.5em;
    margin-bottom: 0;
}

/* Base player container styles */
.mementor-tts-player-container {
    clear: both;
    display: block;
    position: relative;
    box-sizing: border-box;
    width: 100%;
}

/* Max width custom class with fallback support */
html body .mementor-tts-player-container.mementor-tts-max-width-custom {
    max-width: var(--mementor-tts-max-width, 100%) !important;
    width: 100% !important;
}

/* Max width based on data attributes - modern browsers */
@supports (max-width: attr(data-max-width px)) {
    html body .mementor-tts-max-width-custom {
        max-width: attr(data-max-width length, 100%) !important;
    }
}

html body .mementor-tts-player-container.mementor-tts-width-content_width {
    width: 100% !important;
    max-width: var(--mementor-tts-max-width, 100%) !important;
}

/* Ensure the player element also respects the max-width */
html body .mementor-tts-player-container.mementor-tts-max-width-custom .mementor-tts-player {
    width: 100% !important;
}

/* Responsive Breakpoints */
@media screen and (max-width: 1024px) {
    html body .mementor-tts-player-container {
        padding: var(--mementor-tts-spacing-md);
    }

    .mementor-tts-custom-controls {
        gap: var(--mementor-tts-spacing-sm);
    }
}

@media screen and (max-width: 768px) {
    html body .mementor-tts-player-container {
        padding: var(--mementor-tts-spacing-sm);
    }

    .mementor-tts-custom-controls {
        flex-wrap: wrap;
        gap: var(--mementor-tts-spacing-xs);
    }

    .mementor-tts-progress-container {
        order: 2;
        max-width: 30%;
        margin: var(--mementor-tts-spacing-xs) 0;
    }

    .mementor-tts-time-display {
        order: 3;
    }

    .mementor-tts-volume-button,
    .mementor-tts-speed-button,
    .mementor-tts-download-button,
    .mementor-tts-info-button {
        order: 4;
    }

    .mementor-tts-player-label {
        font-size: calc(var(--mementor-tts-label-size) * 0.9);
        margin-bottom: var(--mementor-tts-spacing-sm);
    }
}

@media screen and (max-width: 480px) {
    html body .mementor-tts-player-container {
        padding: var(--mementor-tts-spacing-xs);
    }

    .mementor-tts-custom-controls {
        justify-content: center;
    }

    .mementor-tts-play-button {
        order: 1;
        margin-right: var(--mementor-tts-spacing-xs);
    }

    .mementor-tts-progress-container {
        order: 2;
        width: 100%;
        margin: var(--mementor-tts-spacing-xs) 0;
    }

    .mementor-tts-time-display {
        order: 3;
        font-size: calc(var(--mementor-tts-font-size) * 0.9);
    }

    .mementor-tts-volume-button,
    .mementor-tts-speed-button,
    .mementor-tts-download-button,
    .mementor-tts-info-button {
        order: 4;
        padding: calc(var(--mementor-tts-spacing-xs) * 1.5);
    }

    .mementor-tts-player-label {
        font-size: calc(var(--mementor-tts-label-size) * 0.85);
        margin-bottom: var(--mementor-tts-spacing-xs);
    }

    /* Adjust icon sizes for better touch targets */
    .mementor-tts-play-button .dashicons {
        font-size: calc(var(--mementor-tts-play-icon-size) * 1.1);
        width: calc(var(--mementor-tts-play-icon-size) * 1.1);
        height: calc(var(--mementor-tts-play-icon-size) * 1.1);
    }

    .mementor-tts-volume-button .dashicons,
    .mementor-tts-speed-button .dashicons,
    .mementor-tts-download-button .dashicons,
    .mementor-tts-info-button .dashicons {
        font-size: calc(var(--mementor-tts-icon-size) * 1.1);
        width: calc(var(--mementor-tts-icon-size) * 1.1);
        height: calc(var(--mementor-tts-icon-size) * 1.1);
    }
}

@media screen and (max-width: 360px) {
    .mementor-tts-custom-controls {
        gap: calc(var(--mementor-tts-spacing-xs) / 2);
    }

    .mementor-tts-volume-button,
    .mementor-tts-speed-button,
    .mementor-tts-download-button,
    .mementor-tts-info-button {
        padding: var(--mementor-tts-spacing-xs);
    }

    .mementor-tts-time-display {
        font-size: calc(var(--mementor-tts-font-size) * 0.85);
    }
} 