/* Responsive styles for mobile */
/* Frontend/css/mobile-chat.css */

/* Force mobile layout when JS detects mobile device (even if media queries fail) */
body.mobile-standalone {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    --mobile-keyboard-offset: 0px;
}

body.mobile-standalone .app-container {
    height: 100%;
    position: relative;
    overflow: hidden !important;
}

body.mobile-standalone .snowflake-area {
    z-index: 1;
}

body.mobile-standalone .chat-area {
    overflow-y: hidden !important;
    position: fixed !important;
    z-index: 2;
    background-color: transparent !important;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    flex-direction: column;
    display: flex;
    padding-bottom: 0;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
}

body.mobile-standalone .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    width: 0;
    z-index: 3000;
    transition: width 0.3s ease;
    overflow: hidden;
    padding-top: env(safe-area-inset-top);
}

body.mobile-standalone .sidebar.collapsed {
    width: 0;
}

body.mobile-standalone .sidebar.expanded .workflow-title {
    display: flex !important;
}

body.mobile-standalone .sidebar.expanded {
    width: 90% !important;
}

body.mobile-standalone .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    transition: opacity 0.3s ease;
}

body.mobile-standalone .sidebar-overlay.active {
    display: block;
}

body.mobile-standalone .current-workflow {
    flex: 1;
    text-align: center;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 10px;
}

body.mobile-standalone .chat-header .search-container {
    display: none;
}

body.mobile-standalone .header-actions {
    display: none;
}

body.mobile-standalone .mobile-header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: 10px;
}

body.mobile-standalone .mobile-sidebar-toggle,
body.mobile-standalone .mobile-search-toggle,
body.mobile-standalone .mobile-theme-toggle,
body.mobile-standalone .mobile-new-chat,
body.mobile-standalone .mobile-menu-toggle {
    background: none;
    border: none;
    color: var(--icon-color);
    font-size: 18px;
    padding: 5px;
    cursor: pointer;
}

body.mobile-standalone .mobile-search-bar {
    display: none;
    position: fixed;
    top: calc(env(safe-area-inset-top) + 50px);
    left: 0;
    right: 0;
    background: var(--header-bg);
    z-index: 1001;
    padding: 10px 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transform: translateZ(0);
}

body.mobile-standalone .mobile-search-bar.active {
    display: block !important;
}

body.mobile-standalone .mobile-search-bar.active ~ .messages-wrapper {
    margin-top: 50px;
}

body.mobile-standalone .file-upload-button {
    display: none;
}

body.mobile-standalone .messages-container {
    overflow-y: visible !important;
    overflow-x: visible !important;
    padding: 10px 5px 0;
    max-width: 97%;
    gap: 5px;
    padding-bottom: calc(10px + var(--send-anchor-extra-space, 0px)) !important;
    margin-bottom: 0;
    box-sizing: border-box;
    min-height: auto;
    height: auto;
}

body.mobile-standalone .chat-area .chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0px 20px 10px;
    padding-top: calc(env(safe-area-inset-top) + 12px);
    transition: transform 0.8s ease-in-out;
    height: 50px;
    position: relative !important;
    z-index: 1000;
}

body.mobile-standalone.keyboard-open .chat-header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
}

body.mobile-standalone.keyboard-open .messages-wrapper {
    padding-top: 80px;
}

body.mobile-standalone .input-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    z-index: 1001;
    padding: 5px;
    padding-bottom: max(5px, env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
    transform: translateY(calc(-1 * var(--mobile-keyboard-offset, 0px)));
    transition: transform 0.2s ease-out;
    /* box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08); */
    box-shadow: none;
    min-height: 20px;
    display: flex !important;
    visibility: visible !important;
    background: var(--input-field-bg);
    --stt-mic-color: var(--stt-regular-mic);
    --stt-mic-hover-color: var(--stt-regular-mic-hover);
    --stt-mic-hover-bg: var(--stt-regular-mic-hover-bg);
    --stt-stop-color: var(--stt-regular-stop);
    --stt-spinner-color: var(--stt-regular-spinner);
    --stt-visualizer-color: var(--stt-regular-visualizer);
}

