:root {
  --input-height: 88px;
  --background: #1A1A1A;
  --surface: #232323;
  --surface-alt: #282828;
  --border: #3d3d3d; /* Lighter border for better visibility */
  --border-strong: #4a4a4a; /* Even stronger border for emphasis */
  --text-main: #E0E0E0;
  --text-subtle: #B0B0B0;
  --accent: #6f42c1; /* Deep purple accent */
  --user-bubble: #1e2a38; /* Deep blue */
  --bot-bubble: #232323;
  --button-bg: #6f42c1;
  --button-hover: #563d7c;
  --button-text: #E0E0E0;
  --input-bg: #1A1A1A; /* Darker to match background */
  --input-border: #4a4a4a; /* Stronger border */
  --quick-reply-bg: #1e2a38;
  --quick-reply-hover: #6f42c1;
  --quick-reply-text: #E0E0E0;
  --bs-body-bg: var(--surface) !important;
  --bg-primary: var(--surface)  !important;
}

body {
    background-color: none;
}


/* Chat container improvements */
.chat-container {
    position: relative;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 250px);
    min-height: 500px;
}

.chat-messages {
    background: var(--background);
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    padding-bottom: 1.5rem;
    scroll-behavior: smooth;
}

/* Message spacing and flow */
.message {
    margin-bottom: 1.25rem;
}

.message .d-flex {
    gap: 0.75rem;
}

/* Welcome box and chat bubbles */
.welcome-box {
    background: var(--bot-bubble);
    color: var(--text-main);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    max-width: 420px;
    padding: 1rem;
}

.welcome-img {
    width: 100%;
    max-width: 380px;
    border-radius: 12px;
    object-fit: cover;
    display: block;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    border: 2px solid var(--border);
}

.welcome-tip {
    background: var(--surface-alt);
    color: var(--text-subtle);
    border-radius: 8px;
    padding: 0.65em 0.9em;
    margin-top: 0.75em;
    border: 1px solid var(--border);
}

.bot-message .message-content {
    background: var(--bot-bubble);
    color: var(--text-main);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    max-width: 480px;
    padding: 0.85rem 1rem;
    border-radius: 16px;
}

.user-message .message-content {
    background: var(--surface);
    color: var(--text-main);
    border-radius: 16px;
   
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    max-width: 480px;
    padding: 0.85rem 1rem;
}

/* Avatar: perfectly round, centered, dark style */
.avatar {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px;
    min-height: 44px;
    max-width: 44px;
    max-height: 44px;
    border-radius: 50% !important;
    background: var(--accent) !important;
    color: #fff !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 1.5rem;
    box-shadow: 0 3px 10px rgba(111, 66, 193, 0.4);
    margin-top: 2px;
    border: 3px solid var(--border-strong);
}

/* Input area */
.input-container {
    background: var(--background) !important;
    padding: 1rem !important;
}

/* Card footer styling - keep it inside the card flow, not fixed */
.card-footer.bg-light {
  background: var(--background) !important;
  border-top: 1px solid var(--border) !important;
  padding: 1rem;
}

/* Desktop: Constrain input width to match chat content (best practice for chat UIs) */
@media (min-width: 768px) {
  .card-footer.bg-light .input-group {
    max-width: 800px;
    margin: 0 auto;
  }
}

#user-input {
    background: var(--input-bg) !important;
    color: var(--text-main) !important;
    border: 2px solid var(--input-border) !important;
    border-radius: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#user-input:focus {
    border-color: var(--accent) !important;
    background: var(--input-bg) !important;
    color: var(--text-main) !important;
    box-shadow: 0 0 0 0.2rem rgba(111, 66, 193, 0.25), 0 2px 12px rgba(0,0,0,0.4) !important;
    outline: none !important;
}

#user-input::placeholder {
    color: var(--text-subtle);
}

.chat-button {
    background: var(--button-bg) !important;
    background: var(--quick-reply-bg) !important;
    color: var(--button-text) !important;
    border: 2px solid var(--accent) !important;
    border-radius: 24px !important;
    font-weight: 600;
    transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
    box-shadow: 0 3px 10px rgba(111, 66, 193, 0.3);
}

