:root {
    --primary-color: #006039;
    /* School Green */
    --secondary-color: #f1c40f;
    /* School Yellow */
    --accent-color: #f39c12;
    /* Darker Yellow for text */
    --bg-color: #f9fbf9;
    --sidebar-width: 280px;
    --msg-user-bg: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    --msg-user-text: #ffffff;
    --msg-bot-bg: #ffffff;
    --msg-bot-text: #2d3436;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.12);
    --font-main: 'Sarabun', sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    margin: 0;
    display: flex;
    height: 100vh;
    background-color: var(--bg-color);
    color: #333;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: #ffffff;
    display: flex;
    flex-direction: column;
    padding: 25px;
    box-shadow: 5px 0 25px rgba(0, 0, 0, 0.03);
    z-index: 10;
    border: none;
}

.school-logo {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 40px;
}

.logo-img {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: cover;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.school-logo span {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
    background: none;
    -webkit-text-fill-color: initial;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid #ecf0f1;
    font-size: 0.8rem;
    color: #95a5a6;
    text-align: center;
}

.dev-credit {
    font-weight: 600;
    color: var(--accent-color);
    margin-bottom: 5px;
}

.menu-item {
    padding: 12px 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #7f8c8d;
    font-weight: 500;
}

.menu-item:hover {
    background-color: #f7f9fa;
    color: var(--primary-color);
}

.menu-item.active {
    background-color: var(--accent-color);
    color: white;
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3);
}

.btn-new-chat {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 20px;
    transition: 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
}

.btn-new-chat:hover {
    background-color: #1a252f;
}

/* Model Selector */
.model-selector {
    margin-bottom: 25px;
    padding: 0 5px;
}

.model-label {
    font-size: 0.8rem;
    color: #95a5a6;
    margin-bottom: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.model-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.model-btn {
    padding: 10px 15px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: transparent;
    color: #555;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-family: var(--font-main);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.model-btn:hover {
    background: #f7f9fa;
    border-color: #bdc3c7;
}

.model-btn.active {
    background: #e8f8f5;
    border-color: var(--primary-color);
    color: var(--primary-color);
    font-weight: 600;
    box-shadow: 0 2px 5px rgba(0, 96, 57, 0.1);
}

.model-btn.active::before {
    content: '●';
    font-size: 0.8rem;
    color: var(--primary-color);
}

/* Main Chat Area */
.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

/* Header */
.chat-header {
    height: 90px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 0 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-logo {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.chat-title h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: -0.3px;
    margin-bottom: 2px;
    line-height: 1.2;
}

.chat-title p {
    margin: 0;
    font-size: 0.85rem;
    color: #27ae60;
    font-weight: 500;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: #27ae60;
    background: #e8f8f5;
    padding: 5px 10px;
    border-radius: 15px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #27ae60;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(39, 174, 96, 0.2);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 30px 10%;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

.message {
    border-radius: 20px;
    padding: 15px 22px;
    font-size: 1rem;
    line-height: 1.6;
    box-shadow: var(--shadow-sm);
    max-width: 75%;
    position: relative;
    word-wrap: break-word;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    background: var(--msg-user-bg);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message.bot {
    background: white;
    color: var(--msg-bot-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid #ecf0f1;
}

.time-stamp {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 5px;
    text-align: right;
    display: block;
}

/* Floating Input Bar */
.input-container {
    background: transparent;
    padding: 0 10% 40px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

.input-wrapper {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 50px;
    padding: 8px 12px 8px 25px;
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 800px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.5);
    transition: transform 0.2s;
}

.input-wrapper:focus-within {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

input[type="text"] {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 0;
    outline: none;
    font-size: 1.05rem;
    color: #2c3e50;
    font-weight: 500;
}

.send-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f1c40f 0%, #f39c12 100%);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(241, 196, 15, 0.4);
    margin-left: 10px;
}

.send-btn:hover {
    transform: scale(1.1) rotate(-10deg);
}

/* Optimized Loading Animation */
.loading-dots {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    background: #f1f1f1;
    border-radius: 20px;
    width: fit-content;
    will-change: transform;
}

.dot {
    width: 8px;
    height: 8px;
    background: #95a5a6;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) {
    animation-delay: -0.32s;
}

.dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .chat-messages,
    .input-container {
        padding: 15px 5%;
    }

    .chat-header {
        padding: 0 15px;
    }
}