* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #e9ecef;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

h1 {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 20px 8px 20px;
    text-align: center;
    font-size: 24px;
}

.subheading {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: rgba(255, 255, 255, 0.85);
    padding: 0 20px 10px 20px;
    text-align: center;
    font-size: 14px;
    margin: 0;
    font-weight: 400;
}

.disclaimer {
    text-align: center;
    color: #6c757d;
    padding: 15px 20px;
    font-size: 12px;
    background: #f8f9fa;
    margin: 0;
    border-top: 1px solid #e9ecef;
}

/* Configuration Section */
.config-section {
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
}

.config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    cursor: pointer;
    user-select: none;
    background: #e9ecef;
    transition: background 0.2s;
}

.config-header:hover {
    background: #dee2e6;
}

.config-header h2 {
    font-size: 14px;
    color: #6c757d;
    font-weight: 500;
}

.toggle-icon {
    font-size: 14px;
    transition: transform 0.3s;
    color: #6c757d;
}

.toggle-icon.collapsed {
    transform: rotate(-90deg);
}

.config-content {
    padding: 20px;
    transition: max-height 0.3s ease-out;
    overflow: hidden;
}

.config-content.hidden {
    max-height: 0;
    padding: 0 20px;
}

.config-field {
    margin-bottom: 15px;
}

.config-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #495057;
}

.config-field input {
    width: 100%;
    padding: 10px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.config-field input:focus {
    outline: none;
    border-color: #667eea;
}

.voice-select {
    width: 100%;
    padding: 10px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
    background: white;
    cursor: pointer;
}

.voice-select:focus {
    outline: none;
    border-color: #667eea;
}

.save-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}

.save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.config-status {
    margin-top: 10px;
    padding: 10px;
    border-radius: 6px;
    font-size: 14px;
    text-align: center;
}

.config-status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.config-status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Chat Container */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 500px;
}

.chat-header {
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.view-instructions-btn {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 20px;
    font-weight: 600;
    transition: background 0.2s, color 0.2s;
}

.view-instructions-btn:hover:not(:disabled) {
    background: #667eea;
    color: white;
}

.view-instructions-btn:disabled {
    background: #e9ecef;
    color: #ccc;
    border-color: #ccc;
    cursor: not-allowed;
}

.restart-btn {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 20px;
    font-weight: 600;
    transition: background 0.2s, color 0.2s;
}

.restart-btn:hover:not(:disabled) {
    background: #667eea;
    color: white;
}

.restart-btn:disabled {
    background: #e9ecef;
    color: #ccc;
    border-color: #ccc;
    cursor: not-allowed;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.welcome-message {
    text-align: center;
    color: #6c757d;
    padding: 40px 20px;
    font-size: 16px;
}

.message {
    display: flex;
    gap: 10px;
    max-width: 70%;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.assistant {
    align-self: flex-start;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.4;
}

.message.user .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
    background: #f1f3f4;
    color: #333;
    border-bottom-left-radius: 4px;
}

.message-content img {
    max-width: 200px;
    border-radius: 8px;
    margin-bottom: 8px;
    display: block;
}

.message-content {
    white-space: pre-wrap;
}

/* Markdown formatting in assistant messages */
.message.assistant .message-content h1,
.message.assistant .message-content h2,
.message.assistant .message-content h3,
.message.assistant .message-content h4,
.message.assistant .message-content h5,
.message.assistant .message-content h6 {
    margin: 8px 0 4px 0;
    font-weight: 600;
}

.message.assistant .message-content h1:first-child,
.message.assistant .message-content h2:first-child,
.message.assistant .message-content h3:first-child,
.message.assistant .message-content h4:first-child,
.message.assistant .message-content h5:first-child,
.message.assistant .message-content h6:first-child {
    margin-top: 0;
}

.message.assistant .message-content h1 {
    font-size: 1.5em;
}

.message.assistant .message-content h2 {
    font-size: 1.3em;
}

.message.assistant .message-content h3 {
    font-size: 1.1em;
}

.message.assistant .message-content p {
    margin: 4px 0;
}

.message.assistant .message-content p:first-child {
    margin-top: 0;
}

.message.assistant .message-content p:last-child {
    margin-bottom: 0;
}

.message.assistant .message-content ul,
.message.assistant .message-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.message.assistant .message-content li {
    margin: 4px 0;
}

.message.assistant .message-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.message.assistant .message-content pre {
    background: rgba(0, 0, 0, 0.1);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}

.message.assistant .message-content pre code {
    background: none;
    padding: 0;
}

.message.assistant .message-content blockquote {
    border-left: 3px solid #999;
    padding-left: 12px;
    margin: 8px 0;
    color: #666;
}

.message.assistant .message-content table {
    border-collapse: collapse;
    margin: 8px 0;
}

.message.assistant .message-content th,
.message.assistant .message-content td {
    border: 1px solid #ddd;
    padding: 6px 12px;
}

.message.assistant .message-content th {
    background: rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

.message.assistant .message-content a {
    color: #667eea;
    text-decoration: underline;
}

.message.assistant .message-content hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 12px 0;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

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

/* Chat Input */
.chat-input-container {
    padding: 20px;
    background: #f8f9fa;
    border-top: 2px solid #e9ecef;
}

.image-preview {
    margin-bottom: 10px;
    position: relative;
    display: inline-block;
}

.image-preview img {
    max-width: 150px;
    max-height: 150px;
    border-radius: 8px;
    border: 2px solid #dee2e6;
}

.remove-image {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-image:hover {
    background: #c82333;
}

.input-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.attach-btn {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    padding: 10px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    transition: background 0.2s, color 0.2s;
}

.attach-btn:hover:not(:disabled) {
    background: #667eea;
    color: white;
}

.attach-btn:disabled {
    background: #e9ecef;
    color: #ccc;
    border-color: #ccc;
    cursor: not-allowed;
}

.mic-btn {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    padding: 10px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    transition: background 0.2s, transform 0.2s, color 0.2s;
}

.mic-btn:hover:not(:disabled) {
    background: #667eea;
    color: white;
}

.mic-btn:disabled {
    background: #e9ecef;
    color: #ccc;
    border-color: #ccc;
    cursor: not-allowed;
}

.mic-btn.listening {
    background: #dc3545;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

#userInput {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #dee2e6;
    border-radius: 24px;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    transition: border-color 0.2s;
    resize: none;
    overflow-y: auto;
    max-height: 120px;
    line-height: 1.4;
}

#userInput:focus {
    outline: none;
    border-color: #667eea;
}

#userInput:disabled {
    background: #e9ecef;
    cursor: not-allowed;
}

.send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 24px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}

.send-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

.send-btn.speaking {
    color: white;
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
}

.modal-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-section {
    margin-bottom: 20px;
}

.modal-section:last-child {
    margin-bottom: 0;
}

.modal-section h3 {
    color: #667eea;
    font-size: 16px;
    margin: 0 0 10px 0;
    font-weight: 600;
}

.modal-value {
    margin: 0;
    line-height: 1.6;
    color: #333;
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    border-left: 3px solid #667eea;
}
