/* Base Body Styles */
/* html,
body,
* {
    font-family: 'OpenDyslexic' !important;
} */

body {
    font-family: 'OpenDyslexic', 'Inter', 'Segoe UI', 'Roboto', Arial, sans-serif;
    background: #fff;
    margin: 0;
    display: flex;
    flex-direction: column;
    /* for mobile address bar issue */
    height: 100vh;
    height: 100dvh;
    /* height: 100svh; */
    overflow: hidden;
}

/* App Layout Styles */
.app-layout {
    display: flex;
    /* for mobile address bar issue */
    height: 100vh;
    height: 100dvh;
    /* height: 100svh; */
    /* height: 100%; */
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
    overflow: hidden;
    /* Prevent flex item from overflowing */
}

/* Login Container Styles */
.login-container {
    width: 300px;
    height: 100%;
    min-width: 260px;
    max-width: 400px;
    background: #f5f5f5;
    padding: 32px 18px 18px 18px;
    box-sizing: border-box;
    border-right: 1px solid #eee;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* justify-content: flex-start; */
    justify-content: center;
    gap: 12px;
}

.login-container h2 {
    margin-bottom: 16px;
}

/* Google Login Button */
#google-login {
    background: #f5f5f5;
    padding: 10px 0;
    color: #222;
    border: 1px solid #bbb;
    border-radius: 8px;
    margin-bottom: 8px;
    display: block;
    transition: background 0.2s, border 0.2s;
    width: 100%;
    cursor: pointer;
}

#google-login:hover {
    transform: scale(1.01);
    box-shadow: 0 2px 12px 0 #bbb8;
}

/* Login Form Styles */
.login-or {
    text-align: center;
    color: #888;
    margin: 8px 0;
    font-size: 1em;
}

#login-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#login-form input[type="email"] {
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid #ddd;
    outline: none;
    background: #fff;
    font-size: 1em;
}

#login-form button[type="submit"] {
    padding: 10px 0;
    border-radius: 8px;
    background: #bdd;
    color: #0a2a4a;
    border: none;
    font-size: 1em;
    cursor: pointer;
}

#login-form button[type="submit"]:hover {
    transform: scale(1.01);
    box-shadow: 0 2px 12px 0 #bdd6;
}

.login-message {
    min-height: 32px;
    /* text-align: center; */
    color: rgb(0, 0, 0);
    font-size: 1em;
}

/* Chat Styles */
#chat {
    flex: 1;
    overflow-y: auto;
    width: 50vw;
    margin: 0 auto;
    padding: 24px 16px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: #bbb #ffffff;
}

/* Chat Bubble Styles */
.bubble {
    padding: 12px 18px;
    border-radius: 18px;
    font-size: 1rem;
    line-height: 1.5;
    word-break: break-word;
    margin-bottom: 2px;
    position: relative;
    animation: fadein 0.2s;
}

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

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

.user {
    background: #bdd;
    color: #0a2a4a;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.llm {
    color: #222;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

/* Form and Input Styles */
#form {
    display: flex;
    gap: 8px;
    padding: 16px;
    width: 50vw;
    margin: 0 auto;
}

#input {
    flex: 1;
    font-size: 1rem;
    padding: 10px 14px;
    border-radius: 100px;
    border: 1px solid #ddd;
    outline: none;
    background: #ffffff;
    transition: border 0.2s;
    width: 100%;
    box-sizing: border-box;
}

#input:focus {
    border: 1.5px solid #555;
}

/* Send Button */
#send {
    background: none;
    color: #222;
    border: none;
    border-radius: 50%;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

#send:hover {
    background: #eee;
}

/* Disclaimer */
#disclaimer {
    text-align: center;
    color: #888;
    font-size: 0.95em;
    margin: 12px 0 8px 0;
}

/* Sidebar Styles */
#sidebar-content-wrapper {
    width: 300px;
    background: #f5f5f5;
    height: 100%;
    padding: 0;
    box-sizing: border-box;
    border-right: 1px solid #eee;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.sidebar-fixed-top {
    padding: 24px 0 24px 0;
    /* background: #f5f5f5; */
    z-index: 1;
}

.sidebar-new-chat {
    display: flex;
    align-items: center;
    color: #222;
    text-decoration: none;
    font-size: 1.1em;
    padding: 8px 24px;
    border-radius: 8px;
    margin-bottom: 8px;
    transition: background 0.2s;
    gap: 8px;
}