body.mobile-standalone.keyboard-open .input-container {
    bottom: 0;
    padding-bottom: 5px;
}

body.mobile-standalone .input-container:focus-within,
body.mobile-standalone .input-container.has-text {
    --stt-mic-color: var(--stt-regular-mic-focus);
    --stt-mic-hover-color: var(--stt-regular-mic-hover-focus);
    --stt-mic-hover-bg: var(--stt-regular-mic-hover-bg-focus);
    --stt-spinner-color: var(--stt-regular-spinner-focus);
    --stt-visualizer-color: var(--stt-regular-visualizer-focus);
}

body.mobile-standalone.fresh-chat-mode #inputContainer {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
}

body.mobile-standalone .fresh-chat-wrapper {
    max-width: 640px;
    padding: 0 16px 24px;
}

body.mobile-standalone .fresh-chat-input-shell {
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.25);
}

body.mobile-standalone .messages-wrapper {
    flex: 1;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    position: relative;
    z-index: 950;
    box-sizing: border-box;
    padding-bottom: calc(20px + var(--mobile-keyboard-offset, 0px));
    transition: margin-top 0.3s ease-in-out;
    margin-top: -50px;
}

body.mobile-standalone.assistant-streaming .messages-wrapper {
    padding-bottom: calc(82px + var(--mobile-keyboard-offset, 0px));
}

body.mobile-standalone .scroll-bottom-arrow {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(88px + env(safe-area-inset-bottom, 0px) + var(--mobile-keyboard-offset, 0px));
    z-index: 1002;
    opacity: 0.6;
}

body.mobile-standalone.assistant-streaming .scroll-bottom-arrow {
    display: none !important;
}

body.mobile-standalone .scroll-bottom-arrow:hover {
    transform: translateX(-50%) scale(1.1);
}

body.mobile-standalone .chat-header.scroll-hidden {
    transform: translateY(-100%);
    overflow: hidden;
}

body.mobile-standalone .chat-header.scroll-hidden ~ .messages-wrapper {
    margin-top: -50px;
}

body.mobile-standalone .messages-container.input-visible {
    padding-bottom: calc(10px + var(--send-anchor-extra-space, 0px));
}

body.mobile-standalone .messages-container.input-hidden {
    padding-bottom: calc(20px + var(--send-anchor-extra-space, 0px));
}

body.mobile-standalone #userInput {
    flex: 1;
    width: 100%;
    border: none;
    min-height: 44px;
    max-height: 150px;
    height: auto;
    line-height: 1.3;
    padding: 10px 50px 10px 16px;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    background: transparent;
    font-size: 0.92rem;
    color: var(--text-color);
}

body.mobile-standalone #userInput::placeholder {
    color: rgba(64, 80, 98, 0.55);
}

body.dark-theme.mobile-standalone #userInput::placeholder {
    color: rgba(240, 240, 240, 0.55);
}

body.mobile-standalone .input-container:focus-within #userInput,
body.mobile-standalone .input-container.has-text #userInput {
    background: #ffffff;
    color: #2b2b2b;
    box-shadow: 0 0 5px rgba(97, 98, 98, 0.5);
}

body.mobile-standalone .input-container:focus-within #userInput::placeholder,
body.mobile-standalone .input-container.has-text #userInput::placeholder {
    color: #6b7280;
}

body.mobile-standalone.keyboard-open .welcome-container {
    position: relative;
    margin-top: 20px;
    margin-bottom: 20px;
    min-height: auto;
}

body.mobile-standalone .mobile-menu {
    position: fixed;
    top: 60px;
    right: 10px;
    background-color: var(--sidebar-bg);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 25;
    display: none;
    min-width: 150px;
    border: 1px solid var(--border-color);
}

body.mobile-standalone .mobile-menu-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    cursor: pointer;
    font-size: 14px;
}

