
/* Responsive Styling */

.sidebar-overlay {
    display: none;
}

/* Image Zoom Modal Responsiveness */
.image-zoom-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.image-zoom-modal.active {
    display: flex;
}

.image-zoom-container {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-zoom-img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
}

.image-zoom-close {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 40px;
    color: white;
    cursor: pointer;
    z-index: 10001;
    background: none;
    border: none;
    padding: 0;
    line-height: 1;
}

.image-zoom-close:hover {
    color: #ccc;
}

@media (max-width: 768px) {
    /* Hide sidebar by default on mobile by moving it off-screen */
    .chat-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100dvh; /* Use dynamic viewport height */
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        z-index: 1050;
        margin: 0;
        border-radius: 0;
        border-right: 1px solid #222;
        background-color: #050505; /* Solid background to block content behind */
    }

    /* Show sidebar when active class is present */
    .chat-sidebar.active {
        transform: translateX(0);
    }

    /* Overlay when sidebar is open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1040;
    }

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

    /* Adjust chat main area */
    .chat-main {
        width: 100%;
        margin: 0;
        height: 100%; /* Force height to match parent */
        overflow: hidden; /* Stop checking for overflow, clip it */
        position: relative;
        padding: 0 !important; /* Zero padding for maximum width */
    }

    /* Landing scrolls internally so sidebar toggle + status button above stay pinned */
    .chat-landing {
        justify-content: flex-start !important;
        padding-top: 10vh;
        padding-bottom: 80px;
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box;
    }

    /* Example prompts: fade + collapse when input is focused (no longer needed while typing) */
    #example-prompts {
        max-height: 300px;
        overflow: hidden;
        opacity: 1;
        transition: opacity 0.3s ease, max-height 0.4s ease;
    }

    .chat-landing:has(.chat-input:focus) #example-prompts {
        opacity: 0;
        max-height: 0;
    }

    /* Ensure card scrolls properly instead of expanding */
    .card {
        height: 100%;
        min-height: 0; /* Critical for nested flex scrolling */
        padding: 0 !important; /* Remove card padding to gain width */
    }

    /* Remove card-body padding on mobile */
    .card-body {
        padding: 0 !important;
    }

    .bubble {
        max-width: 96%; /* Maximize bubble width */
    }

    /* Reduce horizontal margins for bubbles */
    .chat-message {
        width: 100%;
        padding-left: 2px; /* Tiny safety margin */
        padding-right: 2px;
    }

    .chat-landing .chat-input-form {
        width: 95% !important;
    }
    
    .chat-landing h1 {
        font-size: 2rem;
        margin-bottom: 1.5rem;
    }

    /* Scale down landing page input & button on mobile (override ID selector) */
    #input-div .chat-input {
        min-height: 50px;
        height: 50px;
        font-size: 1rem !important;
        padding: 10px 15px !important;
    }

    #input-div .btn {
        height: 50px;
        min-height: 50px;
        padding: 0 15px !important;
        font-size: 1.2rem; /* Keep icon visible */
    }
    
    /* Scale down example buttons */
    .example-prompts .example-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    /* Adjust input form width limiter on mobile */
    .chat-input-width-limiter {
        max-width: 100% !important; 
        width: 100% !important;
    }

    /* Mobile Table Styling */
    .chat-message table {
        font-size: 0.75rem !important;
        margin: 0.5rem 0 !important;
        min-width: 100% !important;
        display: table !important;
        border-collapse: separate !important;
        border-spacing: 0 !important;
        border-radius: 8px !important;
        overflow: hidden !important;
        width: 100% !important;
        border: 1px solid #007bff !important;
        box-shadow: 0 1px 4px rgba(0, 123, 255, 0.1) !important;
    }

    .chat-message thead {
        display: table-header-group !important;
    }

    .chat-message tbody {
        display: table-row-group !important;
    }

    .chat-message tr {
        display: table-row !important;
    }

    .chat-message th,
    .chat-message td {
        display: table-cell !important;
        padding: 4px 6px !important;
        font-size: 0.75rem !important;
        border: 1px solid #444 !important;
        vertical-align: top !important;
        text-align: left !important;
        word-break: normal !important;
        overflow-wrap: break-word !important;
        white-space: normal !important;
        min-width: 80px !important;
    }

    .chat-message th {
        background: linear-gradient(135deg, #1a5a96 0%, #0d3d6b 100%) !important;
        font-weight: 600 !important;
        color: #e0f1ff !important;
        border-bottom: 1px solid #007bff !important;
        font-size: 0.8rem !important;
        padding: 6px 6px !important;
    }

    .chat-message tbody tr:nth-child(even) {
        background-color: rgba(0, 123, 255, 0.03) !important;
    }

    .chat-message tbody tr:hover {
        background-color: rgba(0, 123, 255, 0.08) !important;
        transition: background-color 0.2s ease !important;
    }

    /* Enable horizontal scrolling for tables on mobile */
    .bot-bubble {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding-bottom: 0.5rem !important;
    }

    /* Mobile List Styling - Keep Normal */

    /* Ensure user bubble text is properly centered */
    .user-bubble {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        min-height: 2.5rem !important; /* ensure minimum height for centering */
    }

    .user-bubble p {
        margin: 0 !important;
        width: 100% !important;
    }

    /* Mobile Link Styling */
    .chat-message a {
        color: #4dabf7 !important; /* brighter blue for better visibility */
        text-decoration: none !important;
        border-bottom: 1px solid rgba(77, 171, 247, 0.3) !important;
        transition: all 0.2s ease !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
        font-size: 0.9rem !important;
    }

    .chat-message a:hover {
        color: #82cfff !important; /* lighter blue on hover */
        border-bottom-color: rgba(130, 207, 255, 0.6) !important;
        background-color: rgba(77, 171, 247, 0.1) !important;
        padding: 0 2px !important;
        border-radius: 2px !important;
    }

    .chat-message a:visited {
        color: #6c9bd1 !important; /* slightly different color for visited links */
        border-bottom-color: rgba(108, 155, 209, 0.3) !important;
    }

    /* Gradient scrim that fades out chat content before the floating input (active chats only) */
    .chat-main:has(#chat-window)::after {
        content: '';
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 260px; /* tall enough to cover input + gap + start fading early */
        background: linear-gradient(
            to bottom,
            transparent 0%,
            rgba(5, 5, 5, 0.6) 35%,
            rgba(5, 5, 5, 0.92) 60%,
            #050505 100%
        );
        pointer-events: none;
        z-index: 1029; /* just below the input bar */
    }

    /* Fix chat input to bottom of viewport on mobile (Only for active chat, not landing) */
    .chat-main > .chat-input-form {
        position: fixed !important;
        bottom: 80px !important; /* Offset to clear in-app navbar */
        left: 12px !important;
        right: 12px !important;
        width: auto !important;
        margin: 0 !important;
        padding: 10px 14px !important;
        background: rgba(18, 18, 18, 0.55) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        border: 1px solid rgba(255, 255, 255, 0.08) !important;
        border-radius: 20px !important;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45) !important;
        z-index: 1030;
    }

    /* Reduce bottom padding of chat window to match smaller input */
    #chat-window {
        padding-bottom: 170px !important; /* input height (~90px) + app navbar offset (80px) */
    }

    /* Push sidebar Neuer Chat button above in-app navbar */
    .chat-sidebar .mt-auto {
        padding-bottom: 80px !important;
    }
}

/* Compact landing top padding when keyboard is open (short viewport) */
@media (max-width: 768px) and (max-height: 500px) {
    .chat-landing {
        padding-top: 3vh;
    }
}

/* Ensure no conflict on desktop */
@media (min-width: 769px) {
    .chat-sidebar {
        transform: none !important; 
        display: flex !important;
        position: relative !important;
        height: 100% !important;
}
}
