/* Root Variables - Consolidate all variables */
:root {
    --primary-color: #5cb85c;
    --secondary-color: #4cae4c;
    --text-color: #333;
    --light-gray: #f4f4f4;
    --border-color: #ddd;
    --header-height: 70px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 2px 5px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
    --radius-sm: 4px;
    --radius-md: 8px;
    --dark-bg: #1a1a1a;
    --dark-text: #f0f0f0;
    --container-width: 1200px;
}

/* Global Styles */
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--light-gray);
    margin: 0;
    padding-top: var(--header-height);
    overflow-x: hidden;
    width: 100%;
}

/* Common Container Styles - Gộp các container styles */
.container,
.header-container,
.hero-section,
.tts-container,
.controls-container,
.model-controls,
.text-input-container,
.language-toolbar,
.vocals-toolbar {
    max-width: var(--container-width);
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
    padding: 20px;
}

/* Header Styles */
.main-header {
    background: #fff;
    box-shadow: var(--shadow-md);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    transition: var(--transition);
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Logo Styles */
.logo a {
    text-decoration: none;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
}

.logo span {
    color: var(--primary-color);
    font-weight: 800;
}

/* Navigation Styles */
.main-nav {
    display: flex;
    align-items: center;
    gap: 24px;
}

.nav-links {
    display: flex;
    gap: 20px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    padding: 8px 15px;
    border-radius: 4px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-links a i {
    font-size: 1.1em;
    color: var(--primary-color);
}

.nav-links a:hover {
    background: var(--light-gray);
}

.nav-links a.active {
    color: var(--primary-color);
}

.nav-links a.premium-btn {
    background: var(--primary-color);
    color: white !important;
}

.nav-links a.premium-btn i {
    color: white;
}

.nav-links a.premium-btn:hover {
    background: var(--secondary-color) !important;
    transform: translateY(-1px);
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    /* Ẩn mặc định trên desktop */
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
}

.hamburger {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text-color);
    position: relative;
    transition: var(--transition);
}

.hamburger::before,
.hamburger::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 2px;
    background: var(--text-color);
    transition: var(--transition);
}

.hamburger::before {
    top: -6px;
}

.hamburger::after {
    bottom: -6px;
}

@media (max-width: 768px) {
    .main-nav {
        position: relative;
    }

    .mobile-menu-btn {
        display: block;
        margin-left: auto;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: calc(var(--header-height) - 20px);
        right: 0;
        width: 200px;
        background: #fff;
        flex-direction: column;
        padding: 10px 0;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        border-radius: 4px;
    }

    .nav-links.active {
        display: flex;
    }

    .nav-links li {
        width: 100%;
    }

    .nav-links li a {
        width: 100%;
        padding: 10px 16px;
        justify-content: flex-start;
    }

    .nav-links li a.premium-btn {
        display: inline-flex;
        width: auto;
        padding: 8px 16px;
        margin-left: 16px;
    }

    .nav-links li a i {
        margin-right: 8px;
    }

    .mobile-menu-btn.active .hamburger {
        background: transparent;
    }

    .mobile-menu-btn.active .hamburger::before {
        transform: rotate(45deg);
        top: 0;
    }

    .mobile-menu-btn.active .hamburger::after {
        transform: rotate(-45deg);
        bottom: 0;
    }
}

/* Main Content Styles */
.container {
    max-width: 1000px;
    /* Reduced from 1200px */
    margin: 0 auto;
    padding: 40px 15px;
    /* Adjusted horizontal padding */
    max-width: 1200px;
    /* Match header-container width */
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

/* Hero Section - Updated */
.hero-section {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    margin: 20px auto;
    width: 100%;
    max-width: 1000px;
    box-sizing: border-box;
}

.hero-section h2 {
    font-size: clamp(1.8rem, 4vw, 2.2rem);
    color: var(--text-color);
    margin-bottom: 15px;
    line-height: 1.2;
}

.hero-section p {
    font-size: clamp(1rem, 2vw, 1.1rem);
    color: #666;
    max-width: 500px;
    margin: 0 auto;
    line-height: 1.5;
}

@media (max-width: 768px) {
    .hero-section {
        padding: 30px 15px;
        margin: 15px auto 25px;
    }
}

@media (prefers-color-scheme: dark) {
    .hero-section {
        background: linear-gradient(135deg, #242424 0%, #1a1a1a 100%);
    }

    .hero-section p {
        color: #999;
    }
}

/* Form Controls */
.controls-container {
    background: #fff;
    padding: 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    margin: 20px;
    overflow: visible !important;
    position: relative !important;
    box-sizing: border-box;
    width: calc(100% - 40px);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
    max-width: 1000px;
    width: calc(100% - 30px);
    margin: 15px auto;
}

/* Toggle Styles */
.multilingual-toggle,
.vocals-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
}

.multilingual-toggle input[type="checkbox"],
.vocals-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.multilingual-toggle label,
.vocals-toggle label {
    cursor: pointer;
    user-select: none;
}

/* Toolbar Styles */
.multilingual-toolbar,
.vocals-toolbar {
    background-color: #f5f5f5;
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.multilingual-toolbar .toolbar-content,
.vocals-toolbar .toolbar-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.multilingual-toolbar .toolbar-hint,
.vocals-toolbar .toolbar-hint {
    font-size: 14px;
    color: #666;
}

.multilingual-toolbar .toolbar-example,
.vocals-toolbar .toolbar-example {
    font-size: 13px;
    color: #888;
    font-style: italic;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {

    .multilingual-toolbar,
    .vocals-toolbar {
        background-color: #2a2a2a;
    }

    .multilingual-toolbar .toolbar-hint,
    .vocals-toolbar .toolbar-hint {
        color: #ccc;
    }

    .multilingual-toolbar .toolbar-example,
    .vocals-toolbar .toolbar-example {
        color: #aaa;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .controls-container {
        gap: 12px;
    }

    .multilingual-toggle,
    .vocals-toggle {
        padding: 6px 0;
    }

    .multilingual-toolbar,
    .vocals-toolbar {
        padding: 12px;
        margin: 8px 0;
    }
}

/* Common Button Styles - Gộp các button styles */
.btn,
.primary-btn,
.lang-btn,
.cookie-btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary,
.primary-btn,
.lang-btn {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--secondary-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        position: absolute;
        top: var(--header-height);
        left: 0;
        width: 100%;
        background: white;
        padding: 20px;
        box-shadow: var(--shadow-md);
        flex-direction: column;
        align-items: stretch;
    }

    .nav-links.active {
        display: flex;
    }

    .nav-links a {
        padding: 12px 16px;
    }

    .mobile-menu-btn {
        display: block;
    }

    .hero-section h2 {
        font-size: 2rem;
    }

    .controls-container,
    .text-input-container,
    .language-toolbar {
        width: calc(100% - 30px);
        margin: 15px;
    }

    .container,
    .tts-container,
    .controls-container,
    .text-input-container,
    .language-toolbar {
        width: calc(100% - 20px);
        margin-left: auto;
        margin-right: auto;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 20px;
    }

    .controls-container {
        padding: 16px;
        width: calc(100% - 20px);
        margin: 10px;
    }

    .hero-section h2 {
        font-size: 1.75rem;
    }

    .controls-container,
    .text-input-container,
    .language-toolbar {
        width: calc(100% - 20px);
        margin: 10px;
    }
}

/* TTS Container - Updated */
.tts-container {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    padding: 20px;
    margin: 20px auto;
    max-width: 1000px;
    /* Reduced from 1200px */
    box-sizing: border-box;
    width: 100%;
    max-width: 1200px;
    /* Match container width */
    width: 100%;
    overflow: hidden;
}

@media (max-width: 768px) {
    .tts-container {
        padding: 15px;
        margin: 15px auto;
    }

    .controls-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .voice-controls,
    .model-selection,
    .speed-control {
        width: 100%;
    }

    .model-selection {
        justify-content: flex-start;
    }

    .model-selection label {
        padding: 6px 12px;
        font-size: 0.9em;
    }
}

@media (max-width: 480px) {
    .tts-container {
        padding: 10px;
        margin: 10px auto;
    }

    .controls-container {
        gap: 12px;
    }

    .voice-select {
        padding: 8px;
        font-size: 0.9em;
    }
}

/* Model Controls */
.model-controls {
    padding: 24px;
    margin: 20px auto;
    background: #fff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.model-selection {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    padding: 0;
    margin: 0;
}

.model-selection input[type="radio"] {
    display: none;
}

.model-selection label {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0;
}

.model-selection input[type="radio"]:checked+label {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Voice Controls */
.voice-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 10px 0;
    min-height: 10px;
    margin-top: -40px;
    overflow: visible !important;
    position: relative !important;
}

.voice-select-container {
    display: flex;
    gap: 10px;
    align-items: center;
    width: 100%;
    flex-direction: row; /* Default to horizontal layout */
    overflow: visible; /* Ensure content is not clipped */
    position: relative;
}

/* Ensure proper order by default */
.voice-select-container #voiceSelect {
    order: 1;
    flex: 1;
}

.voice-select-container #voicePreviewBtn {
    order: 2;
    flex-shrink: 0;
}