.chat-button:hover, .chat-button:focus {
    background: var(--button-hover) !important;
    color: var(--button-text) !important;
    border-color: var(--button-hover) !important;
    box-shadow: 0 4px 14px rgba(111, 66, 193, 0.5);
    transform: translateY(-1px);
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
    width: 10px;
    background: var(--background);
}
.chat-messages::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 8px;
    border: 2px solid var(--background);
}
.chat-messages::-webkit-scrollbar-track {
    background: var(--surface);
    border-radius: 8px;
    margin: 4px;
}

/* Card styling overrides */
.card {
    background: var(--surface) !important;
}

.card-header {
    background: var(--surface-alt) !important;
}

/* Text color overrides */
.text-muted {
    color: var(--text-subtle) !important;
}

/* Carousel */
.property-carousel {
    max-width: 100%;
    margin: 1rem 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Message carousel container - ensure proper spacing */
.message-carousel {
    margin-bottom: 0.5rem;
}

.carousel-image {
    width: 100%;
    height: auto;
    max-height: 500px;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.carousel-image:hover {
    transform: scale(1.02);
}

/* Thumbnails */
.carousel-thumbnails {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
}

.carousel-thumbnails .thumbnail {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.3s, transform 0.3s;
    border: 2px solid transparent;
}

.carousel-thumbnails .thumbnail:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.carousel-thumbnails .thumbnail.active {
    opacity: 1;
    border-color: #0d6efd;
}

/* Lightbox */
#lightboxModal .modal-body img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
}

/* Responsive overrides: */
@media (min-width: 768px) {
    .chat-footer.card-footer.bg-light .input-group {
        max-width: 800px;
        margin: 0 auto;
    }
}
/* Mobile optimizations */
@media (max-width: 768px) {
    .carousel-image {
        max-height: 300px;
    }
    
    .carousel-thumbnails .thumbnail {
        width: 60px;
        height: 45px;
    }
    
    .carousel-caption {
        font-size: 0.85rem;
        padding: 0.5rem;
    }
}

/* Touch zoom support */
.carousel-image {
    touch-action: pinch-zoom;
}

/* Responsive tweaks (keep your existing media queries, but update colors if needed) */
@media (max-width: 576px) {
    .chat-messages {
        background: var(--background);
    }
    .avatar {
        width: 38px !important;
        height: 38px !important;
        font-size: 1.2rem;
    }
}

/* ...keep your existing responsive and safe-area rules... */
/* Touch-friendly optimizations */
@media (hover: none) and (pointer: coarse) {
    .cover-image:hover {
        transform: none;
    }
    .chat-button:hover {
        background-color: var(--button-hover);
        box-shadow: none;
    }
    .chat-button {
        -webkit-tap-highlight-color: rgba(111, 66, 193, 0.3);
    }
    #user-input {
        -webkit-tap-highlight-color: rgba(111, 66, 193, 0.1);
    }
}

/* Tablet devices (768px - 1024px) */
@media (max-width: 1024px) {
    .chat-container {
        height: calc(100vh - 220px);
    }
    
    .chat-messages {
        padding: 0.75rem;
    }
}

/* Mobile devices (481px - 767px) */
@media (max-width: 767px) {
    .chat-container {
        height: calc(100vh - 180px);
        min-height: 400px;
    }
    
    .chat-messages {
        padding: 0.75rem;
        padding-bottom: 1rem;
    }
    
    .user-message {
        width: 100%;
        max-width: 100%;
    }
    .bot-message {
        width: 100%;
        max-width: 100%;
    }
    .user-message .message-content {
        max-width: 85%;
        font-size: 0.9rem;
        padding: 0.6rem 0.85rem;
    }
    .bot-message .message-content {
        max-width: 95%;
        font-size: 0.9rem;
        padding: 0.6rem 0.85rem;
    }
    .welcome-box {
        width: 95%;
        max-width: 95%;
    }
    
    .card-footer.bg-light {
        padding: 0.75rem;
    }
    
    #user-input {
        font-size: 16px;
        padding: 12px 16px;
        min-height: 44px;
    }
    .chat-button {
        padding: 12px 18px;
        min-width: 60px;
        min-height: 44px;
    }
    .cover-image {
        max-width: 100%;
        margin: 0.75rem 0;
    }
    .chat-messages::-webkit-scrollbar {
        width: 6px;
    }
    footer {
        display: none;
    }
    pre code.hljs {
        font-size: 0.8rem;
        padding: 0.6rem;
    }
    
    /* Extra spacing for carousels on mobile */
    .message-carousel {
        margin-bottom: 1rem;
    }
}

