:root {
    --primary: #18181b;       /* Zinc 900 */
    --primary-dark: #09090b;  /* Zinc 950 */
    --primary-light: #f4f4f5; /* Zinc 100 */
    --bg-color: #fafafa;      /* Zinc 50 */
    --chat-bg: #ffffff;       /* Pure white */
    --text-primary: #27272a;  /* Zinc 800 */
    --text-secondary: #71717a; /* Zinc 500 */
    --sidebar-bg: #f8f8f8;
    --sidebar-text: #3f3f46;  /* Zinc 700 */
    --border: #e4e4e7;        /* Zinc 200 */
    --user-msg-bg: #18181b;   /* Zinc 900 */
    --bot-msg-bg: #f4f4f5;    /* Zinc 100 */
    --radius: 18px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar Styling */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 32px 24px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 36px;
}

.sidebar-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: -0.01em;
}

.badge {
    background: var(--primary-light);
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid var(--border);
}

.sidebar-content {
    flex: 1;
}

.sidebar-desc {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.6;
    margin-bottom: 28px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #10b981;
    box-shadow: 0 0 0 rgba(16, 185, 129, 0.4);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.secondary-btn {
    width: 100%;
    padding: 12px 16px;
    background: white;
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    font-family: inherit;
    box-shadow: var(--shadow-sm);
}

.secondary-btn:hover {
    background: var(--primary-light);
    border-color: #d4d4d8;
}

/* Chat Section Styling */
.chat-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
    position: relative;
    overflow: hidden;
}

.chat-header {
    padding: 24px 40px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    z-index: 10;
}

.chat-header h1 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: -0.01em;
}

.course-badge {
    background: var(--primary-light);
    color: var(--primary);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    scroll-behavior: smooth;
}

.message {
    display: flex;
    gap: 20px;
    max-width: 85%;
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

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

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.2rem;
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid var(--border);
}

.message.user .avatar {
    background: var(--primary);
    color: white;
    border: none;
}

.bubble {
    padding: 18px 24px;
    border-radius: var(--radius);
    line-height: 1.6;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.message.user .bubble {
    background: var(--user-msg-bg);
    color: white;
    border-top-right-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.message.bot .bubble {
    background: var(--bot-msg-bg);
    border: 1px solid var(--border);
    border-top-left-radius: 4px;
}

.bubble p {
    margin-bottom: 12px;
}

.bubble p:last-child {
    margin-bottom: 0;
}

/* Markdown Specifics */
.bubble pre {
    background: var(--primary);
    color: var(--primary-light);
    padding: 16px;
    border-radius: 12px;
    overflow-x: auto;
    margin: 16px 0;
    font-size: 0.9rem;
    border: 1px solid var(--primary-dark);
}

.bubble code {
    background: rgba(0,0,0,0.06);
    padding: 3px 6px;
    border-radius: 6px;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 0.85em;
    color: var(--primary);
}

.message.user .bubble code {
    background: rgba(255,255,255,0.2);
    color: white;
}

/* Input Area Styling */
.input-area {
    padding: 24px 40px 32px;
    background: var(--chat-bg);
}

#chat-form {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    background: var(--chat-bg);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 8px 8px 8px 24px;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

#chat-form:focus-within {
    border-color: #a1a1aa;
    box-shadow: var(--shadow-md);
}

#message-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 14px 0;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-primary);
    resize: none;
    outline: none;
    max-height: 200px;
    line-height: 1.5;
}

#message-input::placeholder {
    color: var(--text-secondary);
}

#send-btn {
    background: var(--primary);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

#send-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

#send-btn:disabled {
    background: var(--border);
    color: var(--text-secondary);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Loading Dots */
.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 16px 20px;
    background: var(--bot-msg-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    border-top-left-radius: 4px;
    width: fit-content;
}

.dot {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

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

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}
