/* Modern Chat Interface - Glassmorphism Theme */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: 1px solid rgba(255, 255, 255, 0.4);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --accent-color: #764ba2;
    --user-msg-bg: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --ai-msg-bg: rgba(255, 255, 255, 0.85);
}

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

body {
    font-family: 'Kanit', sans-serif;
    background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    padding-bottom: 20px;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 15px 30px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: var(--glass-border);
    box-shadow: var(--glass-shadow);
    flex-shrink: 0;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-text h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 2px;
}

.logo-text p {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 300;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 15px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.2);
    padding: 8px 16px;
    border-radius: 20px;
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 10px #10b981;
    animation: pulse 2s infinite;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.25);
    color: white;
    text-decoration: none;
    border-radius: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 25px;
    flex: 1;
    min-height: 0; /* Important for scroll */
}

/* Chat Section */
.chat-section {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-radius: 30px;
    padding: 25px;
    display: flex;
    flex-direction: column;
    border: var(--glass-border);
    box-shadow: var(--glass-shadow);
    overflow: hidden;
    position: relative;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    scroll-behavior: smooth;
    margin-bottom: 20px;
}

.chat-container::-webkit-scrollbar {
    width: 6px;
}
.chat-container::-webkit-scrollbar-thumb {
    background: rgba(118, 75, 162, 0.3);
    border-radius: 10px;
}

/* Messages */
.message {
    display: flex;
    margin-bottom: 24px;
    animation: slideUp 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

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

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

.message-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    flex-shrink: 0;
    margin: 0 15px;
    z-index: 2;
}

.message-content {
    max-width: 75%;
    padding: 20px 25px;
    border-radius: 20px;
    position: relative;
    font-size: 1rem;
    line-height: 1.7;
    box-shadow: 0 5px 20px rgba(0,0,0,0.05);
}

.ai-message .message-content {
    background: white;
    color: var(--text-primary);
    border-top-left-radius: 5px;
}

.user-message .message-content {
    background: var(--user-msg-bg);
    color: white;
    border-top-right-radius: 5px;
}

.message-content ul {
    margin-left: 20px;
    margin-top: 10px;
}

.message-content strong {
    font-weight: 600;
}

.example-question {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(118, 75, 162, 0.2);
    padding: 12px 16px;
    border-radius: 16px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-primary);
    transition: all 0.2s;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.example-question:hover {
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(118, 75, 162, 0.15);
    border-color: #764ba2;
}

/* Input Area */
.input-section {
    background: rgba(255, 255, 255, 0.5);
    padding: 20px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.voice-controls {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.voice-btn, .language-btn {
    border: none;
    padding: 10px 18px;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    color: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

#voiceBtn { background: linear-gradient(135deg, #FF6B6B, #EE5253); }
#languageBtn { background: linear-gradient(135deg, #4834d4, #686de0); }
#clearCacheBtn { background: linear-gradient(135deg, #95a5a6, #7f8c8d); }
.live-audio-btn { background: linear-gradient(135deg, #6c5ce7, #a29bfe); text-decoration: none; }

.voice-btn:hover, .language-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.text-input-container {
    display: flex;
    gap: 15px;
    position: relative;
}

#textInput {
    flex: 1;
    padding: 18px 25px;
    border-radius: 50px;
    border: 2px solid rgba(255,255,255,0.5);
    background: rgba(255, 255, 255, 0.9);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s;
    outline: none;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.05);
}

#textInput:focus {
    background: white;
    border-color: #764ba2;
    box-shadow: 0 0 0 4px rgba(118, 75, 162, 0.1);
}

.send-btn {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 5px 15px rgba(16, 185, 129, 0.4);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.send-btn:hover {
    transform: scale(1.1) rotate(10deg);
}

/* Side Panel (Camera & Status) */
.camera-section {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.mascot-display {
    text-align: center;
    padding: 20px;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(20px);
    border-radius: 30px;
    border: var(--glass-border);
    position: relative;
    overflow: hidden;
}

.mascot-image {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    object-fit: cover;
    border: 5px solid white;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    background: white;
    transition: all 0.3s;
}

/* Mascot States */
.mascot-display.idle .mascot-image { animation: float 3s ease-in-out infinite; }
.mascot-display.speaking .mascot-image { animation: pulseSpeak 0.8s ease-in-out infinite; border-color: #22d3ee; }
.mascot-display.listening .mascot-image { animation: pulseListen 1.5s ease-in-out infinite; border-color: #f472b6; }

@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes pulseSpeak { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.03); } }
@keyframes pulseListen { 0%, 100% { box-shadow: 0 0 20px rgba(244, 114, 182, 0.5); } 50% { box-shadow: 0 0 40px rgba(244, 114, 182, 0.8); } }

.camera-container {
    background: black;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    aspect-ratio: 4/3;
    border: 2px solid rgba(255,255,255,0.3);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

#cameraVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-overlay {
    position: absolute;
    bottom: 15px;
    left: 15px;
    right: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    padding: 10px 15px;
    border-radius: 12px;
}

.camera-status {
    color: white;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.iot-status {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(30px);
    padding: 20px;
    border-radius: 24px;
    border: var(--glass-border);
}

.iot-status h3 {
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: #4a5568;
}

.status-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 0.95rem;
    color: #4a5568;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

/* Transcript Box */
.transcript-section {
    background: white;
    margin-top: 15px;
    padding: 15px;
    border-radius: 16px;
    font-size: 0.95rem;
    color: #4a5568;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.05);
}

/* Animations */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0; }
    100% { transform: scale(1); opacity: 0; }
}

/* Responsive */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    .camera-section {
        display: none; /* Hide camera on small tablets/mobile for cleaner chat? or stack it */
    }
}