/* Smaller input bar on mobile */
@media (max-width: 767px) {
  .card-footer.bg-light {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 10 !important;
    background: var(--background) !important;
  }
  
  /* iOS Safe Area Support for mobile */
  .card-footer.bg-light {
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  }
}

/* Small mobile devices (320px - 480px) */
@media (max-width: 480px) {
    /* Fix double horizontal scroll */
    .container-fluid, .chat-row, .chat-col .chat-container, .chat-messages {
        width: 100vw !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        box-sizing: border-box;
    }

    /* Hide padding from container/footer */
    .chat-input-container {
        padding: 0 !important;
    }
    /* Hide card header to save space */
    .card-header {
        display: none !important;
    }

    .message .d-flex {
        gap: 0.4rem;
    }

    /* Widen welcome box and message bubbles */
    .welcome-box,
    .bot-message .message-content,
    .user-message .message-content {
        max-width: 100% !important;
        width: 100% !important;
    }

    /* Reduce padding in welcome box and bubbles */
    .welcome-box,
    .bot-message .message-content,
    .user-message .message-content {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    /* Reduce avatar size and gap */
    .avatar {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px;
        min-height: 28px;
        max-width: 28px;
        max-height: 28px;
        font-size: 1rem;
        margin-top: 0;
    }
    /* Make input bar always visible */
    .chat-footer.card-footer.bg-light {
        position: sticky;
        bottom: 0;
        z-index: 10;
        background: var(--background) !important;
        padding: 0.5rem;
    }
    
    #user-input {
        font-size: 16px;
        padding: 10px 14px;
        min-height: 44px;
        border-radius: 20px;
    }
    .chat-button {
        padding: 10px 16px;
        font-size: 0.9rem;
        min-width: 56px;
        min-height: 44px;
        border-radius: 20px;
    }
    .cover-image {
        max-width: 100%;
        margin: 0.5rem 0;
        border-radius: 10px;
    }
    .chat-messages::-webkit-scrollbar {
        width: 4px;
    }
    .chat-messages::-webkit-scrollbar-thumb {
        background-color: var(--accent);
    }
    pre code.hljs {
        font-size: 0.75rem;
        padding: 0.5rem;
        border-radius: 6px;
    }
}
/* Landscape: Ultra-compact phones (iPhone SE, small devices) */
@media only screen and (max-height: 430px) and (orientation: landscape) {
    .chat-container {
        height: calc(100vh - 80px) !important;
        min-height: 150px !important;
    }
    
    .chat-messages {
        padding: 0.25rem !important;
        padding-bottom: 0.4rem !important;
    }

    .input-container {
        padding: none;
    }
    
    .message {
        margin-bottom: 0.4rem !important;
    }
    
    .message .d-flex {
        gap: 0.25rem !important;
    }
    
    .avatar {
        width: 20px !important;
        height: 20px !important;
        min-width: 20px !important;
        min-height: 20px !important;
        max-width: 20px !important;
        max-height: 20px !important;
        font-size: 0.7rem !important;
    }
    
    /* Welcome box in compact row layout */
    .welcome-box {
        display: flex !important;
        flex-direction: row !important;
        align-items: flex-start !important;
        max-width: 100% !important;
        width: 100% !important;
        padding: 0.3rem !important;
        gap: 0.4rem;
    }
    
    .welcome-img {
        width: 70px !important;
        max-width: 70px !important;
        min-width: 70px !important;
        height: auto;
        flex-shrink: 0;
        border-radius: 5px;
        margin: 0 !important;
        display: block !important;
        box-shadow: 0 2px 6px rgba(0,0,0,0.2);
        border: 1px solid var(--border);
    }
    
    .welcome-text {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 0.65rem;
        line-height: 1.15;
        padding: 0;
        overflow-y: auto;

    }
    
    .welcome-text h6 {
        font-size: 0.75rem;
        margin-bottom: 0.2rem;
    }
    
    .welcome-text p {
        font-size: 0.65rem;
        margin-bottom: 0.2rem;
    }
    
    
    .welcome-tip {
        font-size: 0.6rem !important;
        padding: 0.2rem 0.3rem !important;
        margin-top: 0.2rem;
    }
    
    .welcome-text small {
        font-size: 0.55rem;
    }

    .welcome-text::-webkit-scrollbar {
        width: 4px;
    }
    
    .welcome-text::-webkit-scrollbar-thumb {
        background: var(--accent);
        border-radius: 2px;
    }
    
    .welcome-text::-webkit-scrollbar-track {
        background: transparent;
    }
    
    .bot-message .message-content,
    .user-message .message-content {
        font-size: 0.7rem !important;
        padding: 0.3rem 0.45rem !important;
        line-height: 1.2;
        max-width: 100% !important;
    }
    
    .card-footer.bg-light {
        position: sticky !important;
        bottom: 0 !important;
        z-index: 10 !important;
        padding: 0.25rem !important;
    }
    
    #user-input {
        min-height: 28px !important;
        padding: 5px 8px !important;
        font-size: 12px !important;
        line-height: 1.1;
    }
    
    .chat-button {
        padding: 5px 10px !important;
        font-size: 0.7rem !important;
        min-height: 28px !important;
    }
    
    footer, .navbar {
        display: none !important;
    }
}

