body {
    font-family: Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    background-color: #f0f2f5;
    color: #333;
}

.container {
    background-color: #fff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-width: 600px;
    width: 90%;
}

h1 {
    color: #2c3e50;
    margin-bottom: 25px;
    font-size: 2em;
}

.upload-section {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.custom-file-upload {
    display: inline-block;
    padding: 10px 20px;
    background-color: #007bff;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.custom-file-upload:hover {
    background-color: #0056b3;
}

input[type="file"] {
    display: none; /* Hide the default file input */
}

#fileNameDisplay {
    font-style: italic;
    color: #666;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.image-preview-container {
    background-color: #e9ecef;
    border: 2px dashed #ccc;
    border-radius: 8px;
    min-height: 250px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 25px;
    overflow: hidden; /* Ensure caption stays within bounds */
    position: relative;
}

#no-image-text {
    color: #888;
    font-style: italic;
}

.image-container {
    position: relative;
    max-width: 100%;
    max-height: 500px; /* Limit height to prevent overly large previews */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#uploaded-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* Maintain aspect ratio and fit within container */
    display: block; /* Override initial display: none */
}

.caption-overlay {
    position: absolute;
    bottom: 0; /* Position at the bottom */
    width: 100%;
    background-color: rgba(0, 0, 0, 0.6); /* Semi-transparent background */
    color: white;
    padding: 10px 5px;
    font-size: 1.8em; /* Large font for caption */
    font-weight: 900;
    text-align: center;
    word-wrap: break-word; /* Wrap long captions */
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8); /* Text shadow for readability */
    box-sizing: border-box; /* Include padding in width */
    min-height: 50px; /* Ensure some height even if no text */
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap; /* Allow text to wrap within the overlay */
    line-height: 1.2;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

input[type="text"] {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1em;
    width: calc(100% - 24px); /* Full width minus padding */
    box-sizing: border-box;
}

button {
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-size: 1.1em;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    width: 100%;
}

button:hover:enabled {
    transform: translateY(-2px);
}

button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    opacity: 0.7;
}

#suggest-caption-btn {
    background-color: #28a745;
    color: white;
}

#suggest-caption-btn:hover:enabled {
    background-color: #218838;
}

#download-image-btn {
    background-color: #17a2b8;
    color: white;
}

#download-image-btn:hover:enabled {
    background-color: #138496;
}