.voice-preview-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 44px;
    flex-shrink: 0;
    font-size: 16px;
    line-height: 1;
    position: relative;
    overflow: hidden;
}

.voice-preview-btn:hover {
    background: var(--secondary-color);
    transform: translateY(-1px);
}

.voice-preview-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}


.voice-preview-btn.playing {
    background: #e74c3c;
    animation: pulse 1s infinite;
}

.voice-preview-btn.playing i {
    animation: none;
}

.voice-preview-btn.loading {
    background: #f39c12;
    animation: shimmer 1.5s infinite;
    position: relative;
    overflow: hidden;
}

.voice-preview-btn.loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer-slide 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes shimmer {
    0% { background: #f39c12; }
    50% { background: #e67e22; }
    100% { background: #f39c12; }
}

@keyframes shimmer-slide {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Mobile-specific loading states */
@media (max-width: 768px) {
    .voice-preview-btn.loading {
        background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%) !important;
        animation: mobile-shimmer 1.5s infinite !important;
    }
    
    .voice-preview-btn.playing {
        background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%) !important;
        animation: mobile-pulse 1s infinite !important;
    }
}

@keyframes mobile-shimmer {
    0% { 
        background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
        transform: scale(1);
    }
    50% { 
        background: linear-gradient(135deg, #e67e22 0%, #d35400 100%);
        transform: scale(1.02);
    }
    100% { 
        background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
        transform: scale(1);
    }
}

@keyframes mobile-pulse {
    0% { 
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
    }
    50% { 
        transform: scale(1.05);
        box-shadow: 0 4px 12px rgba(231, 76, 60, 0.5);
    }
    100% { 
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
    }
}


#countrySelect,
#voiceSelect {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1em;
    background: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
}

#countrySelect:hover,
#voiceSelect:hover {
    border-color: var(--primary-color);
}

#voiceSelectionDiv {
    opacity: 0;
    height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

#voiceSelectionDiv[style*="display: block"] {
    opacity: 1;
    height: auto;
    margin-top: 15px;
}

.voice-controls label {
    font-weight: 500;
    color: var(--text-color);
    margin-top: 10px;
    display: block;
}

/* Dark mode support for selects */
@media (prefers-color-scheme: dark) {

    #countrySelect,
    #voiceSelect {
        background: var(--dark-bg);
        color: var(--dark-text);
        border-color: var(--border-color);
    }

    #countrySelect:hover,
    #voiceSelect:hover {
        border-color: var(--primary-color);
    }

    .voice-controls label {
        color: var(--dark-text);
    }
}

/* Mobile responsiveness */
@media (max-width: 768px) {

    #countrySelect,
    #voiceSelect {
        padding: 12px;
        font-size: 16px;
        /* Prevent zoom on mobile */
    }

    .voice-controls {
        gap: 12px;
    }
}

#countrySelect {
    margin-bottom: 10px;
}


