/* Form Elements */
#openai-tts-generator-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

#openai-tts-generator-form textarea,
#openai-tts-generator-form select,
#openai-tts-generator-form input[type="number"] {
    width: 100%;
    padding: 8px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    box-sizing: border-box;
}

/* Dropdowns Container */
.tts-dropdown-container {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}
span#speed-value {
    display: block;
    /* float: right; */
    font-size: 0.9em;
    color: #777;
    text-align: end;
    margin-bottom: 15px;
}
.tts-dropdown {
    width: calc(50% - 7.5px); /* Ensures two per row with gap */
}

#openai-tts-generator-form button {
    padding: 10px 20px;
    background-color: #0274be;
    color: white;
    border: none;
    cursor: pointer;
    display: block;
    width: 100%;
}

/* Audio Output and History */
#tts-audio-output {
    margin-top: 20px;
}

h2.history-heading {
    margin-top: 20px;
}

ul.tts-history-list {
    padding: 0;
    list-style: none;
}

.tts-history-list li {
    border: 1px solid #eee;
    padding: 15px;
    margin-bottom: 10px;
    background-color: #f9f9f9;
    border-radius: 4px;
}

.tts-history-list li p {
    margin-top: 0;
    margin-bottom: 5px;
}

.tts-history-list li audio {
    width: 100%;
    margin-bottom: 10px;
}

.history-timestamp {
    font-size: 0.9em;
    color: #777;
}

div#tts-generation-history {
    max-height: 420px;
    overflow-y: auto;
    scrollbar-width: thin;
}

/* Character Count */
#tts-char-count {
    font-size: 0.9em;
    color: #777;
    margin-bottom: 10px;
    position: relative;
    top: -50px;
    text-align: right;
    right: 8px;
}

/* Progress Bar */
.progress-bar-container {
    width: 100%;
    background-color: #f0f0f0;
    padding: 3px;
    border-radius: 3px;
    margin: 10px 0;
}

.progress-bar {
    height: 20px;
    background-color: #4CAF50;
    width: 0%;
    border-radius: 2px;
    transition: width 0.3s ease-in-out;
    position: relative;
}

.progress-bar-text {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 12px;
    line-height: 20px;
}

#generate-tts:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Voice Selector Dropdown */
.voice-dropdown .voice-selector {
    position: relative;
    cursor: pointer;
}

.voice-dropdown .voice-selector-display {
    padding: 7px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.voice-dropdown.active .voice-selector-display {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

button.voice-sample-button.play {
    background: transparent !important;
    width: 20% !important;
}

.voice-dropdown .voice-options-container {
   display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    border: 1px solid #ccc;
    border-top: none;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
    overflow: hidden;
    background-color: white;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    max-height: 316px; /* Reduced height */
    overflow-y: auto;   /* Added scrollbar */
}

.voice-options-container {
    scrollbar-width: thin;
}


.voice-dropdown.active .voice-options-container {
    display: block;
}

.voice-dropdown .voice-option {
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.voice-dropdown .voice-option:hover,
.voice-dropdown .voice-option.selected {
    background-color: #f0f0f0;
}

.voice-dropdown .voice-option:not(:last-child) {
    border-bottom: 1px solid #eee;
}

.voice-dropdown .voice-sample-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-left: 10px;
    color: #333;
}

.voice-dropdown .voice-sample-button:focus {
    outline: none;
}

.voice-dropdown .voice-sample-button .dashicons {
    font-size: 20px;
    color: #6495ED;
    float: right;
    line-height: 1;
    width: 20px;
    height: 20px;
}

/* Download Buttons */
.download-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    margin-bottom: 5px;
}

.download-buttons button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    border: none;
    width: auto;
}

.download-buttons .download-audio {
    background-color: #4CAF50;
    color: white;
}

.download-buttons .download-text {
    background-color: #2196F3;
    color: white;
}

.download-buttons button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.download-buttons button:active {
    transform: translateY(0);
}

.download-buttons .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
    line-height: 18px;
}

/* Error States */
.error {
    color: #d32f2f;
    background-color: #ffebee;
    padding: 10px;
    border-radius: 4px;
    margin-top: 10px;
}

/* Responsive Styles */
@media (max-width: 600px) {
    .tts-dropdown {
        width: 100%;
    }

    .voice-dropdown .voice-options-container {
        position: static;
        width: 100%;
        box-shadow: none;
        border-radius: 0;
    }

    .voice-dropdown.active .voice-selector-display {
        border-radius: 4px 4px 0 0;
    }

    .voice-dropdown .voice-selector-display {
        border-radius: 4px;
    }

    .download-buttons {
        flex-direction: column;
    }

    .download-buttons button {
        width: 100%;
    }
}

/* Loading States */
.processing {
    opacity: 0.7;
}

/* Scrollbar Styling */
#tts-generation-history::-webkit-scrollbar {
    width: 6px;
}

#tts-generation-history::-webkit-scrollbar-track {
    background: #f1f1f1;
}

#tts-generation-history::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

#tts-generation-history::-webkit-scrollbar-thumb:hover {
    background: #555;
}