.sidebar-new-chat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-new-chat:hover {
    background: #d6d6d6;
}

#sidebar-content {
    /* padding: 24px 0 0 0; */
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #bbb #f5f5f5;
}

.sidebar-chats-header {
    margin: 16px 0 0 0;
    color: #444;
    padding-left: 24px;
    font-size: 1.05em;
}

.sidebar-chat-link {
    display: block;
    color: #222;
    text-decoration: none;
    font-size: 1em;
    padding: 6px 24px;
    border-radius: 6px;
    margin-top: 4px;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.sidebar-chat-link:hover {
    background: #eee;
    color: #1565c0;
}

#sidebar-user-account {
    padding: 12px 24px 18px 24px;
    color: #444;
    font-size: 0.98em;
    border-top: 1px solid #eee;
    /* background: #f5f5f5; */
    min-height: 40px;
    transition: background 0.2s;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

#sidebar-user-account:hover {
    background: #e0e0e0;
}

/* Sidebar Logout Button */
#sidebar-logout-btn {
    background: #f5f5f5;
    padding: 12px 24px 18px 24px;
    color: #444;
    border: none;
    border-top: 1px solid #eee;
    margin-bottom: 8px;
    display: block;
    transition: background 0.2s, border 0.2s;
    font-size: 1em;
    cursor: pointer;
    z-index: 1000;
}

#sidebar-logout-btn:hover {
    background: #ffffff;
    transform: scale(1.01);
    box-shadow: 0 2px 12px 0 rgba(210, 210, 210, 0.533);
}

/* Responsive Design - Mobile First Approach */
/* Mobile Styles (default) */
@media screen and (max-width: 768px) {
    /* Hide sidebar by default on mobile */
    #sidebar-content-wrapper {
        position: fixed;
        top: 0;
        left: -300px;
        /* Hidden off-screen */
        background: #fff;
        /* width: 280px; */
        height: 100%;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.03);
    }

    /* Show sidebar when active */
    #sidebar-content-wrapper.sidebar-open {
        left: 0;
    }

    /* Overlay for mobile sidebar */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        /* for mobile address bar issue */
        height: 100%;
        background: rgba(255, 255, 255, 0.5);
        backdrop-filter: blur(1px);
        -webkit-backdrop-filter: blur(1px);
        z-index: 999;
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* Mobile menu button */
    .mobile-menu-btn {
        display: block;
        position: fixed;
        top: 0px;
        left: 0px;
        z-index: 1;
        background: #fff;
        /* border: 1px solid #eee; */
        border: none;
        padding: 20px;
        cursor: pointer;
        /* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); */
        /* Gradually invisible edges using a mask gradient (horizontal and vertical) */
        /* -webkit-mask-image:
            linear-gradient(to right, transparent 0%, #fff 20%, #fff 80%, transparent 100%),
            linear-gradient(to bottom, transparent 0%, #fff 20%, #fff 80%, transparent 100%);
        mask-image:
            linear-gradient(to right, transparent 0%, #fff 20%, #fff 80%, transparent 100%),
            linear-gradient(to bottom, transparent 0%, #fff 20%, #fff 80%, transparent 100%); */
    }

    /* Adjust chat area for mobile */
    #chat {
        box-sizing: border-box;
        width: 100%;
        max-width: 100%;
        padding: 60px 16px 16px 16px;
        /* Extra top padding for menu button */
        margin: 0;
    }

    /* Adjust form for mobile */
    #form {
        box-sizing: border-box;
        width: 100%;
        max-width: 100%;
        padding: 0px 16px;
        margin: 0;
        gap: 0;
    }

    #disclaimer {
        font-size: 0.8em;
        margin: 12px 0;
    }

    /* Smaller bubbles on mobile */
    .bubble {
        padding: 10px 14px;
        font-size: 0.95rem;
        line-height: 1.8;
    }

    .llm.bubble {
        padding-left: 0;
        padding-right: 0;
    }

    /* Adjust input and button sizes */
    #input {
        font-size: 16px;
        /* Prevent zoom on iOS */
        padding: 12px 14px;
        /* border: 1px solid #000000; */
    }

    #send {
        width: 44px;
        height: 44px;
        flex-shrink: 0;
    }

    #sidebar-logout-btn {
        background: #ffffff;
    }

    /* Login container responsive */
    .login-container {
        background: #fff;
        width: 100%;
        min-width: unset;
        max-width: 400px;
        margin: 0 auto;
        border-right: none;
        height: 100%;
        justify-content: center;
    }

    #google-login {
        background: #ffffff;
    }

    #login-btn {
        padding: 10px 14px;
        /* border-radius: 12px; */
        /* border: 1px solid #ddd; */
        border: none;
        outline: none;
        background: #fff;
        font-size: 1.4em;
    }
}

