.group {
    position: relative !important;
    overflow: visible !important;
    /* quan trọng vì để ngăn không bị cắt phần dropdown voice  mở ra ra*/
}

/* Clear Float */
#a-text-to-speech-box.clear {
    clear: both;
}

/* Hidden Elements */
#a-text-to-speech-box .hidden-voice {
    display: none;
}

/* Links */
#a-text-to-speech-box a {
    color: #054fcb;
    text-decoration: none;
    font-size: 90%;
}

#a-text-to-speech-box a:hover {
    color: blue;
    transform: translateY(-1px);
    text-shadow: 0 0 1px rgba(0, 0, 0, 0.3);
}

/* ==================================================
   2. FORM INTERFACE
   ================================================== */

/* Main Form Container */
#atts-form {
    border-radius: 5px;
    padding: 5px 10px 10px 10px;
    margin: 0px;
    display: block;
    background: #f6f6f6;
}

/* Table Layout for Form */
#a-text-to-speech-box table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    margin: 0;
    font-size: 100%;
}

#a-text-to-speech-box .td1 {
    width: 20%;
    min-width: 100px;
    vertical-align: middle;
}

#a-text-to-speech-box .td2 {
    text-align: left;
    vertical-align: middle;
}

/* Input Elements */
#a-text-to-speech-box .td2 select {
    font-size: 100%;
    min-width: 170px;
    padding: 5px;
    border: 1px solid #e5e5e5;
    border-radius: 5px;
    box-sizing: border-box;
}

#a-text-to-speech-box textarea {
    resize: none;
    display: block;
    font-size: 100%;
    width: 100%;
    min-height: 160px;
    max-height: 50vh;
    padding: 8px;
    padding-bottom: 20px;
    margin: 4px 0;
    border: 2.5px solid #f6f6f6;
    border-radius: 5px;
    box-sizing: border-box;
    margin-bottom: -3px;
    /* overflow: hidden; */
    /* ẩn thanh cuộn khi auto-grow */
    /* resize: none; */
    /* chặn kéo resize thủ công */
    /* font-family: monospace; */
    transition: border-color 0.3s ease;
}

#a-text-to-speech-box textarea:hover {
    border: 2.5px solid #4353ff;
    box-shadow: 0 0 0 4px rgba(0, 124, 186, 0.1);
    box-sizing: border-box;
    margin-bottom: -3px;
}

#a-text-to-speech-box textarea::placeholder {
    font-style: italic;
    color: #aaa;
    opacity: 1;
}


#a-text-to-speech-box textarea:focus {
    outline: none;
    border-color: #054fcb;
    box-shadow: 0 0 0 4px rgba(0, 124, 186, 0.1);
}


#a-text-to-speech-box .atts-form-group {
    padding: 0;
    margin-bottom: 10px;
}

#a-text-to-speech-box .atts-textarea-group {
    margin-bottom: -10px;
}

#a-text-to-speech-box .atts-form-group p {
    margin: 0;
    padding: 0;
}

#a-text-to-speech-box .atts-button-group {
    display: block;
    padding: 10px 0px;
}

#a-text-to-speech-box .atts-button-group:hover button {
    color: #fff;
    background: #4353ff;
}




/* Radio Buttons and Checkboxes */
#a-text-to-speech-box .td2 input[type="checkbox"] {
    vertical-align: middle;
    margin-right: 5px;
}

#a-text-to-speech-box input[type="radio"] {
    vertical-align: middle;
    margin-right: 5px;
}

#a-text-to-speech-box .td2 input[type="radio"] {
    margin-right: 0 !important;
}

#a-text-to-speech-box .radio-type {
    vertical-align: middle;
    font-size: 70% !important;
}

#atts-form .radio-group {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

/* Labels */
#a-text-to-speech-box label {
    font-size: 90%;
    margin-right: 0;
}

#a-text-to-speech-box .td2 input[type="radio"]+label {
    margin-right: 0;
}

/* Form Element Hover Effects */
#a-text-to-speech-box input[type="radio"]:hover,
#a-text-to-speech-box input[type="checkbox"]:hover,
#a-text-to-speech-box select:hover {
    cursor: pointer;
    outline: none;
    border-color: #999;
}

