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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 20px;
    color: white;
}

header h1 {
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

header p {
    opacity: 0.9;
}

/* Chat Container */
.chat-container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 160px);
    min-height: 400px;
}

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

/* Message Bubbles */
.message {
    max-width: 75%;
    animation: fadeIn 0.3s ease;
}

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

/* Bot Message - LEFT aligned */
.bot-message {
    align-self: flex-start;
}

.bot-message .message-content {
    background: #f0f4f8;
    color: #2c3e50;
    padding: 14px 18px;
    border-radius: 18px 18px 18px 4px;
    line-height: 1.5;
}

/* User Message - RIGHT aligned */
.user-message {
    align-self: flex-end;
}

.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 14px 18px;
    border-radius: 18px 18px 4px 18px;
    line-height: 1.5;
}

/* User Image Preview */
.user-message .message-image {
    max-width: 200px;
    max-height: 150px;
    border-radius: 12px;
    margin-bottom: 8px;
    border: 2px solid rgba(255,255,255,0.3);
}

.user-message .image-label {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 4px;
}

/* Disease Detection Card */
.disease-card {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border: 1px solid #28a745;
    border-radius: 12px;
    padding: 16px;
    margin-top: 8px;
}

.disease-card h3 {
    color: #155724;
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.disease-card p {
    margin: 6px 0;
    color: #155724;
}

.disease-card strong {
    color: #0d3d17;
}

/* No Match Card */
.no-match-card {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeeba 100%);
    border: 1px solid #ffc107;
    border-radius: 12px;
    padding: 16px;
    margin-top: 8px;
}

.no-match-card h3 {
    color: #856404;
    margin-bottom: 12px;
}

.no-match-card p {
    color: #856404;
    margin: 6px 0;
}

/* Input Area */
.input-area {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid #eee;
    background: #fafafa;
}

#message-input {
    flex: 1;
    padding: 14px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#message-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

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

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

#upload-btn {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 28px;
    font-weight: bold;
    line-height: 1;
    transition: transform 0.2s, box-shadow 0.2s;
}

#upload-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 12px rgba(17, 153, 142, 0.4);
}

/* Captcha gate (kit-files) */
.captcha-gate {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px 0;
    border-top: 1px solid #eee;
    background: #fafafa;
    font-size: 14px;
    color: #555;
}

.captcha-gate + .input-area {
    border-top: none;
}

.captcha-hint.verified {
    color: #11998e;
    font-weight: 600;
}

#upload-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Loading Indicator */
.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.98);
    padding: 30px 50px;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    z-index: 1000;
}

.spinner {
    width: 45px;
    height: 45px;
    border: 4px solid #e0e0e0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Progress Steps */
.progress-message .message-content {
    min-width: 300px;
}

.progress-header {
    font-weight: 600;
    margin-bottom: 10px;
    color: #555;
    font-size: 1.05em;
}

.progress-steps {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.progress-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    font-size: 0.92em;
    color: #444;
    animation: fadeIn 0.3s ease;
}

.progress-step .step-icon {
    color: #28a745;
    font-weight: bold;
    font-size: 1.1em;
    min-width: 18px;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

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

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

/* Responsive */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    .message {
        max-width: 85%;
    }

    .input-area {
        padding: 12px;
    }

    #send-btn {
        padding: 12px 20px;
    }
}
