/* =========================================
   1. CONTAINER: Fluid Flex Layout
   ========================================= */
/* Default state (empty) */
.btn-sound {
    display: flex;
    border: 0;
    cursor: pointer;
    background-color: transparent;
    /* Use min-content to fit the button before loading, 
       but allow growing once loaded */
    width: auto; 
    height: 50px;
}

/* Active state (when player is loaded) */
.btn-sound:has(.player-controls) {
    /* KEY CHANGE: Use flex properties instead of fixed width */
    width: 100% !important;
    /* height: auto !important; */
    
    /* Allow it to shrink if parent is small, grow up to a limit */
    flex: 1 1 auto;
    min-width: 0; /* Critical for flex items to shrink properly */
    max-width: 245px; /* Ensure it never goes wider than parent */
    background: none !important;
    cursor: default;
    /* margin-top: 10px; */
}

/* =========================================
   2. PLAYER CARD
   ========================================= */
.player-controls {
    display: flex;
    align-items: center;
    gap: 5px;
    
    /* GLASS EFFECT */
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 140, 66, 0.2);
    padding: 8px 3px;
    border-radius: 50px;
    
    /* KEY CHANGE: Ensure the card itself fits the container */
    width: 100%;
    max-width: 100%; /* Never overflow */
    box-sizing: border-box;
    box-shadow: 0 4px 15px rgba(255, 140, 66, 0.1);
}

/* =========================================
   3. INNER ELEMENTS (Buttons & Wave)
   ========================================= */
.play-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #FF8C42 !important;
    color: #ffffff !important;
    flex-shrink: 0; /* Never shrink the button */
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    box-shadow: 0 2px 5px rgba(255, 140, 66, 0.4);
}
.play-btn:hover {
    background-color: #ff7a20 !important;
    transform: scale(1.05);
}
.play-btn svg { width: 20px; height: 20px; fill: currentColor; }

/* WAVEFORM: The "Flexible" Part */
.wave-container {
    flex-grow: 1;    /* Grow to fill remaining space */
    flex-shrink: 1;  /* Shrink if space is tight */
    position: relative;
    min-width: 40px; /* Minimum size before breaking layout */
    overflow: hidden; /* Cut off if absolutely necessary */
}

/* META CONTROLS (Right Side) */
.meta-controls {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0; /* Keep these readable size */
}

.time-text {
    font-family: 'Helvetica Neue', sans-serif;
    font-size: 10px;
    color: #000;
    font-weight: 600;
    white-space: nowrap;
    text-align: right;
    /* Allow time to shrink slightly if very tight, but prefer not to */
    flex-shrink: 0;
}

.speed-btn {
    font-size: 10px;
    font-weight: 700;
    color: #000000;
    background: transparent;
    /* padding: 1px 1px; */
    border-radius: 6px;
    border: none;
    cursor: pointer;
    min-width: 20px;
    text-align: center;
    transition: background 0.2s;
}
.speed-btn:hover { 
    background: #fff; 
    color: #FF8C42; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.05); 
}

.download-btn {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: transparent;
    color: #000 !important;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.2s;
}
.download-btn:hover { 
    background: #fff; 
    color: #FF8C42; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.download-btn svg { width: 16px; height: 16px; fill: currentColor; }

/* =========================================
   4. RESPONSIVE BEHAVIOR
   ========================================= */
@media screen and (max-width: 480px) {
    /* No rigid width here either. Just let it fill parent. */
    .btn-sound:has(.player-controls) {
        /* Optional: You can set a max-width if you WANT it small, 
           but removing it lets flex handle it. */
        width: 100% !important;
        max-width: 200px; 
    }
    .btn-sound {
        height: 40px;
    }
    .player-controls {
        padding: 5px 8px;
        gap: 6px;
    }

    .play-btn {
        width: 32px;
        height: 32px;
    }
    
    .play-btn svg { width: 16px; height: 16px; }

    /* Hide Time on small screens to save space */
    .time-text {
        display: none !important; 
    }
    
    .download-btn {
        width: 26px;
        height: 26px;
    }
}