/* Tablet Styles */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    /* almost copy and paste from monile */
    #sidebar-content-wrapper {
        position: fixed;
        top: 0;
        left: -600px;
        /* Hidden off-screen */
        background: #fff;
        width: 450px;
        height: 100%;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.03);
    }

    /* Show sidebar when active */
    #sidebar-content-wrapper.sidebar-open {
        left: 0;
    }

    /* Overlay for mobile sidebar */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100%;
        background: rgba(255, 255, 255, 0.5);
        backdrop-filter: blur(1px);
        -webkit-backdrop-filter: blur(1px);
        z-index: 999;
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* Mobile menu button */
    .mobile-menu-btn {
        display: block;
        position: fixed;
        top: 0px;
        left: 0px;
        z-index: 1;
        background: #fff;
        /* border: 1px solid #eee; */
        border: none;
        padding: 20px;
        cursor: pointer;
    }

    /* Adjust chat area for mobile */
    #chat {
        box-sizing: border-box;
        width: 100%;
        max-width: 100%;
        padding: 60px 32px 16px 32px;
        /* Extra top padding for menu button */
        margin: 0;
    }

    /* Adjust form for mobile */
    #form {
        box-sizing: border-box;
        width: 100%;
        max-width: 100%;
        padding: 0px 32px;
        margin: 0;
        gap: 0;
    }

    #disclaimer {
        font-size: 1em;
        margin: 24px 0;
    }

    /* Smaller bubbles on mobile */
    .bubble {
        padding: 10px 14px;
        font-size: 1.3rem;
        line-height: 1.8;
    }

    .llm.bubble {
        padding-left: 0;
        padding-right: 0;
    }

    /* Adjust input and button sizes */
    #input {
        font-size: 1.2rem;
        /* Prevent zoom on iOS */
        padding: 12px 14px;
        /* border: 1px solid #000000; */
    }

    #send {
        width: 44px;
        height: 44px;
        flex-shrink: 0;
    }

    .sidebar-new-chat {
        font-size: 1.5em;
    }

    .sidebar-chats-header {
        font-size: 1.35em;
    }

    .sidebar-chat-link {
        font-size: 1.4em;
    }

    #sidebar-user-account {
        padding: 24px;
        font-size: 1.5em;
    }

    #sidebar-logout-btn {
        background: #ffffff;
        padding: 24px;
        font-size: 1.5em;
    }

    /* Login container responsive */
    .login-container {
        background: #fff;
        width: 100%;
        min-width: unset;
        max-width: 400px;
        margin: 0 auto;
        border-right: none;
        height: 100%;
        justify-content: center;
    }

    #google-login {
        background: #ffffff;
    }

    #login-btn {
        padding: 10px 14px;
        /* border-radius: 12px; */
        /* border: 1px solid #ddd; */
        border: none;
        outline: none;
        background: #fff;
        font-size: 1.6em;
    }
}

/* Desktop Styles */
@media screen and (min-width: 1025px) {
    .mobile-menu-btn {
        display: none;
    }

    #sidebar-content-wrapper {
        width: 300px;
        position: relative;
    }

    #chat {
        width: 50vw;
        max-width: 800px;
    }

    #form {
        width: 50vw;
        max-width: 800px;
    }
}

/* Large Desktop */
@media screen and (min-width: 1440px) {
    .mobile-menu-btn {
        display: none;
    }

    #chat {
        width: 45vw;
        max-width: 900px;
    }

    #form {
        width: 45vw;
        max-width: 900px;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .bubble {
        animation: none;
    }

    #sidebar-content-wrapper {
        transition: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .bubble {
        border: 2px solid;
    }

    #input {
        border: 2px solid;
    }
}
