/* General Body and Container Styling */
body {
    font-family: 'Open Sans', sans-serif;
    background: linear-gradient(135deg, #f0e6d6 0%, #e0c8b0 100%);
    color: #4a4a4a;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
}

.container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
    padding: 40px 60px;
    text-align: center;
    max-width: 900px;
    width: 100%;
    transform: translateY(0);
    transition: transform 0.5s ease-out;
}

/* New: Welcome Screen Styling */
.welcome-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f0e6d6 0%, #e0c8b0 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 1000;
    transition: opacity 1s ease-out, visibility 1s ease-out;
}

.welcome-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.welcome-heading {
    font-family: 'Playfair Display', serif;
    font-size: 4em;
    color: #4a235a;
    animation: welcome-fade-in 1.5s ease-out forwards;
}

.welcome-subheading {
    font-size: 1.5em;
    color: #555;
    animation: welcome-fade-in 1.5s ease-out 0.5s forwards;
}

@keyframes welcome-fade-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header Styling */
header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 3em;
    color: #4a235a;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

header p {
    font-size: 1.1em;
    color: #555;
    margin-bottom: 30px;
}

/* Form Section Styling */
.form-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin-bottom: 40px;
}

/* Custom File Input Styling */
.file-input-wrapper {
    display: flex;
    align-items: center;
    gap: 15px;
    background: #ffffff;
    border: 2px solid #ddd;
    border-radius: 10px;
    padding: 10px 20px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    width: 100%;
    max-width: 400px;
}

.file-input-wrapper:hover {
    border-color: #7d4ba6;
    box-shadow: 0 0 10px rgba(125, 75, 166, 0.3);
}

.custom-file-upload {
    background-color: #7d4ba6;
    color: white;
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.custom-file-upload:hover {
    background-color: #6a3a96;
    transform: translateY(-2px);
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.2);
}

#fileInput {
    display: none;
}

.file-name-display {
    flex-grow: 1;
    text-align: left;
    color: #444;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9em;
}

/* Animated Button Styling */
.animated-button {
    background-color: #6a3a96;
    color: white;
    padding: 14px 35px;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    letter-spacing: 1.2px;
    text-transform: uppercase;
}

.animated-button:hover {
    background-color: #4a235a;
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.animated-button:active {
    transform: translateY(0);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.animated-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.4s ease-out, height 0.4s ease-out;
    z-index: 0;
}

.animated-button:hover::before {
    width: 200%;
    height: 200%;
}

.animated-button span {
    position: relative;
    z-index: 1;
}

/* Results Section Styling */
.results-section {
    background: #fdfdfd;
    border: 1px solid #eee;
    border-radius: 15px;
    padding: 30px;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.05);
    margin-top: 30px;
    position: relative;
}

.results-section h3 {
    font-family: 'Playfair Display', serif;
    color: #8367a7;
    font-size: 1.8em;
    margin-bottom: 20px;
}

.description-text {
    font-size: 1.1em;
    line-height: 1.6;
    color: #333;
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
    min-height: 100px;
    text-align: left;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.copy-button {
    margin-top: 20px;
    padding: 8px 20px;
    font-size: 0.95em;
    background-color: #4CAF50;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.copy-button:hover {
    background-color: #45a049;
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.2);
}

/* New: Styles for Translation and TTS Buttons */
.translation-buttons, .tts-section {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

.translation-buttons .animated-button, .tts-section .animated-button {
    background-color: #a779c1;
    padding: 10px 20px;
    font-size: 0.95em;
}

.translation-buttons .animated-button:hover, .tts-section .animated-button:hover {
    background-color: #6a4c93;
}


/* New: Styles for the speaking rate control */
.speaking-rate-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

.speaking-rate-control label {
    font-size: 0.9em;
    color: #6a4c93;
    font-weight: bold;
}

.speaking-rate-control input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 150px;
    height: 8px;
    background: #e0e0e0;
    border-radius: 5px;
    outline: none;
    transition: all 0.2s ease-in-out;
}

.speaking-rate-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #8367a7;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: background-color 0.2s ease;
}

.speaking-rate-control input[type="range"]::-webkit-slider-thumb:hover {
    background-color: #6a4c93;
}

/* New: Style for the "Translate to English" button to differentiate it */
#translateEnglishBtn {
    background-color: #4a6c93;
}

#translateEnglishBtn:hover {
    background-color: #3a5c7c;
}

/* New: Image Preview Styling */
.image-preview {
    max-width: 400px;
    margin: 20px auto;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease-in-out;
}

.image-preview img {
    width: 100%;
    height: auto;
    display: block;
}

.image-preview.hidden {
    display: none;
}

/* New: Stop button styling */
.stop-button {
    background-color: #e74c3c;
    box-shadow: 0 4px 8px rgba(231, 76, 60, 0.2);
}

.stop-button:hover {
    background-color: #c0392b;
    transform: translateY(-2px);
    box-shadow: 0 6px 10px rgba(231, 76, 60, 0.3);
}

/* New: Loading Spinner for Button */
.animated-button.loading {
    cursor: not-allowed;
    pointer-events: none;
    background-color: #a779c1;
}

.animated-button.loading span {
    display: none;
}

.animated-button.loading::after {
    content: '';
    position: relative;
    width: 20px;
    height: 20px;
    display: inline-block;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}


/* Loading and Error Messages */
.hidden {
    display: none;
}

.loading-animation {
    font-size: 1.2em;
    color: #8367a7;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.loading-animation::before {
    content: '';
    border: 3px solid #f3f3f3;
    border-top: 3px solid #8367a7;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

.error-message {
    color: #e74c3c;
    font-weight: bold;
    padding: 15px;
    background: #fdeded;
    border-radius: 10px;
    border: 1px solid #e74c3c;
    margin-top: 20px;
}

/* New: Success Message Styling */
.success-message {
    color: #4CAF50;
    font-weight: bold;
    font-size: 1.2em;
    margin-top: 10px;
    animation: fade-in 0.5s ease-out;
}

/* Animations */
@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fade-in 1s ease-out forwards;
}

.fade-in:nth-child(1) { animation-delay: 0.2s; }
.fade-in:nth-child(2) { animation-delay: 0.4s; }
.fade-in:nth-child(3) { animation-delay: 0.6s; }


@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 30px;
        margin: 20px;
    }
    header h1 {
        font-size: 2em;
    }
    .file-input-wrapper {
        flex-direction: column;
        align-items: flex-start;
        padding: 15px;
    }
    .custom-file-upload {
        width: 100%;
        text-align: center;
        margin-bottom: 10px;
    }
    .animated-button {
        width: 100%;
        padding: 10px 20px;
    }
}