:root {
    /* Color Palette */
    --primary-bg: #f8fafc;
    --secondary-bg: #ffffff;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --user-bubble: #3b82f6;
    --bot-bubble: #f1f5f9;
    --header-height: 64px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    width: 100%;
    height: 100%;
    background-color: var(--primary-bg);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* --- Header (Fixed Height) --- */
header {
    height: var(--header-height);
    min-height: var(--header-height);
    /* Prevent collapse */
    max-height: var(--header-height);
    /* Prevent expansion */
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    z-index: 1000;
    position: sticky;
    top: 0;
    width: 100%;
    flex-shrink: 0;
    /* Critical: prevents header from shrinking */
}

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

.logo {
    height: 32px;
    width: 32px;
    object-fit: contain;
    flex-shrink: 0;
}

header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    white-space: nowrap;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 24px;
}

.nav-links li a {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.15s ease;
}

.nav-links li a:hover {
    color: var(--accent-color);
}

.desktop-nav {
    display: flex;
}

.menu-toggle {
    display: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 10px;
}

/* --- Mobile Sidebar (Vertical Fix) --- */
.side-menu {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    height: 100%;
    background: white;
    z-index: 2000;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.05);
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.side-menu.active {
    right: 0;
}

.side-menu-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.side-menu-title {
    font-weight: 700;
    font-size: 1.1rem;
}

.close-menu {
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
}

/* Mobile Nav - VERTICAL Layout Fix */
.mobile-nav {
    flex-direction: column !important;
    /* Force vertical */
    padding: 24px;
    gap: 20px;
    display: flex !important;
}

.mobile-nav li {
    width: 100%;
}

.mobile-nav li a {
    display: block;
    padding: 12px 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* --- Main Layout --- */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    position: relative;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-box {
    flex: 1;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px 24px;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

/* Welcome UI */
.welcome-screen {
    margin: auto;
    text-align: center;
    padding: 60px 20px;
}

.welcome-logo {
    width: 72px;
    height: 72px;
    margin-bottom: 24px;
}

.welcome-screen h2 {
    font-size: 2rem;
    font-weight: 700;
    color: #1a1a1a;
}

/* --- Messages (No Avatars, Consistent Width) --- */
.chat-message {
    display: flex;
    width: 100%;
    margin-bottom: 16px;
}

/* User messages: right-aligned */
.chat-message.user {
    justify-content: flex-end;
}

/* Bot messages: left-aligned */
.chat-message.bot {
    justify-content: flex-start;
}

/* Hide avatars completely */
.avatar {
    display: none !important;
}

.message-content {
    padding: 16px 24px;
    border-radius: 18px;
    font-size: 1.05rem;
    line-height: 1.6;
    max-width: 700px;
    /* Consistent max-width for both */
    width: fit-content;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

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

.bot .message-content {
    background: white;
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
}

/* Typing indicator animation */
.typing-dots {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 20px !important;
}

.typing-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-secondary);
    animation: typing 1.4s infinite;
}

.typing-dots .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    60%,
    100% {
        opacity: 0.3;
        transform: scale(0.8);
    }

    30% {
        opacity: 1;
        transform: scale(1);
    }
}


/* --- Input Area --- */
.input-area {
    width: 100%;
    background: rgba(248, 250, 252, 0.98);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    position: sticky;
    bottom: 0;
    z-index: 100;
    padding: 16px 24px 24px;
    flex-shrink: 0;
}

.input-wrapper {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 4px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

#prompt {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    max-height: 200px;
    min-height: 48px;
    resize: none;
    font-family: inherit;
    padding: 12px 0;
    background: transparent;
    line-height: 1.5;
    display: block;
}

#send-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--accent-color);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.input-area-footer {
    text-align: center;
    margin-top: 12px;
    width: 100%;
}

.input-area-footer p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Code Blocks */
.code-block-container {
    margin: 24px 0;
    border-radius: 12px;
    background: #0f172a;
    overflow: hidden;
    border: 1px solid #1e293b;
}

.code-header {
    display: flex;
    justify-content: space-between;
    padding: 12px 20px;
    background: #1e293b;
    color: #94a3b8;
    font-size: 0.85rem;
}