body.mobile-standalone .mobile-menu-item:hover {
    background-color: rgba(0,0,0,0.05);
}

body.mobile-standalone .mobile-menu-item i {
    font-size: 16px;
}

body.mobile-standalone .mobile-menu-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-color);
    font-weight: 500;
}

body.mobile-standalone .mobile-switch {
    width: 42px;
    height: 22px;
    border-radius: 999px;
    background: rgba(64, 80, 98, 0.3);
    position: relative;
    transition: background 0.2s ease;
}

body.mobile-standalone .mobile-switch-handle {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: left 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

body.mobile-standalone .mobile-switch.enabled {
    background: #4f8ad9;
}

body.mobile-standalone .mobile-switch.enabled .mobile-switch-handle {
    left: 22px;
    box-shadow: 0 2px 6px rgba(79,138,217,0.4);
}

body.mobile-standalone .mobile-lang-options {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--secondary-text);
}

body.mobile-standalone .mobile-lang-option {
    cursor: pointer;
    font-weight: 500;
    opacity: 0.6;
}

body.mobile-standalone .mobile-lang-option.active {
    opacity: 1;
    color: var(--text-color);
    border-bottom: 2px solid var(--text-color);
    background: #4f8ad9;
    padding: 5px 10px;
    border-radius: 8px;
    color: white;
}

body.mobile-standalone .mobile-lang-divider {
    opacity: 0.4;
}

body.mobile-standalone .mobile-menu-separator {
    height: 1px;
    background: rgba(0,0,0,0.1);
    margin: 4px 0;
}

body.mobile-standalone .mobile-menu.active {
    display: block;
}

body.mobile-standalone .input-row {
    width: 100%;
    position: relative;
    /* background: #fff; */
    /* border-radius: 24px; */
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
    box-shadow: none;
    padding: 0;
    display: flex !important;
    align-items: center;
    min-height: 52px;
    /* border: 1px solid rgba(0, 0, 0, 0.05); */
    overflow: hidden;
}

body.mobile-standalone .input-row:before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 20px;
    pointer-events: none;
    /* box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6); */
}

body.mobile-standalone #userInput::placeholder {
    color: rgba(64, 80, 98, 0.55);
}

body.mobile-standalone .file-upload-button {
    display: none !important;
}

body.mobile-standalone .input-container .send-button {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(64, 80, 98, 0.08);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(64, 80, 98, 0.75);
    border: none;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

body.mobile-standalone.pull-refreshing .input-container {
    opacity: 0;
    pointer-events: none;
}

body.mobile-standalone.pull-refreshing .scroll-bottom-arrow {
    display: none !important;
}

body.mobile-standalone .input-container .stt-visualizer {
    position: absolute;
    right: 50px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    align-items: center;
    gap: 4px;
    height: 18px;
}

body.mobile-standalone .input-container .stt-visualizer span {
    width: 3px;
    height: 10px;
    background: var(--stt-visualizer-color);
    border-radius: 2px;
    animation: stt-bar 0.9s ease-in-out infinite;
}

body.mobile-standalone .input-container .stt-visualizer span:nth-child(2) {
    animation-delay: 0.2s;
}

body.mobile-standalone .input-container .stt-visualizer span:nth-child(3) {
    animation-delay: 0.4s;
}

body.mobile-standalone .input-container .mic-button {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--stt-mic-color);
    border: none;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    z-index: 10;
}

body.mobile-standalone .input-container .send-button i {
    font-size: 18px;
    margin-left: 1px;
}

body.mobile-standalone .input-container .mic-button i {
    font-size: 18px;
    margin-left: 1px;
}

.chat-area #inputContainer .send-button.has-content,
body.mobile-standalone .send-button.has-content {
    /* background: #405062; */
    background: transparent;
    /* color: var(--send-btn-bg, #405062); */
    color: #405062;
    /* box-shadow: 0 4px 12px rgba(64, 80, 98, 0.35); */
    box-shadow: none;
    z-index: 10;
}

