/* General UI/UX from the document */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; /* Modern font */
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(to right, #ff7e5f, #feb47b, #ff7e5f); /* More vibrant gradient */
    color: white;
    transition: background 1s ease-in-out;
}

/* Welcome Page Specific Styles */
.welcome-page-body {
    background: linear-gradient(to right, #833ab4, #fd1d1d, #fcb045); /* Instagram-like gradient */
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.welcome-container {
    padding: 2rem;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.welcome-container .chat-title {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    animation: bounceIn 1s ease-out;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.welcome-container .subtitle {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    opacity: 0;
    animation: fadeIn 1.5s ease-out 0.5s forwards;
}

.welcome-buttons button {
    background-color: #007bff;
    color: white;
    font-size: 1.2rem;
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.welcome-buttons button:hover {
    background-color: #0056b3;
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes bounceIn {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); }
}

/* Existing styles from the document with enhancements */
.chat-title {
    font-size: 2.5rem; /* Slightly larger */
    font-weight: bold;
    margin-bottom: 1.5rem; /* More space */
    text-align: center;
    animation: colorChange 5s infinite alternate; /* Slower and alternate */
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3); /* Soft text shadow */
}

@keyframes colorChange {
    0% { color: #f2e305; }
    25% { color: #00bcd4; }
    50% { color: #8bc34a; }
    75% { color: #ff9800; }
    100% { color: #e91e63; }
}

.chat-container {
    width: 95%;
    max-width: 480px; /* Slightly wider */
    min-height: 80vh; /* Min height to accommodate content */
    background-color: #fff;
    border-radius: 15px; /* More rounded */
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2); /* Softer, larger shadow */
    display: flex;
    flex-direction: column;
    color: #000;
    overflow: hidden;
    margin-top: 1rem;
}

.chat-body {
    flex: 1;
    padding: 15px; /* More padding */
    overflow-y: auto;
    border-bottom: 1px solid #eee; /* Lighter border */
    background-color: #fcfcfc;
}

.message {
    margin-bottom: 12px; /* More space between messages */
    padding: 10px 15px; /* More padding */
    border-radius: 12px; /* More rounded */
    max-width: 75%; /* Allow a bit more width */
    word-wrap: break-word;
    position: relative;
    font-size: 0.95rem;
}

.user-message {
    background-color: #4CAF50; /* Green shade */
    color: #fff;
    margin-left: auto;
    border-bottom-right-radius: 4px; /* Pointed corner */
}

.bot-message {
    background-color: #e0e0e0; /* Light gray */
    color: #333;
    margin-right: auto;
    border-bottom-left-radius: 4px; /* Pointed corner */
}

.message-text {
    padding-right: 25px; /* Space for speak button */
}

.chat-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 10px;
    background-color: #f5f5f5; /* Lighter footer */
    border-top: 1px solid #ddd;
}

.message-input {
    flex: 1;
    min-width: 0;
    padding: 12px; /* More padding */
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 8px; /* More rounded */
    margin: 5px;
    outline: none;
    transition: border-color 0.3s ease;
}

.message-input:focus {
    border-color: #007bff;
}

#send-message {
    background-color: #007bff;
    color: white;
    font-size: 1.4rem; /* Larger icon */
    border: none;
    padding: 10px 16px; /* Adjusted padding */
    border-radius: 8px;
    cursor: pointer;
    margin: 5px;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

#send-message:hover {
    background-color: #0056b3;
    transform: scale(1.05);
}

.clip-container {
    position: relative;
    margin-right: 5px;
}

#clip-button {
    background: none;
    border: none;
    font-size: 1.8rem; /* Larger icon */
    cursor: pointer;
    color: #555;
    transition: color 0.3s ease;
}

#clip-button:hover {
    color: #007bff;
}

.clip-dropdown {
    display: none;
    position: absolute;
    bottom: 110%; /* Keeps the dropdown ABOVE the button */
    left: 0;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 10px; /* More rounded */
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15); /* Softer, larger shadow */
    z-index: 10;
    min-width: 150px; /* Wider */
    padding: 5px 0;
}

.clip-dropdown button,
.clip-dropdown select {
    display: block;
    width: 100%;
    padding: 10px 15px; /* More padding */
    font-size: 0.95rem;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    color: #333;
    transition: background-color 0.2s ease;
}

.clip-dropdown button:hover {
    background-color: #f1f1f1;
}

.clip-dropdown select {
    border-top: 1px solid #eee; /* Lighter border */
    outline: none;
    appearance: none; /* Remove default select styles */
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23000000%22%20d%3D%22M287%2C114.7L154.7%2C18.6c-4.6-3.8-11.2-3.8-15.8%2C0L5.4%2C114.7c-7.3%2C6-6.5%2C16.3%2C1.4%2C21.6l1.3%2C0.9c7.9%2C5.3%2C18.1%2C4.5%2C24.1-3.3l119-158.4c-4.6-3.8-11.2-3.8-15.8%2C0L5.4%2C114.7c-7.3%2C6-6.5%2C16.3%2C1.4%2C21.6l1.3%2C0.9c7.9%2C5.3%2C18.1%2C4.5%2C24.1-3.3l119-158.4z%22%2F%3E%3C%2Fsvg%3E'); /* Custom arrow */
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
}

.hidden {
    display: none;
}

.clip-container:focus-within .clip-dropdown,
.clip-container:hover .clip-dropdown {
    display: block;
}

/* Specific styles for Image Analyzer */
.image-upload-area {
    border: 2px dashed #ccc;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    margin: 20px;
    color: #555;
    background-color: #f9f9f9;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.image-upload-area:hover {
    background-color: #f0f0f0;
    border-color: #007bff;
}

.image-upload-area p {
    margin: 0;
}

#image-input {
    display: none;
}

.image-preview-container {
    text-align: center;
    margin-bottom: 20px;
}

#uploaded-image-preview {
    max-width: 90%;
    max-height: 250px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 10px;
}

