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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, navy 0%, #38267a 100%);
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-container {
    width: 100%;
    max-width: 800px;
    height: 90vh;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    background: linear-gradient(135deg, navy 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

.chat-header h1 {
    font-size: 24px;
    margin-bottom: 5px;
}

.chat-header p {
    opacity: 0.9;
    font-size: 14px;
}

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

.message {
    display: flex;
    gap: 12px;
    animation: fadeIn 0.3s ease-in;
}

.user-message {
    justify-content: flex-end;
}

.bot-message {
    justify-content: flex-start;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
}

.user-message .message-content {
    background: navy;
    color: white;
    border-bottom-right-radius: 6px;
}

.bot-message .message-content {
    background: #f1f3f4;
    color: #333;
    border-bottom-left-radius: 6px;
}

.message-content p {
    margin-bottom: 8px;
}

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

.scenario-info {
    background: #e3f2fd;
    border: 1px solid #2196f3;
    border-radius: 8px;
    padding: 8px 12px;
    margin-top: 8px;
    font-size: 12px;
}

.scenario-info strong {
    color: #1976d2;
}

.sources-list {
    margin-top: 8px;
    font-size: 12px;
}

.sources-list a {
    color: navy;
    text-decoration: none;
    display: block;
    margin-top: 4px;
}

.sources-list a:hover {
    text-decoration: underline;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #f1f3f4;
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    max-width: 70%;
}

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

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

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

/* Utility: hide element (e.g. feedback row until is_done). */
.hidden {
    display: none !important;
}

.chat-input-container {
    padding: 20px;
    border-top: 1px solid #e0e0e0;
    background: white;
}

/* Feedback row above chat input; shown when agent sets is_done. Step 1: question + thumbs. */
.feedback-row {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
}

.feedback-question {
    font-size: 14px;
    margin-bottom: 8px;
    color: #555;
}

.feedback-thumbs {
    display: flex;
    gap: 12px;
    align-items: center;
}

.thumb-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 2px solid #e0e0e0;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
}

.thumb-button:hover {
    border-color: navy;
    background: #f5f5ff;
}

.thumb-button.thumb-up.selected {
    color: #2e7d32;
    border-color: #2e7d32;
    background: rgba(46, 125, 50, 0.08);
}

.thumb-button.thumb-down.selected {
    color: #c62828;
    border-color: #c62828;
    background: rgba(198, 40, 40, 0.08);
}

.feedback-expand {
    margin-top: 10px;
}

.feedback-comment {
    width: 100%;
    padding: 8px 10px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 8px;
    box-sizing: border-box;
}

.feedback-comment:focus {
    outline: none;
    border-color: navy;
}

.feedback-submit {
    background: navy;
    color: white;
    border: none;
    border-radius: 18px;
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
}

.feedback-submit:hover {
    background: #000070;
}

.feedback-thanks {
    margin: 0;
    font-size: 14px;
    color: #333;
}

.chat-form {
    width: 100%;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    padding: 8px;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: navy;
}

#messageInput {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 12px;
    font-size: 16px;
    resize: none;
    outline: none;
    font-family: inherit;
    max-height: 120px;
    min-height: 20px;
}

#sendButton {
    background: navy;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

#sendButton:hover {
    background: navy;
}

#sendButton:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.error-message {
    background: #ffebee;
    border: 1px solid #f44336;
    color: #c62828;
    padding: 12px 16px;
    border-radius: 8px;
    margin-top: 8px;
}

@media (max-width: 768px) {
    .chat-container {
        height: 100vh;
        border-radius: 0;
    }
    
    .message-content {
        max-width: 85%;
    }
}

.debug-info details {
    cursor: pointer;
}

.debug-info summary {
    font-weight: bold;
    padding: 4px 0;
    user-select: none;
}

.debug-info summary:hover {
    background: rgba(0,0,0,0.05);
    padding-left: 4px;
    border-radius: 2px;
}

.debug-info pre {
    overflow-x: auto;
    max-width: 100%;
}