.copy-btn {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

pre {
    padding: 20px !important;
    overflow-x: auto;
    margin: 0 !important;
}

/* --- About & Projects Pages --- */
.about-me,
.projects {
    padding: 60px 24px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

/* About Me specific centering */
.about-me {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.about-me-content {
    width: 100%;
    max-width: 800px;
}

.about-me .card {
    display: block;
    /* Changed from flex to block */
    text-align: left;
    /* Keep text left-aligned */
}

/* Projects specific centering */
.projects {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.projects-content {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.projects-content h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 40px;
    text-align: center;
    width: 100%;
}

.card,
.project {
    background: white;
    padding: 40px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
    /* Consistent spacing */
    width: 100%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.project:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Profile Picture - Circular with Blue Outline */
.profile-pic {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    /* Circular */
    border: 4px solid var(--accent-color);
    /* Blue outline */
    margin: 0 auto 32px;
    /* Centered with bottom margin */
    object-fit: cover;
    display: block;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
    /* Subtle blue shadow */
}

.card-content {
    width: 100%;
}

.card-content h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: #000000;
    /* Black text */
}

.card-content h3 {
    font-size: 1.4rem;
    font-weight: 600;
    margin: 32px 0 16px;
    color: var(--accent-color);
    text-align: left;
}

.card-content p,
.card-content ul li {
    color: #1a1a1a;
    /* Dark black for readability */
    margin-bottom: 12px;
    line-height: 1.7;
    text-align: left;
}

.card-content>p:first-of-type {
    font-size: 1.15rem;
    color: #4b5563;
    /* Subtitle color */
    margin-bottom: 8px;
}

.card-content p strong {
    color: #000000;
    /* Black for labels */
    font-weight: 600;
}

.card-content ul {
    list-style: none;
    padding-left: 0;
    text-align: left;
}

.card-content ul li::before {
    content: "→ ";
    color: var(--accent-color);
    font-weight: bold;
    margin-right: 8px;
}

.project h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.project p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
}

.project a {
    display: inline-block;
    margin-top: 8px;
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.project a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.main-footer {
    padding: 32px 24px;
    text-align: center;
    background: white;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.main-footer p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* --- Mobile Optimizations --- */
@media (max-width: 768px) {
    header {
        padding: 0 16px;
    }

    .desktop-nav {
        display: none;
    }

    .menu-toggle {
        display: block;
    }

    .chat-box {
        padding: 24px 16px 40px;
        /* Consistent padding */
        max-width: 100%;
        /* Prevent overflow */
        overflow-x: hidden;
        /* Hide horizontal scroll */
    }

    .message-content {
        max-width: 90%;
        /* Responsive width */
        padding: 14px 18px;
        font-size: 1rem;
        /* Ensure content doesn't overflow */
        overflow-wrap: break-word;
        word-break: break-word;
    }

    /* Ensure code blocks don't cause overflow */
    .code-block-container {
        max-width: 100%;
        overflow-x: auto;
    }

    pre {
        max-width: 100%;
        overflow-x: auto !important;
    }

    .input-area {
        padding: 12px 12px 20px;
    }

    .input-wrapper {
        border-radius: 12px;
    }

    #prompt {
        padding: 10px 0;
        min-height: 40px;
    }

    .card,
    .project {
        padding: 24px;
        margin-bottom: 20px;
        /* Consistent spacing on mobile */
    }

    .about-me,
    .projects {
        padding: 40px 16px;
    }

    /* Mobile About Me styles */
    .profile-pic {
        width: 140px;
        height: 140px;
        margin-bottom: 24px;
    }

    .card-content h2 {
        font-size: 1.75rem;
    }

    .card-content h3 {
        font-size: 1.25rem;
        margin: 24px 0 12px;
    }

    .card-content>p:first-of-type {
        font-size: 1.05rem;
    }

    /* Mobile Projects styles */
    .projects-content h2 {
        font-size: 1.75rem;
        margin-bottom: 32px;
    }

    .project h3 {
        font-size: 1.3rem;
    }
}