#clear-image-button {
    background-color: #dc3545;
    color: white;
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin-top: 10px;
}

#clear-image-button:hover {
    background-color: #c82333;
}

#analyze-image-button {
    background-color: #28a745;
    color: white;
    font-size: 1.1rem;
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin: 0 auto 20px auto; /* Centered */
    display: block;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

#analyze-image-button:hover:not(.disabled) {
    background-color: #218838;
    transform: translateY(-2px);
}

#analyze-image-button.disabled {
    background-color: #6c757d;
    cursor: not-allowed;
    opacity: 0.7;
}

.ai-description-container {
    background-color: #f0f8ff; /* Light blue background */
    border-radius: 10px;
    padding: 15px;
    margin: 0 20px 20px 20px;
    border: 1px solid #d0e8f8;
    color: #333;
    min-height: 80px;
}

.ai-description-container h3 {
    margin-top: 0;
    color: #0056b3;
    font-size: 1.1rem;
}

.ai-description-container p {
    margin-bottom: 10px;
    line-height: 1.6;
}

.tts-controls {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.tts-controls button {
    background-color: #6c757d;
    color: white;
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.tts-controls button:hover {
    background-color: #5a6268;
}

/* Chat options for voice.html */
.chat-options {
    display: flex;
    justify-content: center;
    padding: 10px;
    background-color: #f9f9f9;
    border-top: 1px solid #eee;
    gap: 10px;
    flex-wrap: wrap; /* Added for responsiveness */
}

.chat-options button {
    background-color: #17a2b8;
    color: white;
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.chat-options button:hover {
    background-color: #138496;
}

/* Top Navigation Bar */
.top-nav {
    width: 100%;
    background-color: #333;
    padding: 10px 0;
    display: flex;
    justify-content: center;
    gap: 30px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
}

.top-nav a {
    color: white;
    text-decoration: none;
    padding: 8px 15px;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

.top-nav a:hover {
    background-color: #555;
}

.top-nav a.active {
    background-color: #007bff;
    font-weight: bold;
}

/* Adjust body padding for fixed nav */
body:not(.welcome-page-body) {
    padding-top: 70px; /* Space for the fixed navigation bar */
}

/* Thinking indicator */
.thinking-indicator {
    display: flex;
    align-items: center;
    justify-content: center; /* Center dots in the bubble */
    height: 20px; /* Ensure vertical alignment */
}

.thinking-indicator .dot {
    width: 8px;
    height: 8px;
    background-color: #888;
    border-radius: 50%;
    margin: 0 2px;
    animation: bounce 1.4s infinite ease-in-out both;
}

.thinking-indicator .dot:nth-child(1) { animation-delay: -0.32s; }
.thinking-indicator .dot:nth-child(2) { animation-delay: -0.16s; }
.thinking-indicator .dot:nth-child(3) { animation-delay: 0s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

/* Attachment styling */
.attachment {
    max-width: 100%;
    height: auto;
    margin-top: 10px;
    border-radius: 5px;
}

.file-name {
    font-style: italic;
    font-size: 0.85em;
    color: #666;
    margin-top: 5px;
}

/* Speak button next to bot messages */
.bot-message .speak-message-button {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #007bff;
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.7;
    transition: opacity 0.2s ease, color 0.2s ease;
}

.bot-message .speak-message-button:hover {
    opacity: 1;
    color: #0056b3;
}

/* Recording indicator for voice button */
#voice-input.recording {
    color: #dc3545; /* Red color when recording */
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    from { transform: scale(1); opacity: 1; }
    to { transform: scale(1.1); opacity: 0.7; }
}

/* TTS Button active state */
#toggle-tts.active {
    background-color: #28a745; /* Green when active */
}