#a-text-to-speech-box .atts-char-count-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 5px;
    font-size: 14px;
    position: relative;
    top: -20px;
    font-size: 70%;
    margin: 5px 5px 5px 4px;
    padding: 0px;
    line-height: 1.2;
}

#a-text-to-speech-box .atts-char-count {
    color: #555;
    border-radius: 5px;
    background: #ffffff;
    padding: 0px 6px;
}

#a-text-to-speech-box .atts-clear-text {
    color: #555;
    cursor: pointer;
    border-radius: 5px;
    padding: 0px 5px 0px 5px;
    margin: 0px 0px;
    background: #fff;
}

#a-text-to-speech-box .atts-clear-text:hover {
    color: #fff;
    background: #c82333;
}


/* ==================================================
   3. BUTTON SYSTEM
   ================================================== */

/* Primary Form Submit Button */
#a-text-to-speech-box .atts-form .atts-button-group button {
    background-color: #3c4145;
    color: #e9eae9;
    line-height: 1.4;
    padding: 2px 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 100%;
    text-shadow: 0 0 0 transparent;
    transition: all 0.2s ease;
}

#a-text-to-speech-box .atts-form .atts-button-group button:hover {
    color: #fff;
    background: #4353ff;
    text-shadow: 0 0 1px rgba(255, 255, 255, 0.3);
    animation: attsButtonAttention 0.0s ease;
}

#a-text-to-speech-box .create-speech-icon {
    font-size: 0;
    fill: currentColor;
    vertical-align: middle;
}

/* Voice Options Button */
#a-text-to-speech-box .atts-show-more button {
    background: none;
    color: #054fcb;
    border: none;
}

#a-text-to-speech-box .atts-show-more button:hover {
    background: none;
    color: #054fcb;
    border: none;
}


#a-text-to-speech-box .advanced-options {
    display: none;
}

#a-text-to-speech-box .show-advanced-options,
#a-text-to-speech-box .hide-advanced-options {
    margin: 10px 0;
    cursor: pointer;
    color: #007bff;
    text-align: right;
}

/* Reset Options */
#a-text-to-speech-box .reset-all-options {
    text-align: right;
    padding: 10px;
    font-size: 80%;
}

#a-text-to-speech-box .reset-all-options a {
    opacity: 0.6;
    display: inline-block;
}

/* Class để bật hiệu ứng gây chú ý cho nút */
@keyframes attsButtonAttention {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-4px);
    }

    40% {
        transform: translateX(4px);
    }

    60% {
        transform: translateX(-3px);
    }

    80% {
        transform: translateX(3px);
    }
}

#a-text-to-speech-box .atts-form .atts-attention {
    animation: attsButtonAttention 0.4s ease;
}

/* Kết thúc hiệu ứng gây chú ý cho nút */
/* ==================================================
   8. LOADING STATES
   ================================================== */

#a-text-to-speech-box .loading-container {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin: 5px 0;
}

#a-text-to-speech-box .loading-spinner {
    width: 18px;
    height: 18px;
    aspect-ratio: 1 / 1;
    /* luôn giữ tỉ lệ hình vuông */
    border: 2px solid #c1c1c1;
    border-top: 2px solid #0762ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 5px 5px 5px 0;
    box-sizing: border-box;
    flex-shrink: 0;
    /* ngăn flex làm méo */
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}


/* ==================================================
   9. AUDIO & DOWNLOAD COMPONENTS
   ================================================== */

#atts-audio {
    margin-top: 20px;
    width: 100%;
}

#atts-download {
    margin-top: 20px;
    display: none;
    text-align: center;
}


#a-text-to-speech-box .speech-output {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin: 10px 0;
    padding: 10px;
    border: none;
    border-radius: 6px;
    background: #f3f3f3;
}

#a-text-to-speech-box .speech-output button {
    font-size: 90%;
    height: 20px;

    box-sizing: border-box;
    border: 1.5px solid #e3e3e3;
}

#a-text-to-speech-box .speech-output:hover .preview-button {
    border: 1.5px solid #4353ff;
    box-shadow: 0 0 0 4px rgba(0, 124, 186, 0.1);
}

#a-text-to-speech-box .speech-output-success {
    flex: 1;
    text-align: left;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