/* Landscape: Standard phones and small tablets */
@media only screen and (min-height: 431px) and (max-height: 600px) and (orientation: landscape) {
    .chat-container {
        height: calc(100vh - 100px) !important;
        min-height: 200px !important;
    }
    
    .chat-messages {
        padding: 0.35rem !important;
        padding-bottom: 0.5rem !important;
    }
    
    .message {
        margin-bottom: 0.5rem !important;
    }
    
    .message .d-flex {
        gap: 0.3rem !important;
    }
    
    .avatar {
        width: 24px !important;
        height: 24px !important;
        min-width: 24px !important;
        min-height: 24px !important;
        max-width: 24px !important;
        max-height: 24px !important;
        font-size: 0.85rem !important;
    }
    
    /* Welcome box in row layout */
    .welcome-box {
        display: flex !important;
        flex-direction: row !important;
        align-items: flex-start !important;
        max-width: 100% !important;
        width: 100% !important;
        padding: 0.35rem 0.4rem !important;
        gap: 0.5rem;
    }
    
    .welcome-img {
        width: 80px !important;
        max-width: 80px !important;
        min-width: 80px !important;
        height: auto;
        flex-shrink: 0;
        border-radius: 6px;
        margin: 0 !important;
        display: block !important;
        box-shadow: 0 2px 6px rgba(0,0,0,0.2);
        border: 1px solid var(--border);
    }
    
    .welcome-text {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 0.7rem;
        line-height: 1.2;
        padding: 0;
        overflow-y: auto;
        max-height: 22vh;
    }
    
    .welcome-text h6 {
        font-size: 0.8rem;
        margin-bottom: 0.25rem;
    }
    
    .welcome-text p {
        font-size: 0.7rem;
        margin-bottom: 0.25rem;
    }
    
    
    .welcome-tip {
        font-size: 0.65rem !important;
        padding: 0.25rem 0.35rem !important;
        margin-top: 0.25rem;
    }
    
    .welcome-text small {
        font-size: 0.6rem;
    }
    
    .bot-message .message-content,
    .user-message .message-content {
        font-size: 0.75rem !important;
        padding: 0.35rem 0.5rem !important;
        line-height: 1.25;
        max-width: 100% !important;
    }
    
    .card-footer.bg-light {
        padding: 0.35rem !important;
    }
    
    #user-input {
        min-height: 32px !important;
        padding: 6px 10px !important;
        font-size: 13px !important;
        line-height: 1.2;
    }
    
    .chat-button {
        padding: 6px 12px !important;
        font-size: 0.75rem !important;
        min-height: 32px !important;
    }
    
    footer, .navbar {
        display: none !important;
    }
}