/* Responsive styles for voice controls */
@media (max-width: 768px) {
    .voice-controls label {
        margin-bottom: 5px;
    }

    #countrySelect,
    #voiceSelect {
        width: 100%;
    }
    
    /* Force mobile layout for voice select container */
    .voice-controls .voice-select-container,
    .voice-select-container {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
        width: 100% !important;
        overflow: visible !important;
        position: relative !important;
    }
    
    /* Force mobile layout for voice preview button */
    .voice-controls .voice-select-container #voicePreviewBtn,
    .voice-select-container #voicePreviewBtn,
    #voicePreviewBtn {
        width: 100% !important;
        margin-top: 0 !important;
        margin-left: 0 !important;
        padding: 14px 16px !important;
        font-size: 15px !important;
        min-height: 48px !important;
        height: 48px !important;
        border-radius: 8px !important;
        background: linear-gradient(135deg, var(--primary-color) 0%, #4a90e2 100%) !important;
        box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        order: 2 !important; /* Force button to appear after select */
        overflow: visible !important;
        position: relative !important;
        z-index: 10 !important;
    }
    
    .voice-controls .voice-select-container #voicePreviewBtn:hover,
    .voice-select-container #voicePreviewBtn:hover,
    #voicePreviewBtn:hover {
        transform: translateY(-2px) !important;
        box-shadow: 0 4px 12px rgba(74, 144, 226, 0.4) !important;
    }
    
    .voice-controls .voice-select-container #voicePreviewBtn:active,
    .voice-select-container #voicePreviewBtn:active,
    #voicePreviewBtn:active {
        transform: translateY(0) !important;
    }
    
    /* Ensure voice select comes first */
    .voice-controls .voice-select-container #voiceSelect,
    .voice-select-container #voiceSelect,
    #voiceSelect {
        order: 1 !important;
        width: 100% !important;
        margin-bottom: 0 !important;
    }
}

/* Tablet optimizations */
@media (min-width: 769px) and (max-width: 1024px) {
    .voice-select-container {
        flex-direction: row !important;
        gap: 12px !important;
        align-items: center !important;
    }
    
    .voice-preview-btn {
        padding: 12px 16px !important;
        font-size: 15px !important;
        min-width: 60px !important;
        height: 48px !important;
        border-radius: 8px !important;
        background: linear-gradient(135deg, var(--primary-color) 0%, #4a90e2 100%) !important;
        box-shadow: 0 2px 6px rgba(74, 144, 226, 0.2) !important;
        order: 2 !important;
    }
    
    .voice-preview-btn:hover {
        transform: translateY(-1px) !important;
        box-shadow: 0 4px 10px rgba(74, 144, 226, 0.3) !important;
    }
    
    #voiceSelect {
        order: 1 !important;
        flex: 1 !important;
    }
}

/* Large screens */
@media (min-width: 1025px) {
    .voice-select-container {
        flex-direction: row !important;
        gap: 10px !important;
        align-items: center !important;
    }
    
    .voice-preview-btn {
        background: linear-gradient(135deg, var(--primary-color) 0%, #4a90e2 100%) !important;
        box-shadow: 0 2px 4px rgba(74, 144, 226, 0.2) !important;
        order: 2 !important;
        flex-shrink: 0 !important;
    }
    
    .voice-preview-btn:hover {
        transform: translateY(-1px) !important;
        box-shadow: 0 4px 8px rgba(74, 144, 226, 0.3) !important;
    }
    
    #voiceSelect {
        order: 1 !important;
        flex: 1 !important;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .voice-preview-btn {
        min-height: 48px !important;
        padding: 12px 16px !important;
        font-size: 15px !important;
        overflow: visible !important;
        position: relative !important;
        z-index: 10 !important;
    }
    
    .voice-preview-btn:active {
        transform: scale(0.98) !important;
        background: var(--secondary-color) !important;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .voice-select-container {
        gap: 6px !important;
        padding: 0 4px !important;
        margin: 0 -4px !important; /* Extend container to prevent clipping */
    }
    
    .voice-preview-btn {
        min-height: 44px !important;
        height: 44px !important;
        padding: 12px 14px !important;
        font-size: 14px !important;
        border-radius: 6px !important;
        overflow: visible !important;
        position: relative !important;
        z-index: 10 !important;
        margin: 0 !important;
        width: calc(100% + 8px) !important; /* Extend button width */
        max-width: none !important;
    }
    
    .voice-controls {
        padding: 8px 0 !important;
        overflow: visible !important;
    }
}

/* iPhone specific optimizations */
@media (max-width: 414px) {
    .voice-select-container {
        gap: 4px !important;
        padding: 0 2px !important;
        margin: 0 -2px !important;
    }
    
    .voice-preview-btn {
        min-height: 42px !important;
        height: 42px !important;
        padding: 10px 12px !important;
        font-size: 13px !important;
        border-radius: 5px !important;
        width: calc(100% + 4px) !important;
        margin: 0 !important;
    }
    
    .voice-controls {
        padding: 6px 0 !important;
    }
}

/* Very small screens (iPhone SE, etc.) */
@media (max-width: 375px) {
    .voice-select-container {
        gap: 3px !important;
        padding: 0 1px !important;
        margin: 0 -1px !important;
    }
    
    .voice-preview-btn {
        min-height: 40px !important;
        height: 40px !important;
        padding: 8px 10px !important;
        font-size: 12px !important;
        border-radius: 4px !important;
        width: calc(100% + 2px) !important;
        margin: 0 !important;
    }
    
    .voice-controls {
        padding: 4px 0 !important;
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    .voice-select-container {
        -webkit-overflow-scrolling: touch !important;
        overflow: visible !important;
    }
    
    .voice-preview-btn {
        -webkit-appearance: none !important;
        -webkit-touch-callout: none !important;
        -webkit-user-select: none !important;
        overflow: visible !important;
        position: relative !important;
        z-index: 999 !important;
    }
}

/* Speed Control */
.speed-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.speed-control input[type="range"] {
    flex: 1;
}

#speedDisplay {
    min-width: 40px;
    text-align: center;
}

/* Multilingual Toggle */
.multilingual-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
}

.multilingual-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

/* Text Input Area */
.text-input-container {
    background: #fff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    margin: 20px;
    padding: 24px;
    box-sizing: border-box;
    width: calc(100% - 40px);
    position: relative;
    max-width: 1000px;
    /* Added max-width */
    width: calc(100% - 30px);
    /* Adjusted from 40px */
    margin: 20px auto;
    /* Changed to auto for horizontal centering */
}

.input-wrapper {
    position: relative;
    margin: 0;
    box-sizing: border-box;
    width: 100%;
}

#textInput {
    display: block;
    width: 100%;
    min-height: 150px;
    padding: 16px;
    margin: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1em;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
    background: #fff;
}

#textInput:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(92, 184, 92, 0.1);
}

.placeholder {
    position: absolute;
    top: 28px;
    left: 28px;
    color: #999;
    pointer-events: none;
    transition: all 0.3s ease;
}

#wordCount {
    margin-top: 12px;
    color: #666;
    font-size: 0.9em;
    text-align: right;
}