#a-text-to-speech-box .speech-output-success p {
    margin-bottom: 0 !important;
}

#a-text-to-speech-box .speech-output-success {}

#a-text-to-speech-box .success-icon {
    color: green;
    width: 14px;
    font-size: 13px;
    fill: currentColor;
    vertical-align: middle;
}

#a-text-to-speech-box .success-text {
    color: green;
}

#a-text-to-speech-box .speech-text-display {
    font-weight: bold;
}


#a-text-to-speech-box .speech-action-button-container {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 0 0 auto;
}

#a-text-to-speech-box .speech-output-play-button,
#a-text-to-speech-box .speech-output-download-button {
    text-align: center;
}


/* ==================================================
   6. SPEECH HISTORY SECTION
   ================================================== */
#a-text-to-speech-box .speech-history {
    padding-bottom: 10px;
}

#a-text-to-speech-box .speech-history h3 {
    font-size: 100%;
    font-weight: normal;
    margin-top: 10px;
}

#a-text-to-speech-box .speech-history small {
    font-size: 80%;
    color: #666b70;
    font-style: italic;
}

#a-text-to-speech-box .speech-history .speech-list-wrap {
    margin: -10px;
    padding: 10px 0;
}

#a-text-to-speech-box .speech-history .speech-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid #f0f0f0;
    overflow: hidden;
    background: #fff;
}

#a-text-to-speech-box .speech-history .speech-item {
    display: flex;
    align-items: center;
    min-height: 36px;
    padding: 5px 10px;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
}

#a-text-to-speech-box .speech-history .speech-item:last-child {
    border-bottom: none;
}

#a-text-to-speech-box .speech-history .speech-item:hover {
    background-color: #f1f2f2;
}

#a-text-to-speech-box .speech-history .title-col {
    flex: 1;
    text-align: left;
}

#a-text-to-speech-box .speech-history .speech-title {
    color: #3c4147;
    font-size: 95%;
    font-weight: normal;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

#a-text-to-speech-box .speech-history .action-button-container-col {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

#a-text-to-speech-box .speech-history .play-col,
#a-text-to-speech-box .speech-history .share-col,
#a-text-to-speech-box .speech-history .download-col {
    flex: 0 0 auto;
}

/* Textarea error state */
#a-text-to-speech-box textarea.atts-textarea-error,
#a-text-to-speech-box textarea.atts-textarea-error:focus {
    outline: none;
    border-color: #ff0019 !important;
    box-shadow: 0 0 0 4px rgba(237, 30, 11, 0.232);
    transition: border-color 0.3s;
}


/* Bắt đầu css cho nhắc nhở người dùng */
#a-text-to-speech-box .atts-button-group {
    display: flex !important;
    align-items: center;
    gap: 5px;
}

#a-text-to-speech-box .atts-button {
    flex: 0 0 auto;
    /* giữ kích thước đúng theo nội dung, không co giãn */
}

#a-text-to-speech-box .tts-reminder {
    flex: 1;
    /* chiếm toàn bộ phần còn lại */
    text-align: left;
    background: #ffffff;
    border-radius: 10px;
    padding: 5px 10px;
    margin-left: 10px;
    font-size: 90%;
    transition: transform 0.3s ease, opacity 0.3s ease;
    position: relative;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    /* nhẹ nhàng hơn */
}

#a-text-to-speech-box .tts-reminder strong {
    color: #4353ff;
    white-space: nowrap;
}

/* Tam giác chỉa về nút bấm */
#a-text-to-speech-box .tts-reminder::before {
    content: "";
    position: absolute;
    left: -8px;
    /* vị trí ngang, để tam giác dính vào bong bóng */
    top: 50%;
    /* căn giữa theo chiều dọc */
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 8px solid #ffffff;
    filter: drop-shadow(-1px 1px 1px rgba(0, 0, 0, 0.05));
}

/* Kết thúc css cho nhắc nhở người dùng */

/* ==================================================
   7. ADVANCED OPTIONS & SETTINGS
   ================================================== */

/* ==================================================
   NOTIFICATION - Thông báo lỗi rate limit
   ================================================== */
#a-text-to-speech-box .atts-display-notification {
    margin: 10px 0;
}

