body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: #1a202c;
    color: #e2e8f0;
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.main-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

.chat-box {
    flex-grow: 1;
    width: 100%;
    overflow-y: auto;
    padding: 20px;
    display: none;
    flex-direction: column;
    gap: 15px;
    padding-bottom: 120px; /* Space for the input form */
}

/* Custom Scrollbar Styling for all browsers */
.chat-box {
    scrollbar-width: thin; /* For Firefox */
    scrollbar-color: #90A4AE #1a202c; /* For Firefox: thumb and track */
}

/* For Chrome, Safari, and other WebKit browsers */
.chat-box::-webkit-scrollbar {
    width: 12px; /* Make scrollbar wider */
}

.chat-box::-webkit-scrollbar-track {
    background: #2d3748; /* Add a background to the track */
}

.chat-box::-webkit-scrollbar-thumb {
    background-color: #e2e8f0; /* Make thumb highly visible */
    border-radius: 6px;
    border: 3px solid #2d3748; /* Add padding around thumb */
}

#scroll-to-bottom {
    position: absolute;
    bottom: 110px; /* Position above the input form */
    right: 30px;
    background-color: #2d3748;
    border: 1px solid #4a5568;
    color: #cbd5e0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 200;
}

#scroll-to-bottom.visible {
    opacity: 1;
    pointer-events: auto;
}

.message {
    padding: 10px 15px;
    border-radius: 18px;
    max-width: 75%;
    line-height: 1.5;
    display: inline-block;
    text-align: left;
    word-wrap: break-word;
}

.user-message {
    background-color: #4a5568; /* Medium Blue-Grey */
    color: white;
    align-self: flex-end;
}

.bot-message {
    background-color: #2d3748; /* Lighter Blue-Grey */
    color: #e2e8f0;
    align-self: flex-start;
}

.bot-message ol,
.bot-message ul {
    padding-left: 20px;
}

.bot-message strong {
    font-weight: 600;
}

h1 {
    font-weight: 400;
    font-size: 2.5rem;
    margin-bottom: 2rem;
    transition: all 0.3s ease;
}

.logo-container {
    position: fixed;
    top: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 1000;
    background: rgba(26, 32, 44, 0.8);
    padding: 10px;
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.logo {
    max-height: 60px;
    max-width: 200px;
    transition: all 0.3s ease;
    object-fit: contain;
    display: block;
}

#new-chat-button {
    position: absolute;
    top: 20px;
    right: 20px;
    background-color: transparent;
    border: 1px solid #4a5568;
    color: #cbd5e0;
    z-index: 100;
}

#new-chat-button:hover {
    background-color: #2d3748;
}

#chat-form {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 700px;
    padding: 1rem;
    box-sizing: border-box;
    background-color: #1a202c; /* Match body background */
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.input-container {
    display: flex;
    align-items: flex-end;
    background-color: #2d3748; /* Lighter Blue-Grey */
    border-radius: 30px;
    padding: 10px 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    flex-grow: 1;
    min-width: 0;
}

#user-input {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: #e2e8f0;
    font-size: 1.1rem;
    padding: 10px;
    font-family: 'Nunito', sans-serif;
    resize: none;
    overflow-y: hidden;
    line-height: 1.4;
    max-height: 150px; /* Limit the max height */
    text-align: left !important;
}

#user-input::placeholder {
    color: #a0aec0; /* Lighter Grey for placeholder */
}

#user-input:focus {
    outline: none;
}

.icon-button {
    background: transparent;
    border: none;
    color: #b0b0b0;
    cursor: pointer;
    font-size: 1.2rem;
    margin: 0 5px;
    padding: 5px;
    margin-bottom: 5px; /* Adjust alignment with textarea */
}

.icon-button:hover {
    color: #4fd1c5; /* Soft Teal for hover */
}

.send-button {
    background-color: #4fd1c5; /* Soft Teal */
    color: #1a202c; /* Dark Slate Blue */
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    padding: 0;
    margin: 0;
    margin-bottom: 5px; /* To align with input box */
}

.send-button:hover {
    background-color: #38b2ac; /* Darker Teal */
}

/* Loading Indicator Styles */
.loading-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
}

.typing-indicator {
    display: flex;
    gap: 4px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #4fd1c5;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    30% {
        transform: scale(1.2);
        opacity: 1;
    }
}

