:root {
    --primary-color: #5E5D5D; /* Dark Charcoal Grey (Main Button Color) */
    --primary-hover: #4a4a4a;
    --bg-color: #FFFFFF; /* Pure White (Main Background) */
    --sidebar-bg: #F3F3F3; /* Soft Off-white (Secondary Base) */
    --text-main: #000000; /* Absolute Black (Typography) */
    --text-muted: #5E5D5D; /* Dark Grey for muted text */
    --accent-color: #6C5D4A; /* Earthy Taupe (Brand Accent) */
    --border-color: rgba(0, 0, 0, 0.08);
    --shadow-main: 0 4px 12px rgba(0, 0, 0, 0.04);
    --user-bubble: #F3F3F3; /* Light Grey for User */
    --assistant-bubble: #6C5D4A; /* Taupe for Assistant (Signature Look) */
    --assistant-text: #FFFFFF;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    width: 100vw;
    margin: 0;
    overflow: hidden;
}

.app-container {
    width: 100%;
    height: 100vh; /* Enforce viewport height */
    display: flex;
    flex-direction: column;
}

/* Main Chat */
.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
    position: relative;
    width: 100%;
    height: 100%; /* Ensure it fills the container */
    overflow: hidden; /* Constrain the height */
}

.chat-header {
    height: 72px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: #FFFFFF;
}

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

.logo-img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.logo-text {
    font-weight: 700;
    font-size: 18px;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.chat-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.reset-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 6px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.reset-btn:hover {
    background-color: var(--sidebar-bg);
}

.status-badge {
    font-size: 11px;
    background-color: #E8F5E9;
    color: #2E7D32;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
}

/* Messages */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 40px 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-height: 0; /* Essential for flexbox scrolling */
}

.message-wrapper {
    display: flex;
    flex-direction: column;
}

.message-bubble {
    max-width: 85%;
    padding: 16px 20px;
    border-radius: 20px;
    font-size: 15px;
    line-height: 1.6;
    position: relative;
    transform: translateY(10px);
    opacity: 0;
    animation: slideUp 0.35s forwards ease-out;
}

.assistant .message-bubble {
    align-self: flex-start;
    background-color: var(--assistant-bubble);
    color: var(--assistant-text);
    border-bottom-left-radius: 4px;
}

.user .message-bubble {
    align-self: flex-end;
    background-color: var(--user-bubble);
    color: var(--text-main);
    border-bottom-right-radius: 4px;
}

@keyframes slideUp {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Input Area */
.input-area {
    padding: 24px;
    padding-bottom: 32px;
    display: flex;
    flex-direction: column;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: flex-end;
    background-color: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 12px 18px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.03);
}

textarea {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px;
    font-size: 15px;
    resize: none;
    outline: none;
    max-height: 200px;
}

.send-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 12px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.send-btn:hover:not(:disabled) {
    background-color: var(--primary-hover);
    transform: scale(1.05);
}

.send-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.input-disclaimer {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 14px;
}

/* Thinking Indicator */
.thinking .message-bubble {
    display: flex;
    gap: 4px;
    padding: 14px 20px;
}

.dot {
    width: 6px;
    height: 6px;
    background-color: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    animation: dotPulse 1.4s infinite ease-in-out both;
}

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

@keyframes dotPulse {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    .app-container {
        max-width: 100%;
        box-shadow: none;
    }
    .chat-title {
        display: none; /* Hide center title on mobile to avoid overlap */
    }
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 6px;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background-color: var(--sidebar-bg);
    color: var(--accent-color);
}

/* Modal Styling */
.settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.settings-modal.active {
    display: flex;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 600px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalSlide 0.3s ease-out;
}

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

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 24px;
}

.modal-body p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

#promptInput {
    width: 100%;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    outline: none;
    background: #F9F9F9;
}

#promptInput:focus {
    border-color: var(--accent-color);
}

.modal-footer {
    padding: 20px 24px;
    background: #F9F9F9;
    display: flex;
    justify-content: flex-end;
}

.save-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.save-btn:hover {
    background-color: #5a4d3d;
    transform: translateY(-1px);
}