/* Landscape: Tablets and larger devices */
@media only screen and (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    .chat-container {
        height: calc(100vh - 150px);
        min-height: 300px;
    }
    
    .chat-messages {
        padding: 0.5rem;
        padding-bottom: 0.75rem;
    }
    
    .message {
        margin-bottom: 0.75rem;
    }
    
    .avatar {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        min-height: 32px !important;
        max-width: 32px !important;
        max-height: 32px !important;
        font-size: 1rem !important;
    }
    
    /* Welcome box - moderate compacting for tablets */
    .welcome-box {
        display: flex !important;
        flex-direction: row !important;
        align-items: flex-start !important;
        max-width: 100%;
        padding: 0.5rem 0.65rem !important;
        gap: 0.75rem;
    }
    
    .welcome-img {
        width: 120px !important;
        max-width: 120px !important;
        min-width: 120px !important;
        height: auto;
        flex-shrink: 0;
        border-radius: 8px;
        margin: 0 !important;
        display: block !important;
        box-shadow: 0 3px 8px rgba(0,0,0,0.25);
        border: 1px solid var(--border);
    }
    
    .welcome-text {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 0.85rem;
        line-height: 1.3;
        padding: 0;
    }
    
    .welcome-text h6 {
        font-size: 0.95rem;
        margin-bottom: 0.4rem;
    }
    
    .welcome-text p {
        font-size: 0.85rem;
        margin-bottom: 0.4rem;
    }
    
    
    .welcome-tip {
        font-size: 0.75rem !important;
        padding: 0.4rem 0.5rem !important;
    }
    
    .bot-message .message-content,
    .user-message .message-content {
        font-size: 0.9rem;
        padding: 0.5rem 0.75rem;
        line-height: 1.4;
    }
    
    .card-footer.bg-light {
        padding: 0.5rem;
    }
    
    #user-input {
        min-height: 38px;
        padding: 8px 14px;
        font-size: 14px;
    }
    
    .chat-button {
        padding: 8px 16px;
        font-size: 0.9rem;
        min-height: 38px;
    }
    
    footer {
        display: none !important;
    }
}

/* =========================================
   NEW SPLIT-VIEW STYLES
   ========================================= */

/* Utility Classes mapping to variables */
.bg-surface { background-color: var(--surface) !important; }
.bg-surface-alt { background-color: var(--surface-alt) !important; }
.text-main { color: var(--text-main) !important; }
.text-subtle { color: var(--text-subtle) !important; }

/* Layout Overrides for Full Height */
html, body {
    height: 100%;
    overflow: hidden; /* Prevent body scroll, handle in containers */
    background-color: var(--background);
}

/* Carousel Overrides */
.carousel-item {
    transition: transform .6s ease-in-out;
}
.carousel-caption {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    bottom: 2rem;
}

/* Quick Actions */
.quick-actions {
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 5px;
    /* Hide scrollbar for cleaner look but allow scroll */
    scrollbar-width: none; 
    -ms-overflow-style: none;
}
.quick-actions::-webkit-scrollbar {
    display: none;
}

.quick-action-btn {
    border: 1px solid var(--accent);
    color: var(--text-main);
    background: rgba(111, 66, 193, 0.1);
    transition: all 0.2s;
    font-size: 0.85rem;
    padding: 0.4rem 1rem;
}

.quick-action-btn:hover {
    background: var(--accent);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(111, 66, 193, 0.3);
}

/* Markdown Styling */
.markdown-body p {
    margin-bottom: 0.8rem;
}
.markdown-body p:last-child {
    margin-bottom: 0;
}
.markdown-body ul, .markdown-body ol {
    padding-left: 1.5rem;
    margin-bottom: 0.8rem;
}
.markdown-body li {
    margin-bottom: 0.3rem;
}
.markdown-body strong {
    font-weight: 600;
    color: var(--text-main);
}
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}
.markdown-body code {
    background: rgba(255,255,255,0.1);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
    color: #e685b5;
}

/* Property Header */
.property-header {
    border-bottom: 1px solid var(--border) !important;
    height: 70px; /* Fixed height for stability */
}

/* Chat Input Area */
.chat-input-area {
    border-top: 1px solid var(--border) !important;
    background-color: var(--surface) !important;
    /* Ensure it stays above keyboard on mobile */
    position: sticky;
    bottom: 0;
    z-index: 100;
    /* Safe area for iPhone X+ */
    padding-bottom: max(1rem, env(safe-area-inset-bottom)) !important;
}

/* Chat Messages Area Override */
.chat-messages {
    height: auto; /* Let flexbox handle it */
    background-color: var(--background);
}

/* Mobile Adjustments */
@media (max-width: 991.98px) {
    /* On mobile, if we want to show carousel, we need to adjust. 
       For now, the HTML hides it (d-none d-lg-block). 
       If we unhide it, we'd use: */
    /*
    .col-lg-7 {
        height: 35vh;
        display: block !important;
    }
    .col-lg-5 {
        height: 65vh;
    }
    */
}