@media (max-width: 768px) {
    .text-input-container {
        margin: 15px;
        padding: 16px;
        width: calc(100% - 30px);
    }

    #textInput {
        min-height: 120px;
        padding: 12px;
        font-size: 0.95em;
    }

    .placeholder {
        top: 24px;
        left: 24px;
    }
}

@media (max-width: 480px) {
    .text-input-container {
        margin: 10px;
        padding: 12px;
        width: calc(100% - 20px);
    }

    #textInput {
        min-height: 100px;
        padding: 10px;
        font-size: 0.9em;
    }

    .placeholder {
        top: 20px;
        left: 20px;
        font-size: 0.9em;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .text-input-container {
        background: #242424;
    }

    #textInput {
        background: #333;
        color: var(--dark-text);
        border-color: #404040;
    }

    #textInput:focus {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 2px rgba(92, 184, 92, 0.15);
    }

    #wordCount {
        color: #999;
    }
}

/* Common Toolbar Styles - Gộp các toolbar styles */
.language-toolbar,
.vocals-toolbar {
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    order: 3;
    padding: 15px;
    margin: 10px auto;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
    width: 100%;
    max-width: 1200px;
}

.toolbar-content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin: 0 auto;
    padding: 15px;
    width: 100%;
}

/* Tablet & Mobile Optimizations */
@media (max-width: 1024px) {

    .language-toolbar,
    .vocals-toolbar {
        position: sticky;
        top: calc(var(--header-height) + 10px);
        z-index: 100;
        margin: 10px;
        padding: 10px;
        background: rgba(248, 249, 250, 0.95);
        backdrop-filter: blur(8px);
    }
}

/* Mobile Specific */
@media (max-width: 768px) {

    .language-toolbar,
    .vocals-toolbar {
        width: calc(100% - 20px);
        margin: 8px auto;
        padding: 12px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {

    .language-toolbar,
    .vocals-toolbar {
        background: rgba(36, 36, 36, 0.95);
        border-color: #404040;
    }
}

/* Vocals specific styles */
.vocals-toolbar .toolbar-content {
    border-left: 4px solid #17a2b8;
    padding-left: 15px;
}

#vocalsToolbar ul li {
    color: #666;
    font-style: italic;
}

.toolbar-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #666;
}

.toolbar-example {
    display: none;
}

.toolbar-actions {
    display: flex;
    justify-content: center;
    max-width: 300px;
}

.lang-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95em;
    transition: all 0.2s ease;
}

.lang-btn:before {
    content: none;
}

.lang-btn:hover {
    background: var(--secondary-color);
}

@media (max-width: 768px) {
    .toolbar-actions {
        position: sticky;
        top: 0;
        z-index: 1000;
        background: #f8f9fa;
        padding: 8px;
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        display: flex;
        gap: 8px;
        margin: 0 0 10px 0;
    }

    .toolbar-actions .lang-btn {
        padding: 6px 12px;
        font-size: 0.9em;
    }

    .text-input-container {
        position: relative;
        margin-top: 5px;
    }

    .language-toolbar {
        width: calc(100% - 40px);
        margin: 10px 20px;
        background: #f8f9fa;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    .toolbar-content {
        flex-direction: column;
        gap: 12px;
        padding: 15px;
        width: 100%;
        margin: 0;
        align-items: center;
    }

    .toolbar-hint {
        display: none;
    }

    .toolbar-example {
        display: block;
        text-align: center;
        color: #666;
        font-size: 1em;
        margin: 0 0 12px 0;
        order: 1;
        width: 100%;
    }

    .toolbar-actions {
        width: 100%;
        order: 2;
        display: flex;
        justify-content: center;
    }

    .lang-btn {
        width: 100%;
        max-width: 400px;
        padding: 12px 20px;
        font-size: 1em;
        justify-content: center;
    }

    .lang-btn .shortcut {
        display: none;
    }
}

@media (max-width: 480px) {
    .language-toolbar {
        width: calc(100% - 20px);
        margin: 8px auto;
        padding: 12px;
    }

    .toolbar-content {
        flex-direction: column;
        gap: 12px;
        padding: 0;
        width: 100%;
    }

    .toolbar-example {
        text-align: center;
        font-size: 0.9em;
        margin-bottom: 8px;
        order: 1;
        width: 100%;
    }

    .toolbar-actions {
        width: 100%;
        order: 2;
        justify-content: center;
    }

    .lang-btn {
        width: 100%;
        max-width: 400px;
        padding: 12px 20px;
        font-size: 1em;
        justify-content: center;
    }

    /* Voice Controls spacing */
    .voice-controls {
        gap: 12px;
        margin-bottom: 12px;
    }

    .speed-control {
        margin-bottom: 12px;
    }

    /* Consistent spacing */
    .controls-container {
        gap: 12px;
        padding: 15px;
    }
}

/* Even smaller screens */
@media (max-width: 480px) {

    .language-toolbar,
    .vocals-toolbar {
        width: calc(100% - 16px);
        margin: 8px auto;
        padding: 10px;
    }

    .toolbar-content {
        gap: 8px;
    }

    .toolbar-example {
        font-size: 0.85em;
    }

    .controls-container {
        padding: 12px;
        gap: 10px;
    }

    .voice-controls,
    .speed-control {
        gap: 8px;
    }

    .lang-btn {
        padding: 8px;
        font-size: 0.9em;
    }
}

/* Mobile & Tablet Sticky Toolbar Actions */
@media (max-width: 1024px) {
    .toolbar-actions {
        position: sticky;
        top: 0;
        z-index: 1000;
        background: #f8f9fa;
        padding: 8px;
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        display: flex;
        gap: 8px;
        margin: 0 0 10px 0;
    }

    .toolbar-actions .lang-btn {
        padding: 6px 12px;
        font-size: 0.9em;
    }

    .text-input-container {
        position: relative;
        margin-top: 5px;
    }
}

/* Adjust for smaller screens */
@media (max-width: 480px) {
    .toolbar-actions {
        padding: 6px;
    }

    .toolbar-actions .lang-btn {
        padding: 5px 10px;
        font-size: 0.85em;
    }
}

/* Mobile Styles */
@media (max-width: 480px) {
    .text-input-container {
        margin: 10px;
    }

    .lang-btn {
        padding: 6px 12px;
        font-size: 0.9em;
    }

    .toolbar-actions {
        padding: 6px;
        gap: 6px;
    }
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    .language-toolbar {
        background: rgba(45, 45, 45, 0.95);
    }

    .toolbar-actions {
        background: rgba(45, 45, 45, 0.95);
    }
}