#a-text-to-speech-box .atts-notification-error {
    background-color: #fee;
    border: 1px solid #fcc;
    border-radius: 5px;
    padding: 10px 15px;
    animation: atts-shake 0.3s ease-in-out;
}

#a-text-to-speech-box .atts-error-message {
    color: #c33;
    font-weight: 500;
    margin: 0;
    font-size: 95%;
    line-height: 1.5;
}

/* Animation shake cho notification */
@keyframes atts-shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}


#a-text-to-speech-box .atts-error-page-reload-button {
    font-weight: bold;
}

#a-text-to-speech-box .button-disabled {
    opacity: 0.8 !important;
    /* cursor: not-allowed !important; */
}


/* Bắt đầu css cho dropdown voice */
#a-text-to-speech-box .voice-options {
    padding: 0;
}

#a-text-to-speech-box .voice-select {
    background: #ececec;
    margin: 2px;
    padding: 0 5px;
    border-radius: 3px;
    display: inline-flex;
    align-items: center;
}


#a-text-to-speech-box .voice-dropdown-container {
    margin-top: 5px;
}

#a-text-to-speech-box .voice-dropdown {
    position: relative;
    display: inline-block;
    width: 100%;
    max-width: 300px;
}

#a-text-to-speech-box .voice-dropdown-selected {
    background: #f6f6f6;
    border: 2px solid #e5e5e5;
    border-radius: 5px;
    padding: 4px 8px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.3s ease;
}

#a-text-to-speech-box .voice-dropdown-selected:hover {
    border-color: #4353ff;
    box-shadow: 0 0 0 4px rgba(67, 83, 255, 0.1);
}

#a-text-to-speech-box .voice-dropdown[data-voice-dropdown-open] .voice-dropdown-selected {
    border-color: #054fcb;
}

#a-text-to-speech-box .voice-dropdown-text {
    font-size: 90%;
    color: #333;
    white-space: nowrap;
    /* Không cho xuống dòng */
    overflow: hidden;
    /* Ẩn phần vượt quá */
    text-overflow: ellipsis;
    /* Hiển thị ... */
    max-width: 200px;
    /* Giới hạn độ rộng để ellipsis hoạt động */
    display: inline-block;
    /* Cần thiết để ellipsis có hiệu lực */
    vertical-align: middle;
    /* Giúp canh hàng đẹp hơn nếu nằm cạnh icon */
}

#a-text-to-speech-box .voice-dropdown-arrow {
    transition: transform 0.3s ease;
    color: #666;
}

#a-text-to-speech-box .voice-dropdown[data-voice-dropdown-open] .voice-dropdown-arrow {
    transform: rotate(180deg);
}

#a-text-to-speech-box .voice-dropdown-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 550px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10;
    margin-top: 5px;
}

#a-text-to-speech-box .voice-dropdown[data-voice-dropdown-open] .voice-dropdown-list {
    display: block;
}

#a-text-to-speech-box .voice-dropdown-item {
    padding: 4px 10px 4px 10px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
}

#a-text-to-speech-box .voice-dropdown-item:last-child {
    border-bottom: none;
}

#a-text-to-speech-box .voice-dropdown-item:hover {
    background-color: #f5f5f5;
}

#a-text-to-speech-box .voice-dropdown-item.voice-dropdown-item-selected {
    font-weight: bold;
    background-color: #f0f0f0;
}

#a-text-to-speech-box .voice-dropdown-item-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

#a-text-to-speech-box .voice-dropdown-item-text {
    font-size: 90%;
    padding: 0px 4px 0px 0px;
    flex: 1;
    min-width: 0;
}

#a-text-to-speech-box .voice-gender-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    padding: 0px 2px;
    font-size: 62%;
    border-radius: 3px;
    font-weight: 500;
    text-align: center;
    flex-shrink: 0;
}

#a-text-to-speech-box .voice-gender-badge.voice-gender-female {
    background-color: #f0f0f0;
    color: #d72a61;
}

#a-text-to-speech-box .voice-gender-badge.voice-gender-male {
    background-color: #f3f3f3;
    /* color: #054fcb; */
}

/* Kết thúc css cho dropdown voice */