body.mobile-standalone .send-button.has-content i {
    font-size: 18px;
}

body.mobile-standalone .mic-button.has-content {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

body.mobile-standalone .mic-button.is-recording {
    color: var(--stt-stop-color);
}

body.mobile-standalone .mic-button.is-processing,
body.mobile-standalone .mic-button.is-preparing {
    pointer-events: none;
    opacity: 1;
    color: var(--stt-spinner-color);
}

body.mobile-standalone .input-container.is-recording .stt-visualizer {
    display: flex;
}


@media (max-width: 768px) {
    body {
        overflow: hidden;
    }

    .app-container {
        overflow: hidden !important;
    }

    .welcome-container .welcome-image {
        width: 50px;
        height: 50px;
    }

    .snowflake-area {
        z-index: 1;
    }

    .chat-area .chat-header {
        z-index: 1200;
    }

    .messages-wrapper {
        position: relative;
        /* z-index: 1000; */
    }

    .input-container {
        position: relative;
        z-index: 1200;
    }

    .input-container .additional-query-suggestions-wrapper {
        width: 89%;
        bottom: calc(50% + 30px);
        border-radius: 12px;
    }

    /* Prevent chat-area scroll */
    .chat-area { 
        overflow-y: hidden !important;
        position: fixed;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        flex-direction: column;
        display: flex;
        padding-bottom: 80px;
    }

    /* Hide sidebar by default on mobile */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        height: 100dvh;
        width: 0;
        z-index: 3000;
        transition: width 0.3s ease;
        overflow: hidden;
        padding-top: env(safe-area-inset-top);
    }

    .sidebar.collapsed { 
        width: 0; 
    }

    .sidebar.expanded .workflow-title {
        display: flex !important;
    }

    .sidebar.expanded {
        width: 90% !important;
    }

    /* Sidebar overlay for mobile click-outside-to-close */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        transition: opacity 0.3s ease;
    }

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

    .current-workflow {
        flex: 1;
        text-align: center;
        font-size: 1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        padding: 0 10px;
    }

    .workflows-list {
        max-height: 40%;
        box-shadow: 0 1px 4px rgb(0 0 0 / 14%);
    }

    /* Hide desktop search bar on mobile */
    .chat-header .search-container {
        display: none;
    }
    
    /* Hide normal header elements and show mobile header */
    .header-actions {
        display: none;
    }
    
    .mobile-header-actions {
        display: flex;
        align-items: center;
        gap: 15px;
        margin-left: 10px;
    }

    .mobile-right-icons {
        display: flex;
        align-items: center;
        gap: 15px;
    }

    .mobile-sidebar-toggle {
        background: none;
        border: none;
        color: var(--icon-color);
        font-size: 18px;
        padding: 5px;
        cursor: pointer;
        margin-right: 10px;
    }

    .mobile-search-toggle,
    .mobile-theme-toggle,
    .mobile-new-chat,
    .mobile-menu-toggle {
        background: none;
        border: none;
        color: var(--icon-color);
        font-size: 18px;
        padding: 5px;
        cursor: pointer;
        right: 10px;
    }
    
    .mobile-search-bar {
        display: none;
        position: fixed;
        /* top: 50px; */
        top: calc(env(safe-area-inset-top) + 50px);
        left: 0;
        right: 0;
        background: var(--header-bg);
        z-index: 1001;
        padding: 10px 15px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
        will-change: transform;
    }

    body.keyboard-open .mobile-search-bar.active {
        top: env(safe-area-inset-top, 0px);
        z-index: 1003; /* Above keyboard */
        top: 50px;
    }

    .mobile-search-bar.active {
        display: block;
        transform: translateY(0);
        opacity: 1;
    }

    .mobile-search-bar.active ~ .messages-wrapper {
        margin-top: 50px; /* Same as search bar height */
    }

    .mobile-search-bar.active .search-container {
        display: block;
    }

    .mobile-search-bar .search-nav-btn:hover:not(:disabled) {
        background-color: rgba(0, 0, 0, 0.1);
    }

    /* Hide file upload on mobile */
    .file-upload-button {
        display: none;
    }
    
    /* Make search more compact on mobile */
    .search-container {
        display: flex;
        align-items: center;
        position: relative;
        width: 100% !important;
        min-width: 200px;
    }
    
    .search-container.expanded {
        width: 70%;
    }
    
    /* Styling for three-dot menu */
    .mobile-menu-toggle {
        display: block;
        background: none;
        border: none;
        color: var(--icon-color);
        font-size: 18px;
        padding: 5px;
    }
    
    .mobile-menu {
        position: fixed;
        top: 60px;
        right: 10px;
        background-color: var(--sidebar-bg);
        border-radius: 8px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.2);
        z-index: 25;
        display: none;
        min-width: 150px;
        border: 1px solid var(--border-color);
    }

    .message-container-bot .bot-message .ui-resource-wrapper {
        min-width: 100px !important;
    }
    
    .mobile-menu.active {
        display: block;
    }
    
    .mobile-menu-item {
        padding: 10px 15px;
        display: flex;
        align-items: center;
        gap: 10px;
        cursor: pointer;
    }
    
    .mobile-menu-item:hover {
        background-color: rgba(0,0,0,0.05);
    }

    .messages-container {
        overflow-y: visible !important; /* Single-scroll model: wrapper scrolls */
        overflow-x: visible !important;
        padding: 10px 5px 0; 
        max-width: 97%;
        gap: 5px;
        padding-bottom: 10px !important;
        margin-bottom: 0;
        box-sizing: border-box;
        min-height: auto; /* Remove min-height that might cause issues */
        height: auto;
    }

    /* .messages-container.input-visible,
    .messages-container.input-hidden {
        padding-bottom: 0 !important;
    } */

    /* Adjust chat header padding */
    .chat-area .chat-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0px 20px 10px;
        padding-top: calc(env(safe-area-inset-top) + 12px);
        transition: transform 0.8s ease-in-out;
        will-change: transform;
        height: 50px;
        position: relative !important;
        z-index: 1000;
    }

    /* Only apply fixed positioning when keyboard is open */
    body.keyboard-open .chat-header {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
    }

    .chat-header.scroll-hidden {
        transform: translateY(-100%);
        overflow: hidden;
    }

    #chatMessages .welcome-container {
        margin-top: 70px !important;
    }
    
    /* Reduce padding for input container */
    .input-container {
        position: fixed;
        bottom: env(safe-area-inset-bottom, 0);
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        z-index: 100;
        padding: 10px 5px;
        padding-bottom: max(var(--input-padding, 12px), env(safe-area-inset-bottom));
        box-sizing: border-box;
        transition: transform 0.3s ease-in-out;
        will-change: transform;
        background-color: var(--header-bg);
        box-shadow: 0 0px 5px rgba(0, 0, 0, 0.2);
        min-height: calc(20px + env(safe-area-inset-bottom, 0));
        /* Ensure container is visible */
        display: flex !important;
        visibility: visible !important;
    }
    
    /* Additional fix for iOS viewport issues */
    @supports (-webkit-touch-callout: none) {
        .input-container {
            bottom: max(env(safe-area-inset-bottom, 0), 0px);
            padding-bottom: max(15px, env(safe-area-inset-bottom, 0));
            bottom: 0;
        }
    }

    textarea {
        -webkit-overflow-scrolling: touch;
        /* Prevent iOS keyboard accessory bar */
        -webkit-user-select: text;
        user-select: text;
    }

    /* Specifically target iOS */
    @supports (-webkit-touch-callout: none) {
        textarea {
            font-size: 16px; /* Prevent zoom on focus */
        }
    }

    @supports (-webkit-touch-callout: none) {
        /* Target only the navigation bar */
        div[role="toolbar"][aria-label="Previous, Next, Done"] {
            display: none !important;
        }
        
        /* Keep text suggestions visible */
        div[role="presentation"][aria-label="Predictive input"] {
            display: flex !important;
        }
        
        /* Ensure input still works normally */
        textarea, input {
            -webkit-user-select: text;
            user-select: text;
            font-size: 16px;
        }
    }

    .messages-wrapper {
        flex: 1;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
        position: relative;
        box-sizing: border-box;
        padding-bottom: 40px;
        transition: margin-top 0.3s ease-in-out;
        margin-top: -50px; /* Default state */
    }

    /* When header is hidden, smoothly reduce top margin */
    .chat-header.scroll-hidden ~ .messages-wrapper {
        margin-top: -50px; 
    }

    /* Dynamic padding when input container is visible */
    .messages-container.input-visible {
        padding-bottom: 10px;
    }
    
    /* Reduced padding when input container is hidden */
    .messages-container.input-hidden {
        padding-bottom: 20px;
    }    

    /* Only add top padding when keyboard is open and header is fixed */
    body.keyboard-open .messages-wrapper {
        padding-top: 80px;
    }

    /* Only apply these styles on mobile when keyboard is open */
    body.keyboard-open .welcome-container {
        position: relative;
        margin-top: 20px;
        margin-bottom: 20px;
        min-height: auto;
    }

    /* Ensure welcome message is visible above keyboard */
    /* body.keyboard-open .messages-container {
        max-height: calc(100vh - 250px);
        overflow-y: auto;
    } */

    #userInput {
        /* border-radius: 30px; */
        min-height: 40px; /* Remove !important */
        max-height: 120px; /* Remove !important */
        height: 40px; /* Set initial height without !important */
        line-height: 1.2;
        padding: 8px 12px;
        padding-right: 48px;
        /* Ensure textarea stays visible */
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative;
        z-index: 1;
        scrollbar-width: thin;
        scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
        border: none;
        box-shadow: none;
        background: transparent;
    }

    .input-row {
        gap: 0;
        width: 100%;
        padding-left: 10px;
        display: flex !important;
        align-items: flex-end; /* Align to bottom when textarea grows */
    }

    .input-container .send-button {
        height: 40px;
        width: 40px;
        background-color: transparent;
        color: color-mix(in srgb, var(--accent-color) 60%, white);
        border-radius: 0;
    }

    .input-container .send-button i {
        font-size: 18px;
    }

    .input-container .mic-button {
        height: 40px;
        width: 40px;
        background-color: transparent;
        color: color-mix(in srgb, var(--accent-color) 60%, white);
        border-radius: 0;
    }

    .input-container .mic-button i {
        font-size: 18px;
    }

    .send-button.has-content {
        box-shadow: none;
        /* box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3); */
        background-color: transparent;
        cursor: pointer;
        color: var(--send-button-bg);
        /* border-radius: 20px; */
    }

    .send-button.has-content i {
        font-size: 20px;
    }

    .mic-button.has-content {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }

    .mic-button.is-processing,
    .mic-button.is-preparing {
        pointer-events: none;
        opacity: 1;
    }

    .input-container.is-recording .stt-visualizer {
        display: flex;
    }


    .file-attachments-container {
        display: none !important;
    }
    
    /* Reduce padding for message bubbles */
    .user-message, .bot-message,
    .message-container .user-message {
        padding: 8px 12px;  /* Slightly reduced padding */
        margin-bottom: 10px;
    }

    .message-container, .message-container-bot {
        gap: 0;
        padding: 0;
        margin: 0;
    }

    .message-container-bot .bot-message {
        max-width: 90%;
    }

    .tooltip-container .bot-icon {
        width: 20px;
        height: 20px;
    }

    .message-meta {
        display: none !important;
    }

    .scroll-bottom-arrow {
        position: fixed;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        bottom: calc(88px + env(safe-area-inset-bottom, 0px) + var(--mobile-keyboard-offset, 0px));
    }

    .message-entering {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .message-entered {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    /* Different animations for user vs bot messages */
    .user-container.message-entering {
        transform: translateX(30px) translateY(10px) scale(0.95);
    }

    .bot-container.message-entering {
        transform: translateX(-30px) translateY(10px) scale(0.95);
    }

    /* Timestamp styles for swipe feature - mobile only */
    .individual-timestamp {
        position: absolute;
        width: 50px;
        max-height: 40px;
        /* background: var(--chat-bg); */
        background: transparent;
        color: var(--text-color);
        font-size: 11px;
        text-align: center;
        z-index: 1000;
        opacity: 0;
        transition: opacity 0.3s ease-out;
        padding: 2px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        pointer-events: none;
    }
    
    .individual-timestamp .timestamp-time {
        font-weight: 500;
        line-height: 1.1;
    }
    
    .individual-timestamp .timestamp-date {
        font-size: 11px;
        opacity: 0.8;
        line-height: 1.1;
    }

    .sidebar-header {
        background-color: var(--header-bg);
    }

    .sidebar.expanded ~ .chat-area .chat-header {
        display: none;
    }
    
    .sidebar.expanded ~ .chat-area .scroll-bottom-arrow {
        display: none !important;
    }
    
    .pull-refresh-content {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        padding: 8px 16px;
    }
    
    .pull-refresh-arrow {
        font-size: 18px;
        transition: transform 0.3s ease;
        color: inherit;
    }
    
    .pull-refresh-text {
        font-size: 14px;
        font-weight: 800;
        text-align: center;
        line-height: 1.4;
        max-width: 200px;
    }
    
    .pull-refresh-indicator.ready-to-refresh .pull-refresh-arrow {
        color: white;
    }

    .ios-spinner {
        width: 24px;
        height: 24px;
        position: relative;
        animation: ios-spinner-rotate 2s linear infinite;
    }
    
    .ios-spinner-blade {
        position: absolute;
        width: 2px;
        height: 6px;
        background: currentColor;
        border-radius: 1px;
        opacity: 0.3;
        left: 50%;
        top: 0;
        transform-origin: center 12px;
    }
    
    .ios-spinner-blade:nth-child(1) { transform: translateX(-50%) rotate(0deg); animation-delay: 0s; }
    .ios-spinner-blade:nth-child(2) { transform: translateX(-50%) rotate(30deg); animation-delay: -0.083s; }
    .ios-spinner-blade:nth-child(3) { transform: translateX(-50%) rotate(60deg); animation-delay: -0.166s; }
    .ios-spinner-blade:nth-child(4) { transform: translateX(-50%) rotate(90deg); animation-delay: -0.25s; }
    .ios-spinner-blade:nth-child(5) { transform: translateX(-50%) rotate(120deg); animation-delay: -0.333s; }
    .ios-spinner-blade:nth-child(6) { transform: translateX(-50%) rotate(150deg); animation-delay: -0.416s; }
    .ios-spinner-blade:nth-child(7) { transform: translateX(-50%) rotate(180deg); animation-delay: -0.5s; }
    .ios-spinner-blade:nth-child(8) { transform: translateX(-50%) rotate(210deg); animation-delay: -0.583s; }
    .ios-spinner-blade:nth-child(9) { transform: translateX(-50%) rotate(240deg); animation-delay: -0.666s; }
    .ios-spinner-blade:nth-child(10) { transform: translateX(-50%) rotate(270deg); animation-delay: -0.75s; }
    .ios-spinner-blade:nth-child(11) { transform: translateX(-50%) rotate(300deg); animation-delay: -0.833s; }
    .ios-spinner-blade:nth-child(12) { transform: translateX(-50%) rotate(330deg); animation-delay: -0.916s; }
    
    @keyframes ios-spinner-rotate {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }
    
    .ios-spinner-blade {
        animation: ios-spinner-fade 2s linear infinite;
    }
    
    @keyframes ios-spinner-fade {
        0% { opacity: 1; }
        100% { opacity: 0.3; }
    }
}