/* Action Buttons */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

.primary-btn {
    padding: 12px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.primary-btn:hover {
    background: var(--secondary-color);
}

#downloadLink {
    padding: 12px 24px;
    background: #fff;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 6px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

#downloadLink:hover {
    background: var(--light-gray);
}

@media (max-width: 768px) {
    .action-buttons {
        flex-direction: column;
        align-items: center;
    }

    .action-buttons .primary-btn,
    .action-buttons #downloadLink {
        width: 100%;
        max-width: 300px;
        justify-content: center;
    }

    .toolbar-content {
        flex-direction: column;
        align-items: center;
    }

    .toolbar-hint {
        text-align: center;
        justify-content: center;
    }

    .lang-btn {
        width: 100%;
        max-width: 300px;
        justify-content: center;
    }
}

/* Progress Bar */
#progressContainer {
    margin-top: 20px;
}

.progress {
    height: 6px;
    background: var(--light-gray);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 10px;
}

#progressBar {
    height: 100%;
    background: var(--primary-color);
    width: 0;
    transition: width 0.3s ease;
}

#progressPercentage {
    text-align: center;
    color: #666;
    font-size: 0.9em;
}

#loadingText {
    text-align: center;
    color: #666;
    margin-top: 5px;
}

/* Audio Player */
#audioPlayer {
    margin-top: 20px;
    width: 100%;
    border-radius: 6px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .controls-container {
        grid-template-columns: 1fr;
    }

    .action-buttons {
        flex-direction: column;
    }

    #downloadLink {
        text-align: center;
        justify-content: center;
    }
}

/* Speak button states */
#speakButton:disabled,
#speakButton.processing {
    background-color: #cccccc !important;
    cursor: not-allowed !important;
    opacity: 0.7;
    pointer-events: none;
}

.lang-transition * {
    transition: opacity 0.3s ease-in-out;
}

.fade-out {
    opacity: 0;
}

.primary-btn {
    transition: all 0.3s ease-in-out;
}

/* Footer Styles */
.main-footer {
    background: #fff;
    padding: 60px 0 20px;
    margin-top: 60px;
    border-top: 1px solid var(--border-color);
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 40px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.footer-section h3 {
    color: var(--text-color);
    margin-bottom: 20px;
    font-size: 1.2em;
}

.footer-section ul {
    list-style: none;
    padding: 0;
}

.footer-section ul li {
    margin-bottom: 10px;
}

.footer-section a {
    color: #666;
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-section a:hover {
    color: var(--primary-color);
}

.contact-info li {
    display: flex;
    align-items: center;
    gap: 10px;
}

.donate-info p {
    margin-bottom: 10px;
    font-size: 0.9em;
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block;
    }

    .nav-links {
        display: none !important;
        position: absolute;
        top: var(--header-height);
        left: 0;
        width: 100%;
        background: #fff;
        padding: 20px;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    }

    .nav-links.active {
        display: flex !important;
        flex-direction: column;
    }

    .hero-section {
        padding: 40px 20px;
    }

    .hero-section h2 {
        font-size: 2em;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 30px;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-section {
    animation: fadeIn 0.6s ease;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* Enhanced Loading Wave Animation */
.loading-wave {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 20px 0;
    height: 30px;
    /* Thêm chiều cao cố định */
}

.loading-wave span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    transform-origin: center center;
    animation: wave 1s ease-in-out infinite;
    will-change: transform;
    /* Tối ưu performance */
    -webkit-animation: wave 1s ease-in-out infinite;
    /* Safari support */
}

/* Điều chỉnh delay cho từng dot */
.loading-wave span:nth-child(1) {
    animation-delay: -0.4s;
    -webkit-animation-delay: -0.4s;
}

.loading-wave span:nth-child(2) {
    animation-delay: -0.3s;
    -webkit-animation-delay: -0.3s;
}

.loading-wave span:nth-child(3) {
    animation-delay: -0.2s;
    -webkit-animation-delay: -0.2s;
}

.loading-wave span:nth-child(4) {
    animation-delay: -0.1s;
    -webkit-animation-delay: -0.1s;
}

.loading-wave span:nth-child(5) {
    animation-delay: 0s;
    -webkit-animation-delay: 0s;
}

@keyframes wave {

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

    50% {
        transform: translateY(-15px);
    }
}

@-webkit-keyframes wave {

    0%,
    100% {
        -webkit-transform: translateY(0);
    }

    50% {
        -webkit-transform: translateY(-15px);
    }
}

/* Thêm smooth effect cho dots */
.loading-wave span {
    transition: background-color 0.3s ease;
}

/* Dark mode adjustment */
@media (prefers-color-scheme: dark) {
    .loading-wave span {
        background: var(--primary-color);
        opacity: 0.9;
    }
}

/* Tối ưu cho các thiết bị có màn hình nhỏ */
@media (max-width: 768px) {
    .loading-wave {
        gap: 6px;
        height: 24px;
    }

    .loading-wave span {
        width: 6px;
        height: 6px;
    }
}

/* Add new Loading Animation */
.loading-wave {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 20px 0;
}

.loading-wave span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: wave 1.5s ease-in-out infinite;
}

.loading-wave span:nth-child(1) {
    animation-delay: 0s;
}

.loading-wave span:nth-child(2) {
    animation-delay: 0.1s;
}

.loading-wave span:nth-child(3) {
    animation-delay: 0.2s;
}

.loading-wave span:nth-child(4) {
    animation-delay: 0.3s;
}

.loading-wave span:nth-child(5) {
    animation-delay: 0.4s;
}

@keyframes wave {

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

    50% {
        transform: translateY(-10px);
    }
}

/* Enhanced Dark Mode */
@media (prefers-color-scheme: dark) {
    :root {
        --text-color: var(--dark-text);
        --light-gray: #2d2d2d;
        --border-color: #404040;
    }

    body {
        background: var(--dark-bg);
        color: var(--dark-text);
    }

    .main-header,
    .tts-container,
    .language-toolbar,
    .main-footer {
        background: #242424;
    }

    .nav-links a:hover {
        background: var(--light-gray);
    }

    #textInput {
        background: #333;
        color: var(--dark-text);
    }

    .hero-section {
        background: linear-gradient(135deg, #242424 0%, #1a1a1a 100%);
    }

    /* Menu dark mode */
    .main-header {
        background: #1a1a1a;
        border-bottom: 1px solid var(--border-color);
    }

    .nav-links a {
        color: var (--dark-text);
    }

    .nav-links a:hover {
        background: #333;
    }

    .nav-links a i {
        color: var(--primary-color);
    }

    .hamburger,
    .hamburger::before,
    .hamburger::after {
        background: var(--dark-text);
    }

    /* Mobile menu in dark mode */
    @media (max-width: 768px) {
        .nav-links {
            background: #1a1a1a;
            border: 1px solid var(--border-color);
        }
    }

    /* TTS Container dark mode */
    .tts-container {
        background: #1a1a1a;
        border: 1px solid var(--border-color);
    }

    .controls-container {
        background: #242424;
        border: 1px solid var(--border-color);
    }

    #countrySelect,
    #voiceSelect {
        background: #333;
        color: var(--dark-text);
        border-color: var(--border-color);
    }

    #countrySelect:hover,
    #voiceSelect:hover {
        border-color: var(--primary-color);
    }

    .model-controls {
        background-color: #1a1a1a !important;
        /* Force override with !important */
        border: 1px solid var(--border-color);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }

    .model-selection label {
        background: #333;
        color: var(--dark-text);
        border-color: #404040;
    }

    .model-selection label:hover {
        background: #3a3a3a;
        border-color: var (--primary-color);
    }

    .model-selection input[type="radio"]:checked+label {
        background: var(--primary-color);
        color: white;
        border-color: transparent;
    }

    .form-group label {
        color: var(--dark-text);
    }

    /* Tooltips và hints trong model controls */
    .model-controls .hint,
    .model-controls .tooltip {
        color: #999;
    }

    /* Speed control dark mode */
    .speed-control input[type="range"] {
        background: #333;
    }

    #speedDisplay {
        color: var(--dark-text);
    }

    /* Loading wave dark mode */
    .loading-wave span {
        background: var(--primary-color);
        opacity: 0.9;
    }
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .controls-container {
        gap: 15px;
    }

    .voice-select {
        font-size: 0.95em;
        padding: 10px;
    }

    .speed-control {
        flex-direction: column;
        align-items: stretch;
    }

    #textInput {
        font-size: 1.1em;
        padding: 15px;
    }

    .action-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .primary-btn,
    #downloadLink {
        width: 100%;
        justify-content: center;
        padding: 15px;
        font-size: 1.1em;
    }

    #progressContainer {
        margin-top: 15px;
    }

    #loadingText {
        font-size: 0.9em;
        line-height: 1.5;
    }
}

