:root {
    /* Color Palette - Emerald Green Theme */
    --primary: #10b981;
    --primary-hover: #059669;
    --primary-light: #d1fae5;
    --bg-app: #f3f4f6;
    --bg-sidebar: #ffffff;
    --bg-chat: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --doxoba-accent: #2563EB;
    /* Keeping brand consistency if needed */

    /* Spacing & Layout */
    --sidebar-width: 280px;
    --header-height: 70px;
    --input-height: 80px;

    /* Shadows & Radius */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --radius-lg: 1rem;
    --radius-md: 0.75rem;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-primary);
    overflow: hidden;
    /* Prevent body scroll, handle in containers */
    height: 100vh;
    height: 100dvh;
}

/* --- App Layout --- */
.app-wrapper {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* --- Sidebar (Desktop) --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    transition: transform var(--transition-fast);
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
    padding-left: 0.5rem;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.user-profile {
    margin-top: auto;
    padding: 1rem;
    background: var(--bg-app);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.avatar {
    width: 40px;
    height: 40px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.1rem;
}

.user-info {
    flex: 1;
    overflow: hidden;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-status {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.status-dot {
    width: 6px;
    height: 6px;
    background-color: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
    animation: pulse 2s infinite;
}

/* Navigation Links / Buttons */
.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    font-size: 0.95rem;
}

.nav-item:hover,
.nav-item.active {
    background: var(--bg-app);
    color: var(--primary);
}

.nav-item svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}


/* --- Main Chat Area --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-chat);
    position: relative;
    max-width: 100%;
    /* Ensure it doesn't overflow */
}

/* Header (Mobile Only mostly, but structure kept) */
.mobile-header {
    display: none;
    /* Hidden on desktop by default */
    padding: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    z-index: 30;
    justify-content: space-between;
    align-items: center;
}

/* Chat Window */
.chat-window {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 10% 2rem 10%;
    /* Center content loosely */
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scroll-behavior: smooth;
    background: radial-gradient(circle at 50% 10%, #f9fafb 0%, white 100%);
}

.chat-window::-webkit-scrollbar {
    width: 6px;
}

.chat-window::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

/* Messages */
.message {
    max-width: 75%;
    padding: 1.25rem 1.5rem;
    font-size: 1rem;
    line-height: 1.6;
    position: relative;
    animation: slideUp 0.3s ease-out forwards;
    opacity: 0;
    transform: translateY(10px);
}

.message.ai {
    align-self: flex-start;
    background: #f3f4f6;
    color: var(--text-primary);
    border-radius: 4px 20px 20px 20px;
}

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: white;
    border-radius: 20px 20px 4px 20px;
    box-shadow: var(--shadow-md);
}

/* Markdown Styling inside Messages */
.message.ai strong {
    font-weight: 700;
    color: #111827;
}

.message.ai p {
    margin-bottom: 0.75rem;
}

.message.ai p:last-child {
    margin-bottom: 0;
}

.message.ai ul,
.message.ai ol {
    margin-left: 1.25rem;
    margin-bottom: 0.75rem;
}

.message.ai li {
    margin-bottom: 0.25rem;
}

/* Input Area */
.input-area {
    padding: 1.5rem 2rem;
    background: white;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    position: relative;
    z-index: 10;
}

.input-wrapper {
    flex: 1;
    position: relative;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    transition: all 0.2s;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
    display: flex;
    align-items: center;
}

.input-wrapper:focus-within {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

textarea {
    flex: 1;
    border: none;
    background: transparent;
    padding: 14px 20px;
    font-size: 1rem;
    resize: none;
    outline: none;
    max-height: 150px;
    height: 52px;
    /* Initial height */
    line-height: 1.5;
    color: var(--text-primary);
    font-family: inherit;
    width: 100%;
}

button.send-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
    flex-shrink: 0;
}

button.send-btn:hover {
    transform: scale(1.05);
    background: var(--primary-hover);
    box-shadow: 0 6px 15px rgba(16, 185, 129, 0.4);
}

button.send-btn:disabled {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

button.send-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
    margin-left: 3px;
    /* Visual center */
}

/* Loading Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 8px;
    align-items: center;
    height: 24px;
}

.dot {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    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;
}

/* Animations */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(0.9);
    }
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {
    .app-wrapper {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        /* Hidden off-canvas */
        height: 100%;
        width: 80%;
        /* Partial width */
        max-width: 300px;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
        z-index: 100;
    }

    .sidebar.active {
        left: 0;
        transform: translateX(0);
    }

    /* Overlay for sidebar */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 90;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
        backdrop-filter: blur(4px);
    }

    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

    .mobile-header {
        display: flex;
    }

    .chat-window {
        padding: 1rem;
        gap: 1rem;
    }

    .message {
        max-width: 90%;
        font-size: 1rem;
        /* Better readability */
    }

    .input-area {
        padding: 1rem 1rem max(1rem, env(safe-area-inset-bottom)) 1rem;
    }

    textarea {
        font-size: 16px;
        /* Prevent iOS Zoom */
    }
}