:root {
    --primary-color: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.4);
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-color: #f8fafc;
    --text-secondary: #94a3b8;
    --user-msg-bg: #6366f1;
    --bot-msg-bg: rgba(152, 169, 209, 0.8);
    --input-bg: rgba(15, 23, 42, 0.6);
    --font-main: 'Outfit', sans-serif;
    --font-thai: 'Sarabun', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-thai);
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

/* Background Blobs */
.background-blobs {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: float 20s infinite ease-in-out;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: #4f46e5;
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 300px;
    height: 300px;
    background: #ec4899;
    bottom: -50px;
    right: -50px;
    animation-delay: -5s;
}

.blob-3 {
    width: 250px;
    height: 250px;
    background: #06b6d4;
    top: 40%;
    left: 40%;
    animation-delay: -10s;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0);
    }

    33% {
        transform: translate(30px, -50px);
    }

    66% {
        transform: translate(-20px, 20px);
    }
}

/* Main Container */
.main-container {
    width: 100%;
    max-width: 500px;
    /* Mobile-first feel but desktop friendly */
    height: 90vh;
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

/* Header */
.chat-header {
    padding: 20px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(15, 23, 42, 0.3);
}

.avatar-container {
    position: relative;
    margin-right: 15px;
}

.avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #ec4899);
    padding: 2px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #1e293b;
}

.status-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid #1e293b;
    box-shadow: 0 0 10px #22c55e;
}

.header-info h1 {
    font-family: var(--font-main);
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.header-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Chat Area */
.chat-area {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
}

.chat-area::-webkit-scrollbar {
    width: 6px;
}

.chat-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.message {
    max-width: 80%;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bot-message {
    align-self: flex-start;
}

.user-message {
    align-self: flex-end;
    align-items: flex-end;
}

.message-content {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
}

.bot-message .message-content {
    background: var(--bot-msg-bg);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(51, 65, 85, 0.8);
}

.user-message .message-content {
    background: var(--user-msg-bg);
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 4px;
    margin-left: 4px;
}

.user-message .message-time {
    margin-right: 4px;
}

/* Input Area */
.input-area {
    padding: 20px;
    background: rgba(15, 23, 42, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.input-wrapper {
    display: flex;
    background: var(--input-bg);
    border-radius: 25px;
    padding: 5px 5px 5px 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 15px var(--primary-glow);
}

input,
textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-family: var(--font-thai);
    font-size: 1rem;
    outline: none;
    padding: 10px 0;
    resize: none;
    /* Disable manual resize */
    max-height: 150px;
    /* Limit height */
}

button#send-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-left: 10px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

button#send-btn:hover {
    transform: scale(1.05);
    background: #4f46e5;
}

button#send-btn:active {
    transform: scale(0.95);
}

button#upload-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 10px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

button#upload-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.chat-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 12px;
    margin-top: 8px;
    margin-bottom: 2px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.chat-image:hover {
    transform: scale(1.02);
}

.chat-image.single {
    width: 100px;
    height: 100px;
    object-fit: cover;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 8px;
    margin-bottom: 2px;
    width: 100%;
}

.image-grid .chat-image {
    width: 100%;
    height: 120px;
    object-fit: cover;
    margin-top: 0;
    margin-bottom: 0;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #1e293b;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.modal-content h2 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

.modal-content p {
    margin-bottom: 10px;
    color: var(--text-secondary);
}

.modal-content span {
    color: var(--text-color);
    font-weight: bold;
}

.modal-content input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 12px;
    margin: 20px 0;
    color: white;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-primary,
.btn-secondary {
    padding: 10px 20px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-family: var(--font-thai);
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #4f46e5;
}

.btn-secondary {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

/* Thought Button */
.think-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    border-radius: 12px;
    transition: all 0.2s;
    opacity: 0.7;
}

.think-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fbbf24;
    /* Amber/Yellow for lightbulb */
    opacity: 1;
}

.think-btn i {
    font-size: 0.9rem;
}

/* Thought Modal Specifics */
#thought-modal .modal-content {
    max-width: 500px;
    width: 95%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    text-align: left;
}

.thought-list {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    padding-right: 10px;
}

.thought-step {
    background: rgba(15, 23, 42, 0.5);
    border-left: 3px solid var(--primary-color);
    padding: 10px 15px;
    border-radius: 4px 8px 8px 4px;
}

.thought-step-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--primary-color);
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
}

.thought-step-data {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.8rem;
    color: var(--text-color);
    white-space: pre-wrap;
    word-break: break-all;
}

.thought-list::-webkit-scrollbar {
    width: 4px;
}

.thought-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}