/* 🆕 Donation Message Styling */
.donation-message {
    background: linear-gradient(135deg, #f8f9ff 0%, #e8f0ff 100%);
    border: 1px solid #d1e7ff;
    border-radius: 12px;
    padding: 15px;
    margin: 10px 0;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.1);
}

.donation-message p {
    margin: 8px 0 !important;
    line-height: 1.4 !important;
}

.donation-message .coffee-emoji {
    font-size: 1.2em;
    margin: 0 5px;
}

.donation-message .bank-info {
    background: #007bff;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    display: inline-block;
    margin-top: 5px;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
}

/* Dark mode for donation message */
@media (prefers-color-scheme: dark) {
    .donation-message {
        background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
        border-color: #404040;
        color: var(--dark-text);
    }
    
    .donation-message .bank-info {
        background: #0056b3;
    }

    .multilingual-toggle input[type="checkbox"] {
        width: 18px;
        height: 18px;
    }

    .model-selection label {
        padding: 10px 20px;
    }
}

/* Accessibility Improvements */
:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }

    .loading-wave span {
        animation: none !important;
    }
}

[aria-hidden="true"] {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.cookie-banner {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    width: 90%;
    max-width: 480px;
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    animation: slideUp 0.3s ease;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.cookie-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.cookie-content p {
    color: #666;
    line-height: 1.5;
    margin: 0;
    text-align: center;
}

.cookie-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.cookie-btn:hover {
    background: var(--secondary-color);
    transform: translateY(-1px);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

@media (max-width: 480px) {
    .cookie-banner {
        bottom: 0;
        width: 100%;
        max-width: none;
        border-radius: 12px 12px 0 0;
    }
}

/* Tablet & Mobile Optimizations */
@media (max-width: 1024px) {

    .language-toolbar[style*="display: flex"],
    .language-toolbar[style*="display: block"],
    .vocals-toolbar[style*="display: block"] {
        position: sticky;
        top: calc(var(--header-height) + 10px);
        z-index: 100;
        margin: 10px;
        padding: 10px;
        background: rgba(248, 249, 250, 0.95);
        backdrop-filter: blur(8px);
        order: 3;
    }
}

/* Mobile Specific Optimizations */
@media (max-width: 480px) {

    .language-toolbar,
    .vocals-toolbar {
        margin: 8px;
        padding: 8px;
    }

    .toolbar-content {
        flex-direction: column;
        gap: 8px;
    }

    .toolbar-example {
        font-size: 0.85em;
        text-align: center;
        margin: 0;
    }

    .toolbar-actions {
        width: 100%;
    }

    .lang-btn {
        width: 100%;
        justify-content: center;
    }

    .lang-btn .shortcut {
        display: none;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {

    .language-toolbar,
    .vocals-toolbar {
        background: rgba(36, 36, 36, 0.95);
        border-color: #404040;
    }

    .toolbar-example {
        color: #999;
    }

    @media (max-width: 768px) {

        .language-toolbar[style*="display: flex"],
        .language-toolbar[style*="display: block"],
        .vocals-toolbar[style*="display: block"] {
            background: rgba(36, 36, 36, 0.95);
        }
    }
}

/* Responsive adjustments */
@media (max-width: 1024px) {

    .hero-section,
    .tts-container {
        width: calc(100% - 30px);
        margin: 15px auto;
    }
}

@media (max-width: 768px) {

    .hero-section,
    .tts-container {
        width: calc(100% - 20px);
        margin: 10px auto;
        padding: 15px;
    }
}

@media (max-width: 480px) {

    .hero-section,
    .tts-container {
        width: calc(100% - 16px);
        margin: 8px auto;
        padding: 12px;
    }
}

/* Fix horizontal scroll on mobile/tablet */
@media screen and (max-width: 1024px) {
    body {
        overflow-x: hidden;
        width: 100%;
    }

    .container,
    .tts-container,
    .controls-container,
    .text-input-container,
    .language-toolbar,
    .vocals-toolbar {
        width: calc(100% - 30px);
        margin-left: auto;
        margin-right: auto;
        box-sizing: border-box;
        overflow: visible;
    }

    .header-container {
        width: calc(100% - 30px);
        padding: 0;
    }
}

@media screen and (max-width: 768px) {

    .container,
    .tts-container,
    .controls-container,
    .text-input-container,
    .language-toolbar,
    .vocals-toolbar,
    .header-container {
        width: calc(100% - 20px);
    }
}

@media screen and (max-width: 480px) {

    .container,
    .tts-container,
    .controls-container,
    .text-input-container,
    .language-toolbar,
    .vocals-toolbar,
    .header-container {
        width: calc(100% - 16px);
    }
}

/* Container alignments */
.header-container,
.hero-section,
.tts-container,
.controls-container,
.model-controls,
.text-input-container,
.language-toolbar,
.vocals-toolbar {
    max-width: 1200px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

/* Model Controls alignment */
.model-controls {
    padding: 24px;
    margin: 20px auto;
    background: #fff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.model-selection {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    padding: 0;
    margin: 0;
}

/* Responsive adjustments */
@media screen and (max-width: 1024px) {

    .header-container,
    .hero-section,
    .tts-container,
    .controls-container,
    .model-controls,
    .text-input-container,
    .language-toolbar,
    .vocals-toolbar {
        width: calc(100% - 30px);
        padding-left: 15px;
        padding-right: 15px;
    }
}

@media screen and (max-width: 768px) {

    .header-container,
    .hero-section,
    .tts-container,
    .controls-container,
    .model-controls,
    .text-input-container,
    .language-toolbar,
    .vocals-toolbar {
        width: calc(100% - 20px);
        padding-left: 10px;
        padding-right: 10px;
    }
}

@media screen and (max-width: 480px) {

    .header-container,
    .hero-section,
    .tts-container,
    .controls-container,
    .model-controls,
    .text-input-container,
    .language-toolbar,
    .vocals-toolbar {
        width: calc(100% - 16px);
        padding-left: 8px;
        padding-right: 8px;
    }
}

#voiceSelectionDiv {
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

#voiceSelectionDiv[style*="display: block"] {
    opacity: 1;
    transform: translateY(0);
}

/* Language Transition */
.lang-transition {
    opacity: 0.8;
    transition: opacity 0.15s ease-in-out;
}

/* Language Selector Enhancement */
.language-select select {
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: #fff;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
}

.language-select select:hover {
    border-color: var(--primary-color);
}

/* Language Select Styling */
.language-select {
    position: relative;
    display: inline-block;
}

.language-select select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding: 8px 32px 8px 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    cursor: pointer;
    font-size: 14px;
}

.language-select::after {
    content: '\f0d7';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .language-select select {
        padding: 6px 28px 6px 12px;
        font-size: 13px;
    }
}

/* Enhanced Link Styles */
a {
    color: var(--primary-color);
    text-decoration: none;
    position: relative;
    transition: color 0.3s ease;
    outline: none;
}

a:hover {
    color: var(--secondary-color);
}

/* Remove focus outline and add custom focus style */
a:focus {
    outline: none;
}

a:focus-visible {
    box-shadow: 0 0 0 2px rgba(92, 184, 92, 0.2);
    border-radius: 2px;
}

/* Add subtle underline effect on hover */
a:not(.logo a):not(.nav-links a):not(.premium-btn):after {
    content: '';
    position: absolute;
    width: 100%;
    height: 1px;
    bottom: -2px;
    left: 0;
    background-color: var(--primary-color);
    transform: scaleX(0);
    transform-origin: bottom right;
    transition: transform 0.3s ease;
}

a:not(.logo a):not(.nav-links a):not(.premium-btn):hover:after {
    transform: scaleX(1);
    transform-origin: bottom left;
}

/* Footer link specific styles */
.footer-section a {
    color: #666;
    padding: 2px 0;
}

.footer-section a:hover {
    color: var(--primary-color);
}

.contact-info a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.contact-info a:hover {
    background-color: rgba(92, 184, 92, 0.1);
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    a {
        color: #7cc17c;
    }

    .footer-section a {
        color: #999;
    }

    .footer-section a:hover {
        color: #7cc17c;
    }

    .contact-info a:hover {
        background-color: rgba(92, 184, 92, 0.15);
    }
}

/* Vocals Mode Styles */
.vocals-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
}

.vocals-toggle input[type="checkbox"] {
    margin-right: 8px;
}

.vocals-toolbar {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 15px;
    margin: 10px auto;
    position: relative;
    max-width: 1200px;
    display: none;
    order: 3;
}

.vocals-toolbar .toolbar-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.vocals-toolbar .toolbar-hint {
    font-size: 14px;
    color: #666;
}

.vocals-toolbar .toolbar-example {
    font-size: 13px;
    color: #888;
    font-style: italic;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .vocals-toolbar {
        background-color: #2a2a2a;
    }

    .vocals-toolbar .toolbar-hint {
        color: #ccc;
    }

    .vocals-toolbar .toolbar-example {
        color: #aaa;
    }
}

/* Common Input Styles - Gộp các input styles */
.multilingual-toggle input[type="checkbox"],
.vocals-toggle input[type="checkbox"],
#vocalsToggle {
    width: 18px !important;
    height: 18px !important;
    margin: 0;
    cursor: pointer;
    vertical-align: middle;
}

@media (max-width: 768px) {

    .multilingual-toggle input[type="checkbox"],
    #vocalsToggle {
        width: 18px !important;
        height: 18px !important;
        margin: 0;
        cursor: pointer;
        vertical-align: middle;
    }
}

/* Đảm bảo thứ tự hiển thị các phần tử */
.tts-container {
    display: flex;
    flex-direction: column;
}

.controls-container {
    order: 1;
}

.model-controls {
    order: 2;
}

.language-toolbar {
    order: 3;
}

.vocals-toolbar {
    order: 3;
}

.text-input-container {
    order: 4;
}

.action-buttons {
    order: 5;
}

#progressContainer {
    order: 6;
}

