:root {
    --bg-color: #0f111a;
    --sidebar-bg: #161b22;
    --text-primary: #e6e6e6;
    --text-secondary: #a0a0a0;
    --accent-color: #cfb53b;
    /* Old Gold */
    --accent-hover: #e6c94c;
    --user-bubble-bg: #2d333b;
    --ai-bubble-bg: linear-gradient(135deg, #1f242d 0%, #161b22 100%);
    --input-bg: rgba(22, 27, 34, 0.8);
    --border-color: #30363d;
    --font-heading: 'Playfair Display', serif;
    --font-body: 'Outfit', sans-serif;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --transition: all 0.3s ease;
}

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-primary);
    color: var(--text-primary);
    height: 100vh;
    /* Fallback for browsers that do not support dvh */
    height: 100dvh;
    height: 100dvh;
    overflow: hidden;
    overflow-x: hidden;
    /* Prevent horizontal scroll globally */
    line-height: 1.6;
}

/* Layout */
.app-container {
    display: flex;
    height: 100%;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    border-right: 1px solid var(--border-color);
    transition: width 0.3s ease, transform 0.3s ease;
    z-index: 100;
}

/* Collapsed Sidebar */
.sidebar.collapsed {
    width: 80px;
}

.sidebar.collapsed .logo span,
.sidebar.collapsed .new-chat-btn span,
.sidebar.collapsed .history-label,
.sidebar.collapsed .history-item span,
.sidebar.collapsed .footer-link span,
.sidebar.collapsed .user-profile span {
    display: none;
}

.sidebar.collapsed .new-chat-btn {
    justify-content: center;
    padding: 0.75rem;
}

.sidebar.collapsed .logo {
    justify-content: center;
}

.sidebar.collapsed .history-item {
    justify-content: center;
}

.sidebar.collapsed .footer-link {
    justify-content: center;
}

.sidebar.collapsed .user-profile {
    justify-content: center;
}

.sidebar-header {
    justify-content: center;
}

.sidebar-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 0 0.5rem;
}

.sidebar.collapsed .sidebar-header {
    align-items: center;
    padding: 0;
}

.logo {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.logo:hover {
    opacity: 0.8;
}

.logo i {
    color: var(--accent-color);
}

.menu-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    cursor: pointer;
    display: block;
    /* Show on all screens */
}

.new-chat-btn {
    background-color: #21262d;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: var(--transition);
    text-align: left;
}

.new-chat-btn:hover {
    background-color: #30363d;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    margin-top: 2rem;
}

.history-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
    padding: 0 0.5rem;
}

.history-item {
    padding: 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: var(--transition);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item:hover {
    background-color: #21262d;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    transition: var(--transition);
    margin-top: auto;
    width: 100%;
}

.sidebar-link:hover {
    color: var(--text-primary);
    background-color: #21262d;
}

.sidebar.collapsed .sidebar-link span {
    display: none;
}

.sidebar.collapsed .sidebar-link {
    justify-content: center;
}

.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
    margin-top: 0.5rem;
    /* Reduced since about btn is above */
}

.footer-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.5rem;
    font-size: 0.9rem;
    transition: var(--transition);
}

.footer-link:hover {
    color: var(--accent-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    margin-top: 0.5rem;
    color: var(--text-primary);
}

.avatar {
    width: 32px;
    height: 32px;
    background-color: var(--accent-color);
    color: #000;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--bg-color);
}

.mobile-header {
    display: none;
    padding: 1rem;
    background-color: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    justify-content: space-between;
}

.mobile-menu-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
}

.mobile-logo {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1.2rem;
}

/* Chat Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 6rem;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

/* Welcome Screen */
.welcome-screen {
    text-align: center;
    margin-top: 10vh;
    animation: fadeIn 0.8s ease-out;
}

.welcome-icon {
    font-size: 4rem;
    color: var(--accent-color);
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 10px rgba(207, 181, 59, 0.3));
}

.welcome-screen h1 {
    font-family: var(--font-heading);
    font-size: 3rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #fff, #a0a0a0);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-screen p {
    color: var(--text-secondary);
    font-size: 1.2rem;
    margin-bottom: 3rem;
}

.suggestion-cards {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    max-width: 800px;
    margin: 0 auto;
}

.suggestion-card {
    background-color: #1e2329;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: calc(33.33% - 1rem);
    min-width: 200px;
    text-align: left;
    font-family: var(--font-body);
}

.suggestion-card:hover {
    background-color: #2a3038;
    border-color: var(--text-secondary);
}

.suggestion-card i {
    opacity: 0;
    transform: translateX(-5px);
    transition: var(--transition);
    color: var(--accent-color);
}

.suggestion-card:hover i {
    opacity: 1;
    transform: translateX(0);
}

/* Message Styles */
.message {
    display: flex;
    gap: 1.5rem;
    max-width: 85%;
    margin-bottom: 3rem;
    animation: slideUp 0.3s ease-out;
}

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

.message.ai {
    align-self: flex-start;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background-color: #3d4450;
    color: #fff;
}

.message.ai .message-avatar {
    background: linear-gradient(135deg, var(--accent-color), #b8860b);
    color: #000;
}

.message-content {
    padding: 1.5rem 2rem;
    border-radius: 18px;
    font-size: 1rem;
    font-size: 1rem;
    line-height: 1.75;
    position: relative;
    overflow-wrap: break-word;
    /* Crucial for mobile */
    word-break: break-word;
    /* Crucial for mobile */
    min-width: 0;
    /* Flexbox overflow fix */
}

.message.user .message-content {
    background-color: var(--user-bubble-bg);
    color: var(--text-primary);
    border-bottom-right-radius: 4px;
}

.message.ai .message-content {
    background: var(--ai-bubble-bg);
    color: #ececec;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.message-content p {
    margin-bottom: 1rem;
}

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

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 1rem;
    margin-left: 3rem;
    /* Align with avatar */
}

.typing-indicator.hidden {
    display: none;
}

.dot {
    width: 8px;
    height: 8px;
    background-color: var(--text-secondary);
    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;
}

/* Input Area */
.input-area-wrapper {
    padding: 1.5rem 2rem;
    background: linear-gradient(to top, var(--bg-color) 80%, transparent);
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

.input-area {
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 0.5rem 1rem;
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    transition: var(--transition);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-md);
}

.input-area:focus-within {
    border-color: var(--accent-color);
    background-color: rgba(22, 27, 34, 0.95);
}

textarea {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    resize: none;
    padding: 0.75rem 0;
    max-height: 150px;
    outline: none;
}

textarea::placeholder {
    color: var(--text-secondary);
}

.input-action-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 50%;
    transition: var(--transition);
}

.input-action-btn:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.1);
}

.send-btn {
    background-color: var(--accent-color);
    border: none;
    color: #000;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.1rem;
    margin-bottom: 2px;
}

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

.send-btn:disabled {
    background-color: #30363d;
    color: #6e7681;
    cursor: not-allowed;
}

.disclaimer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.75rem;
    padding-bottom: 0.5rem;
    /* Ensure some spacing at the very bottom */
}

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

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

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        height: 100%;
        transform: translateX(-100%);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .mobile-header {
        display: flex;
    }

    .chat-container {
        padding: 1rem;
    }

    .welcome-screen h1 {
        font-size: 2rem;
    }

    .welcome-screen p {
        font-size: 1rem;
    }

    .suggestion-card {
        width: 100%;
    }

    .input-area-wrapper {
        padding: 1rem;
    }

    .overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.6);
        z-index: 90;
        display: none;
    }

    .overlay.active {
        display: block;
    }

    .menu-toggle {
        display: block;
    }
}