.loading-text {
    color: #a0aec0;
    font-size: 0.9rem;
    font-style: italic;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    body {
        padding: 0;
        margin: 0;
        overflow: auto; /* Allow scrolling on mobile */
        height: auto; /* Remove fixed height on mobile */
        min-height: 100vh; /* Ensure full height */
    }
    
    .main-container {
        max-width: 100%;
        padding: 0 10px;
        padding-bottom: 120px;
        overflow: visible; /* Allow content to be scrollable */
        height: auto; /* Remove fixed height constraints */
    }
    
    .chat-box {
        padding: 70px 10px 140px 10px; /* Add more top padding to avoid button overlap */
        gap: 12px;
        overflow-y: auto; /* Ensure vertical scrolling */
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        height: auto; /* Remove height constraints */
        max-height: none; /* Remove max-height limits */
    }
    
    .message {
        max-width: 85%;
        padding: 12px 16px;
        font-size: 1rem;
        line-height: 1.4;
    }
    
    h1 {
        font-size: 2rem;
        margin-bottom: 1.5rem;
        padding: 0 20px;
        text-align: center;
    }
    
    .logo-container {
        top: 15px;
        left: 15px;
        gap: 10px;
    }
    
    .logo {
        max-height: 60px;
        max-width: 200px;
    }
    
    #new-chat-button {
        top: 15px;
        right: 15px;
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }
    
    #chat-form {
        padding: 15px 10px;
        gap: 8px;
        bottom: 0;
        left: 0;
        transform: none;
        width: 100%;
        box-sizing: border-box;
    }
    
    .input-container {
        padding: 12px 16px;
        border-radius: 25px;
    }
    
    #user-input {
        font-size: 1rem;
        padding: 8px;
        max-height: 120px;
    }
    
    .send-button {
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
        margin-bottom: 0;
    }
    
    #scroll-to-bottom {
        bottom: 90px;
        right: 20px;
        width: 35px;
        height: 35px;
        font-size: 0.9rem;
    }
    
    /* Adjust message bubbles for mobile */
    .user-message {
        align-self: flex-end;
        margin-left: 8%; /* Reduced from 15% to move message more to the left */
        margin-right: 15px; /* Move user messages slightly to the left */
    }
    
    .bot-message {
        margin-right: 15%;
    }
    
    /* Loading indicator adjustments */
    .loading-indicator {
        gap: 8px;
        padding: 8px 0;
    }
    
    .loading-text {
        font-size: 0.85rem;
    }
    
    .typing-indicator span {
        width: 6px;
        height: 6px;
    }
}

/* Fix for mobile viewport issues */
@media (max-width: 768px) {
    html {
        overflow-x: hidden; /* Prevent horizontal scroll */
        -webkit-text-size-adjust: 100%; /* Prevent text scaling */
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    h1 {
        font-size: 1.8rem;
        margin-bottom: 1rem;
    }
    
    .logo {
        max-height: 50px;
        max-width: 150px;
    }
    
    .message {
        max-width: 90%;
        padding: 10px 14px;
        font-size: 0.95rem;
    }
    
    #user-input {
        font-size: 0.95rem;
        padding: 6px;
    }
    
    .send-button {
        width: 42px;
        height: 42px;
        font-size: 1.2rem;
    }
    
    #new-chat-button {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .input-container {
        padding: 10px 14px;
    }
    
    #chat-form {
        padding: 12px 8px;
    }
    
    .chat-box {
        padding: 70px 8px 130px 8px; /* Add more top padding to avoid button overlap */
    }
    
    .main-container {
        padding: 0 8px;
        padding-bottom: 110px;
    }
}

/* Landscape mobile orientation */
@media (max-width: 768px) and (orientation: landscape) {
    h1 {
        font-size: 1.6rem;
        margin-bottom: 1rem;
    }
    
    .logo {
        max-height: 45px;
    }
    
    .main-container {
        padding-bottom: 100px;
    }
    
    .chat-box {
        padding-bottom: 120px;
    }
    
    #user-input {
        max-height: 80px;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .icon-button {
        min-width: 44px;
        min-height: 44px;
        padding: 8px;
    }
    
    .send-button {
        min-width: 48px;
        min-height: 48px;
    }
    
    #user-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