#audioPlayer {
    order: 7;
}

/* Media Queries - Consolidated */
@media (max-width: 1024px) {

    .container,
    [class*="-container"],
    [class*="-toolbar"] {
        width: calc(100% - 30px);
        padding: 15px;
    }
}

@media (max-width: 768px) {
    /* ...existing mobile styles... */

    .container,
    .tts-container,
    .controls-container,
    .text-input-container,
    .language-toolbar,
    .vocals-toolbar,
    .header-container {
        width: calc(100% - 20px);
        padding: 10px;
    }
}

@media (max-width: 480px) {
    /* ...existing small screen styles... */

    .container,
    .tts-container,
    .controls-container,
    .text-input-container,
    .language-toolbar,
    .vocals-toolbar,
    .header-container {
        width: calc(100% - 16px);
        padding: 8px;
    }
}

/* Content Pages Styles */
.content-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
    line-height: 1.8;
}

.content-page h1 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 10px;
    text-align: center;
}

.content-page h2 {
    font-size: 1.8rem;
    color: var(--text-color);
    margin: 40px 0 20px 0;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

.content-page h3 {
    font-size: 1.4rem;
    color: var(--text-color);
    margin: 30px 0 15px 0;
}

.content-page p {
    margin-bottom: 20px;
    color: #555;
}

.content-page ul, .content-page ol {
    margin: 20px 0;
    padding-left: 30px;
}

.content-page li {
    margin-bottom: 10px;
    color: #555;
}

.last-updated {
    text-align: center;
    color: #888;
    font-style: italic;
    margin-bottom: 40px;
}

.intro-text {
    text-align: center;
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 40px;
}

/* Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin: 40px 0;
}

.feature-card {
    background: #fff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.feature-card h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.feature-card p {
    color: #666;
    line-height: 1.6;
}

/* User Types */
.user-types {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
    margin: 30px 0;
}

.user-type {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 25px;
    border-radius: 10px;
    text-align: center;
    border-left: 4px solid var(--primary-color);
}

.user-type h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 30px;
    margin: 40px 0;
    text-align: center;
}

.stat-item h3 {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 10px;
    font-weight: bold;
}

.stat-item p {
    color: #666;
    font-size: 1.1rem;
    font-weight: 500;
}

/* Contact Methods */
.contact-methods {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin: 40px 0;
}

.contact-method {
    background: #fff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    text-align: center;
    transition: transform 0.3s ease;
}

.contact-method:hover {
    transform: translateY(-5px);
}

.contact-icon {
    width: 60px;
    height: 60px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    color: white;
    font-size: 1.5rem;
}

.contact-method h3 {
    color: var(--text-color);
    margin-bottom: 10px;
}

.contact-method p {
    color: #666;
    margin-bottom: 15px;
}

.contact-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.contact-link:hover {
    color: var(--secondary-color);
}

/* Contact Form */
.contact-form-section {
    background: #f8f9fa;
    padding: 40px;
    border-radius: 12px;
    margin: 40px 0;
}

.contact-form {
    max-width: 600px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

/* FAQ Section */
.faq-section {
    margin: 60px 0;
}

.faq-list {
    margin-top: 30px;
}

.faq-item {
    background: #fff;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.faq-item h3 {
    background: var(--primary-color);
    color: white;
    padding: 20px;
    margin: 0;
    font-size: 1.2rem;
}

.faq-item p {
    padding: 20px;
    margin: 0;
    color: #555;
    line-height: 1.6;
}

/* Support Section */
.support-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    margin: 40px 0;
}

.support-section h2 {
    color: white;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
}

.support-section p {
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 30px;
}

.urgent-contact {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

/* CTA Buttons */
.cta-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 40px 0;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
}

.btn-secondary {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-secondary:hover {
    background: var(--primary-color);
    color: white;
}

.btn-urgent {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.btn-urgent:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* Responsive Design for Content Pages */
@media (max-width: 768px) {
    .content-page {
        padding: 20px 15px;
    }
    
    .content-page h1 {
        font-size: 2rem;
    }
    
    .content-page h2 {
        font-size: 1.5rem;
    }
    
    .features-grid,
    .user-types,
    .contact-methods {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .contact-form-section {
        padding: 20px;
    }
    
    .urgent-contact {
        flex-direction: column;
        align-items: center;
    }
    
    .cta-buttons {
        flex-direction: column;
        align-items: center;
    }
}

/* Dark Mode - Consolidated */
@media (prefers-color-scheme: dark) {
    :root {
        --text-color: var(--dark-text);
        --light-gray: #2d2d2d;
        --border-color: #404040;
    }

    body {
        background: var(--dark-bg);
    }

    .main-header,
    .tts-container,
    .language-toolbar,
    .main-footer,
    .model-controls {
        background: #242424;
    }

    /* Content pages dark mode */
    .content-page {
        background: var(--dark-bg);
        color: var(--dark-text);
    }
    
    .content-page h2 {
        color: var(--dark-text);
        border-bottom-color: var(--primary-color);
    }
    
    .content-page h3 {
        color: var(--dark-text);
    }
    
    .content-page p,
    .content-page li {
        color: #ccc;
    }
    
    .feature-card,
    .contact-method,
    .faq-item {
        background: #2a2a2a;
        color: var(--dark-text);
    }
    
    .faq-item h3 {
        background: var(--primary-color);
    }
    
    .user-type {
        background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
    }
    
    .contact-form-section {
        background: #2a2a2a;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        background: #333;
        color: var(--dark-text);
        border-color: #555;
    }
    
    .form-group input:focus,
    .form-group select:focus,
    .form-group textarea:focus {
        border-color: var(--primary-color);
    }

    /* ...existing dark mode styles... */
}

/* Enhanced UI Components */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

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

/* Enhanced Button Styles */
.btn-enhanced {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.btn-enhanced::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn-enhanced:hover::before {
    left: 100%;
}

/* Card Hover Effects */
.card-hover {
    transition: all 0.3s ease;
}

.card-hover:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

/* Gradient Text */
.gradient-text {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Improved Progress Bar */
.progress-bar-enhanced {
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    background: #f0f0f0;
}

.progress-bar-enhanced::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2, #667eea);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Notification Styles */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #4CAF50;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.notification.show {
    transform: translateX(0);
}

.notification.error {
    background: #f44336;
}

.notification.warning {
    background: #ff9800;
}

/* Tooltip Styles */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 200px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 8px 12px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 14px;
}

.tooltip .tooltiptext::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* Responsive Improvements */
@media (max-width: 768px) {
    .notification {
        right: 10px;
        left: 10px;
        transform: translateY(-100%);
    }
    
    .notification.show {
        transform: translateY(0);
    }
    
    .tooltip .tooltiptext {
        width: 150px;
        margin-left: -75px;
    }
}

