/* backend/static/css/chat.css */

/* --- Theme Variables --- */
/* Define colors for light mode */
:root, :root[data-bs-theme="light"] {
    --wa-bg: #f8f9fa; /* Softer warm gray background */
    --wa-chat-area-bg: #f8f9fa; /* Background behind bubbles */
    --wa-intro-bg: #f1f3f4; /* Softer placeholder background */
    --wa-intro-text: #5f6368;
    --wa-header-bg: #f1f3f4;
    --wa-sidebar-bg: #fefefe; /* Very soft off-white sidebar */
    --wa-sidebar-text: #202124;
    --wa-sidebar-text-secondary: #5f6368;
    --wa-sidebar-active-bg: #e8f0fe; /* Soft blue-tinted active */
    --wa-sidebar-hover-bg: #f8f9fa;
    --wa-bubble-in-bg: #f8f9fa; /* Incoming - soft gray */
    --wa-bubble-out-bg: #e3f2fd; /* Outgoing - soft blue */
    --wa-text: #202124; /* Softer primary text */
    --wa-text-secondary: #5f6368; /* Softer secondary text */
    --wa-input-bar-bg: #f1f3f4;
    --wa-input-bg: #fefefe;
    --wa-icon: #5f6368;
    --wa-icon-hover: #202124;
    --wa-border: #e8eaed;

    /* --- Added for Form Validation --- */
    --bs-form-invalid-color: var(--bs-danger);
    --bs-form-invalid-border-color: var(--bs-danger);
}

/* Define colors for dark mode */
:root[data-bs-theme="dark"] {
    --wa-bg: #0b141a; /* Very dark main bg */
    --wa-chat-area-bg: #0b141a;
    --wa-intro-bg: #202c33; /* Dark placeholder bg */
    --wa-intro-text: #8696a0;
    --wa-header-bg: #202c33;
    --wa-sidebar-bg: #111b21; /* Dark sidebar */
    --wa-sidebar-text: #e9edef;
    --wa-sidebar-text-secondary: #8696a0;
    --wa-sidebar-active-bg: #2a3942; /* Darker grey active */
    --wa-sidebar-hover-bg: #202c33;
    --wa-bubble-in-bg: #202c33; /* Incoming */
    --wa-bubble-out-bg: #005c4b; /* Dark green outgoing */
    --wa-text: #e9edef; /* Light primary text */
    --wa-text-secondary: #8696a0; /* Lighter secondary text */
    --wa-input-bar-bg: #202c33;
    --wa-input-bg: #2a3942;
    --wa-icon: #8696a0;
    --wa-icon-hover: #aebac1;
    --wa-border: #374045; /* Darker border */

    /* --- Added for Form Validation --- */
    --bs-form-invalid-color: var(--bs-danger); /* Keep same for visibility */
    --bs-form-invalid-border-color: var(--bs-danger);
}


/* --- Body & Layout --- */
body {
    display: block;
    min-height: 100vh;
    background-color: var(--wa-bg);
    color: var(--wa-text);
    overflow-y: auto; /* Changed from hidden to auto, to allow scroll if content overflows viewport */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    font-size: 14px;
}

/* Navbar */
.navbar {
    background-color: var(--wa-header-bg) !important;
    border-bottom: 1px solid var(--wa-border);
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}
 .navbar .navbar-brand { color: var(--wa-text) !important; font-weight: 500; }
 .navbar .navbar-text { color: var(--wa-text) !important; }
 .navbar .nav-link { color: var(--wa-text-secondary) !important; }
 .navbar .nav-link:hover { color: var(--wa-text) !important; }

.btn-icon {
    background: none;
    border: none;
    color: var(--wa-icon);
    padding: 8px;
    margin: 0;
    border-radius: 50%;
    line-height: 1;
    font-size: 1.25rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-icon:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--wa-icon-hover);
}
[data-bs-theme="dark"] .btn-icon:hover {
    background-color: rgba(255, 255, 255, 0.1);
}
.btn-icon:focus {
    box-shadow: none;
}

/* Main Layout (Sidebar + Chat Area) */
.main-chat-layout {
    display: flex;
    height: calc(100vh - 56px - 1rem); /* Assuming navbar height approx 56px + 1rem margin below navbar */
    max-height: calc(100vh - 56px - 1rem); /* Consistency */
    border: 1px solid var(--wa-border);
    border-radius: 0; /* Or your preference, e.g., 0.25rem */
    overflow: hidden;
    background-color: var(--wa-sidebar-bg); /* Sidebar bg often defines the "window" bg */
    margin: 0 auto;
    max-width: 1600px; /* Or your preferred max width */
    box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.06), 0 2px 5px 0 rgba(0, 0, 0, 0.06);
}

main.container-fluid { /* Adjust padding for the container holding main-chat-layout */
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}


/* --- Sidebar --- */
.sidebar {
    width: 35%;
    min-width: 320px;
    max-width: 450px;
    flex-shrink: 0;
    border-right: 1px solid var(--wa-border);
    display: flex;
    flex-direction: column;
    max-height: 100%; /* Ensure it doesn't exceed parent */
    overflow-y: auto;
    background-color: var(--wa-sidebar-bg);
}
.sidebar-section {
    padding: 10px 0px;
    border-bottom: 1px solid var(--wa-border);
}
.sidebar-section:last-child {
    border-bottom: none;
}
.sidebar-section h5 {
    font-size: 0.8rem;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--wa-text-secondary);
    margin-bottom: 8px;
    padding: 5px 15px;
}
.sidebar .list-group-item {
    background-color: transparent;
    border: none; /* Bootstrap list-group-items have borders by default */
    padding: 12px 15px; /* Increased padding for better spacing with full names */
    color: var(--wa-text);
    font-size: 0.95rem;
    border-radius: 0;
    margin-bottom: 0; /* No margin between items */
    /* border-bottom: 1px solid var(--wa-border); /* Optional: separator between items, remove if list-group-flush handles it */
    cursor: pointer;
    display: flex;
    align-items: flex-start; /* Align to top for multi-line names */
}
.sidebar .list-group.list-group-flush .list-group-item {
    border-width: 0 0 1px; /* For list-group-flush, only bottom border */
    border-color: var(--wa-border);
}
.sidebar .list-group.list-group-flush .list-group-item:last-child {
    border-bottom-width: 0; /* No border on the very last item */
}
.sidebar .list-group-item:hover {
    background-color: var(--wa-sidebar-hover-bg);
}
.sidebar .list-group-item.active {
     background-color: var(--wa-sidebar-active-bg);
     color: var(--wa-text);
}
.sidebar .list-group-item-action:focus,
.sidebar .list-group-item-action:active {
    box-shadow: none;
    background-color: var(--wa-sidebar-hover-bg); /* Consistent hover/focus */
    outline: none;
}
.sidebar .list-group-item.active:focus,
.sidebar .list-group-item.active:active {
    background-color: var(--wa-sidebar-active-bg); /* Keep active style on focus */
}
.sidebar .list-group-item .avatar-icon { /* This is the <img> tag */
     width: 45px;
     height: 45px;
     border-radius: 50%;
     object-fit: cover;
     margin-right: 12px;
     margin-top: 2px; /* Slight top margin for better alignment with text */
     flex-shrink: 0; /* Prevent icon from shrinking */
}

/* Container for all text info (name, type, badge/dot) */
.sidebar .list-group-item .avatar-info-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-grow: 1;
    /* Remove overflow hidden to allow full name display */
    min-width: 0; /* Critical for child flex items with text-overflow */
}

/* Line containing the avatar name */
.sidebar .list-group-item .avatar-name-line {
    width: 100%;
}

.sidebar .list-group-item .avatar-name {
    font-weight: 500;
    display: block;
    /* Allow full name display without truncation */
    white-space: normal;
    line-height: 1.3;
    word-break: break-word;
    /* Remove height restrictions to show full names */
}

/* Line containing the unread dot and any metadata */
.sidebar .list-group-item .avatar-meta-line {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
    margin-top: 2px;
    min-height: 16px; /* Ensure consistent spacing even when empty */
}

/* WhatsApp-like message preview */
.sidebar .list-group-item .avatar-message-preview {
    font-size: 0.8em;
    color: var(--wa-sidebar-text-secondary);
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px; /* Increased width to use more available space */
    line-height: 1.2;
}

/* Time stamp in sidebar */
.sidebar .list-group-item .avatar-time {
    font-size: 0.75em;
    color: var(--wa-sidebar-text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: 8px;
}

.sidebar .list-group-item .avatar-type-line {
    font-size: 0.8em;
    color: var(--wa-sidebar-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 5px; /* Space before dot if text is long */
}

/* Unread Message Dot Indicator */
.sidebar .list-group-item .unread-dot-indicator {
    width: 8px;
    height: 8px;
    background-color: #06d755; /* WhatsApp green */
    border-radius: 50%;
    display: inline-block; 
    flex-shrink: 0;
}

.no-conversations, .no-avatars {
    font-style: italic;
    color: var(--wa-text-secondary);
    font-size: 0.9rem;
    padding: 10px 15px;
    text-align: center;
}


/* --- Chat Area (Parent of Placeholder/Chat Container) --- */
.chat-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative; /* For potential absolute positioned elements within */
    overflow: hidden; /* Contains message list scrolling */
    background-color: var(--wa-chat-area-bg);
    /* Optional: background image for chat area
    background-image: url('/static/images/wa_chat_bg.png');
    background-repeat: repeat;
    background-size: auto;
    */
}

/* Chat Placeholder (When no chat is selected) */
.chat-placeholder {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
    color: var(--wa-intro-text);
    text-align: center;
    background-color: var(--wa-intro-bg);
    border-bottom: 6px solid #4dbd6d; /* WhatsApp green accent */
    padding: 20px;
}
.chat-placeholder i {
    font-size: 5rem; /* Slightly smaller than before for balance */
    margin-bottom: 1.5rem;
    color: var(--wa-text-secondary);
    opacity: 0.4;
}
.chat-placeholder p {
    font-size: 1.1rem;
    max-width: 400px;
}


/* Chat Container (Holds Header, Messages, Input) */
.chat-container {
    width: 100%;
    height: 100%;
    max-height: 100%; /* Important for grid */
    background-color: transparent; /* Let chat-area background show through */
    display: grid;
    grid-template-rows: auto 1fr auto; /* Header, Messages (flexible), Input */
    grid-template-columns: 100%;
}
.chat-container.d-none { display: none !important; }
.chat-container.d-grid { display: grid !important; }


/* Chat Header (Top bar within chat) */
.chat-header {
    grid-row: 1 / 2;
    grid-column: 1 / 2;
    display: flex;
    align-items: center;
    padding: 10px 16px;
    background-color: var(--wa-header-bg);
    border-bottom: 1px solid var(--wa-border);
    flex-shrink: 0; /* Prevent shrinking */
    min-height: 59px;
}
.selected-avatar-img { /* This is the <img> tag in chat header */
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 15px;
    border: none; /* No border on avatar image itself */
    flex-shrink: 0;
}
.chat-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--wa-text);
    margin: 0;
    flex-grow: 1;
    display: flex;
    align-items: center;
    /* Allow full name display in chat header */
}
.chat-title .selected-avatar-name {
     /* Allow full name display without truncation */
     display: inline-block;
     white-space: normal;
     word-break: break-word;
     line-height: 1.3;
}
.chat-title i.d-none, .chat-title img.d-none { display: none !important; }



/* Message List Container (Scrolling Area) */
.message-list-container {
    grid-row: 2 / 3;
    grid-column: 1 / 2;
    overflow-y: auto;
    padding: 12px 7%; /* Horizontal padding to keep bubbles from edges */
    display: flex;
    flex-direction: column;
    gap: 3px; /* Small gap between consecutive bubbles */
    min-height: 0; /* Important for flex child in grid row */
}

/* History Loading Spinner */
.history-loading {
     color: var(--wa-text-secondary);
     padding: 20px;
     text-align: center;
     font-size: 0.9em;
}
.history-loading .spinner-border {
    width: 1rem;
    height: 1rem;
    border-width: .2em;
}


/* Message Bubble Base */
.message {
    padding: 6px 9px 8px 9px;
    border-radius: 7.5px;
    max-width: 65%;
    word-wrap: break-word;
    box-shadow: 0 1px 0.5px rgba(11,20,26,.13);
    position: relative; /* For potential absolute elements like seen ticks */
    font-size: 14.2px;
    line-height: 19px;
    margin-bottom: 9px; /* Space between distinct messages */
}
.message div:first-child { /* Targets the contentWrapper created by JS */
    /* Styles for the contentWrapper (text + timestamp) are handled in JS for flex layout */
}
.message img { /* Style for images within message bubbles */
    max-width: 100%;
    object-fit: contain;
    border-radius: 6px; /* Match bubble rounding slightly */
    margin-bottom: 5px; /* Space if caption/timestamp is below */
    cursor: pointer; /* If images are clickable for larger view */
}


/* AI/Incoming Message */
.ai-message {
    background-color: var(--wa-bubble-in-bg);
    color: var(--wa-text);
    align-self: flex-start; /* Pushes to left */
    margin-right: auto;
    border-top-left-radius: 0; /* Tail effect */
}

/* User/Outgoing Message */
.user-message {
    background-color: var(--wa-bubble-out-bg);
    color: var(--wa-text); /* Text color on light green */
    align-self: flex-end; /* Pushes to right */
    margin-left: auto;
    border-top-right-radius: 0; /* Tail effect */
}
[data-bs-theme="dark"] .user-message {
     color: #e9edef; /* Light text on dark green */
}


/* Input Area (Bottom bar) */
.input-container {
    grid-row: 3 / 4;
    grid-column: 1 / 2;
    display: flex;
    align-items: center; /* Vertically center items if textarea is single line */
    padding: 5px 16px;
    background-color: var(--wa-input-bar-bg);
    border-top: 1px solid var(--wa-border);
    flex-shrink: 0;
    min-height: 52px;
}

.message-form {
    display: flex;
    align-items: flex-end; /* Align send button with bottom of multi-line textarea */
    width: 100%;
    gap: 12px;
}

.message-input {
    flex-grow: 1;
    border: none;
    border-radius: 21px;
    padding: 9px 12px 11px; /* Top, Hori, Bottom */
    background-color: var(--wa-input-bg);
    color: var(--wa-text);
    resize: none; /* Disable manual resize */
    overflow-y: auto; /* Scroll if content exceeds max-height */
    max-height: 120px; /* e.g., 5 lines */
    line-height: 20px;
    font-size: 15px;
    box-shadow: none;
    outline: none;
    border: 1px solid transparent; /* Placeholder for focus border */
}
.message-input:focus {
     border: 1px solid var(--bs-primary); /* Or a custom focus color */
}
.message-input::placeholder {
    color: var(--wa-text-secondary);
    opacity: 0.8;
}
.message-input:disabled {
     background-color: var(--wa-sidebar-active-bg); /* Or a more distinct disabled color */
     opacity: 0.6;
     cursor: not-allowed;
}

.send-button {
    border: none;
    background-color: transparent;
    color: var(--wa-icon);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease;
    padding: 0;
    margin-bottom: 2px; /* Align with textarea bottom padding */
}
.send-button:hover:not(:disabled) {
    color: var(--wa-icon-hover);
    /* background-color: rgba(0,0,0,0.03); Light subtle bg on hover */
}
/* [data-bs-theme="dark"] .send-button:hover:not(:disabled) {
    background-color: rgba(255,255,255,0.05);
} */
.send-button:disabled {
    color: var(--wa-text-secondary);
    opacity: 0.5;
    cursor: not-allowed;
}
.send-button i { font-size: 1.5rem; }


/* Typing Indicator */
.typing-indicator {
    /* Align self to left, like incoming messages */
    align-self: flex-start;
    margin-right: auto;
    /* Styling similar to an incoming message bubble */
    margin-bottom: 9px;
    padding: 6px 9px 8px 9px;
    max-width: fit-content;
    background-color: var(--wa-bubble-in-bg);
    color: var(--wa-text);
    box-shadow: 0 1px 0.5px rgba(11,20,26,.13);
    border-radius: 7.5px;
    border-top-left-radius: 0; /* Tail for incoming */
    display: none; /* JS will toggle */
    align-items: center; /* Align dots vertically */
}
.typing-dots {
    display: flex;
    align-items: center;
    /* No need for background/shadow/border if the parent .typing-indicator has them */
    padding: 0; /* Remove default padding if any from a generic class */
    height: 10px; /* Height of the dots container */
}
.typing-dot {
    width: 6px; /* Smaller dots */
    height: 6px;
    margin: 0 2px;
    background-color: var(--wa-text-secondary); /* Use secondary text color for dots */
    border-radius: 50%;
    animation: typing 1.2s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; } /* Adjusted delay */
.typing-dot:nth-child(3) { animation-delay: 0.4s; } /* Adjusted delay */

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.6;
    }
    30% { /* Peak of bounce */
        transform: translateY(-4px); /* Adjust bounce height */
        opacity: 1;
    }
}

/* Message Timestamp */
.message-timestamp {
    font-size: 0.75rem; /* Small timestamp */
    color: var(--wa-text-secondary);
    opacity: 0.8;
    line-height: 1; /* Keep it tight */
    align-self: flex-end; /* Aligns to the end of the flex container (contentWrapper) */
    /* margin-left: 8px; /* Space from text if on same line, handled by JS flex */
    /* padding-top: 4px; /* Space if below text */
}


/* --- Styles for Create Avatar Form --- */
#avatar-form .form-label {
    font-weight: 500;
    color: var(--wa-text);
}

#avatar-form .form-control,
#avatar-form .form-select {
    background-color: var(--wa-input-bg);
    color: var(--wa-text);
    border-color: var(--wa-border);
}
#avatar-form .form-control:focus,
#avatar-form .form-select:focus {
    background-color: var(--wa-input-bg); /* Keep background on focus */
    color: var(--wa-text);
    border-color: var(--bs-primary); /* Use Bootstrap primary for focus */
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25);
}

#avatar-form .form-text {
    color: var(--wa-text-secondary);
    font-size: 0.85em;
}

/* Bootstrap validation styles for the form */
#avatar-form .form-control.is-invalid,
#avatar-form .form-select.is-invalid {
    border-color: var(--bs-form-invalid-border-color) !important; /* Ensure override */
    /* SVG icon for invalid state - standard Bootstrap */
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(.375em + .1875rem) center;
    background-size: calc(.75em + .375rem) calc(.75em + .375rem);
    padding-right: calc(1.5em + .75rem); /* Make space for the icon */
}
#avatar-form .form-control.is-invalid:focus,
#avatar-form .form-select.is-invalid:focus {
     box-shadow: 0 0 0 0.25rem rgba(var(--bs-danger-rgb), 0.25); /* Danger focus shadow */
}

#avatar-form .invalid-feedback {
    /* display: none; Bootstrap's .was-validated will handle display */
    color: var(--bs-form-invalid-color);
    font-size: 0.875em;
    margin-top: .25rem;
}

.avatar-form-alert {
    /* Use Bootstrap alert variables. JS adds .alert, .alert-danger etc. */
}


/* Fix any overflow issues with bootstrap-adjacent elements */
.accordion-item {
    background-color: transparent;
    border-color: var(--wa-border);
    color: var(--wa-text);
}
.accordion-button { /* Ensure accordion buttons are themed */
    color: var(--wa-text);
    background-color: var(--wa-header-bg); /* Or a slightly different shade */
}
.accordion-button:not(.collapsed) {
    color: var(--wa-text); /* Color when open */
    background-color: var(--wa-sidebar-active-bg); /* Match active bg */
}
.accordion-button:focus {
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25); /* Focus ring */
}
[data-bs-theme="dark"] .accordion-button::after { /* Dark theme accordion icon */
    filter: invert(1) grayscale(100%) brightness(200%);
}


/* --- Styles for Image Viewer Modal & Clickable Profile Pics --- */
#imageViewerModal .modal-content {
    box-shadow: none; /* Remove default modal shadow if background is transparent */
    background-color: rgba(0,0,0,0.5); /* Semi-transparent dark background for the modal content area */
}

#imageViewerModal .modal-header {
    border-bottom: none; /* Cleaner look */
}
#imageViewerModal .modal-title {
    color: #fff; /* Ensure title is visible on dark overlay */
}
#imageViewerModal .btn-close-white { /* Ensure close button is visible */
    filter: invert(1) grayscale(100%) brightness(200%); /* Make it white */
}

#imageViewerModal .modal-body img {
    border-radius: 8px; /* Optional: rounded corners for the image */
    /* background-color: var(--wa-sidebar-bg); Removed, as modal-content handles bg */
    display: block; /* Ensure it behaves as a block for margin auto */
    margin-left: auto;
    margin-right: auto;
}

/* Ensure clickable profile pictures have a pointer cursor and hover effect */
.sidebar .list-group-item .avatar-icon,
.chat-header .selected-avatar-img {
    cursor: pointer;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}
.sidebar .list-group-item .avatar-icon:hover,
.chat-header .selected-avatar-img:hover {
    transform: scale(1.08); /* Slightly increased scale for better feedback */
    box-shadow: 0 2px 10px rgba(0,0,0,0.2); /* More pronounced shadow */
}

[data-bs-theme="dark"] .sidebar .list-group-item .avatar-icon:hover,
[data-bs-theme="dark"] .chat-header .selected-avatar-img:hover {
    box-shadow: 0 2px 12px rgba(255,255,255,0.15); /* Adjusted dark mode shadow */
}

/* --- NEW TAB SYSTEM STYLES --- */

/* Tab Navigation */
.sidebar-tabs {
    background-color: var(--wa-sidebar-bg);
    border-bottom: 1px solid var(--wa-border);
    padding: 0;
}

.sidebar-tabs .nav-tabs {
    border-bottom: none;
    margin-bottom: 0;
}

.sidebar-tabs .nav-tabs .nav-item {
    flex: 1;
}

.sidebar-tabs .nav-tabs .nav-link {
    background-color: transparent;
    border: none;
    color: var(--wa-text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 12px 8px;
    text-align: center;
    border-radius: 0;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-tabs .nav-tabs .nav-link:hover {
    background-color: var(--wa-sidebar-hover-bg);
    color: var(--wa-text);
    border-color: transparent;
}

.sidebar-tabs .nav-tabs .nav-link.active {
    background-color: var(--wa-sidebar-active-bg);
    color: var(--wa-text);
    border-color: transparent;
    border-bottom: 2px solid var(--bs-primary);
}

.sidebar-tabs .nav-tabs .nav-link i {
    font-size: 0.9rem;
    margin-right: 4px;
}

/* Tab Content */
.tab-content {
    flex: 1;
    overflow-y: auto;
    background-color: var(--wa-sidebar-bg);
}

.tab-pane {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Section Headers */
.section-header {
    padding: 15px 15px 10px 15px;
    background-color: var(--wa-sidebar-bg);
    border-bottom: 1px solid var(--wa-border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.section-header h6 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--wa-text);
    margin-bottom: 2px;
}

.section-header small {
    color: var(--wa-text-secondary);
    font-size: 0.75rem;
}

/* Loading States */
.loading-placeholder {
    color: var(--wa-text-secondary);
    font-size: 0.85rem;
    padding: 20px 15px;
}

.loading-placeholder .spinner-border {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 30px 20px;
    color: var(--wa-text-secondary);
}

.empty-state i {
    color: var(--wa-text-secondary);
    opacity: 0.6;
    margin-bottom: 15px;
}

.empty-state h6 {
    color: var(--wa-text);
    font-weight: 600;
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.85rem;
    line-height: 1.4;
    margin-bottom: 15px;
}

.empty-state .btn {
    font-size: 0.85rem;
    padding: 8px 16px;
}

/* Guest States */
.guest-state {
    text-align: center;
    padding: 30px 20px;
    color: var(--wa-text-secondary);
}

.guest-state i {
    color: var(--wa-text-secondary);
    opacity: 0.6;
    margin-bottom: 15px;
}

.guest-state h6 {
    color: var(--wa-text);
    font-weight: 600;
    margin-bottom: 8px;
}

.guest-state p {
    font-size: 0.85rem;
    line-height: 1.4;
    margin-bottom: 15px;
}

.guest-state .btn {
    font-size: 0.85rem;
    padding: 8px 16px;
}

/* Enhanced Chat Header */
.chat-header {
    background-color: var(--wa-header-bg);
    border-bottom: 1px solid var(--wa-border);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 70px;
}

.chat-title {
    display: flex;
    align-items: center;
    flex: 1;
}

.selected-avatar-info {
    display: flex;
    flex-direction: column;
    margin-left: 12px;
}

.selected-avatar-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--wa-text);
    line-height: 1.2;
}

.selected-avatar-type {
    font-size: 0.75rem;
    color: var(--wa-text-secondary);
    text-transform: capitalize;
}

/* Chat actions removed for cleaner interface */

/* Note: Avatar type tags removed as per user feedback - tabs already categorize avatars */

/* Chat Placeholder Enhancements */
.chat-placeholder {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    background-color: var(--wa-intro-bg);
    color: var(--wa-intro-text);
    text-align: center;
    padding: 40px 20px;
}

.chat-placeholder i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.chat-placeholder h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--wa-text);
}

.chat-placeholder p {
    font-size: 1rem;
    margin-bottom: 20px;
    color: var(--wa-text-secondary);
}

.chat-placeholder .btn {
    font-size: 0.9rem;
    padding: 10px 20px;
    border-radius: 8px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-chat-layout {
        flex-direction: column;
        height: calc(100vh - 56px - 1rem);
    }
    
    .sidebar {
        width: 100%;
        max-width: none;
        min-width: auto;
        height: 50%;
        border-right: none;
        border-bottom: 1px solid var(--wa-border);
    }
    
    .chat-area {
        height: 50%;
    }
    
    .sidebar-tabs .nav-tabs .nav-link {
        font-size: 0.8rem;
        padding: 10px 6px;
    }
    
    .sidebar-tabs .nav-tabs .nav-link i {
        margin-right: 2px;
    }
    
    .section-header {
        padding: 10px 15px 8px 15px;
    }
    
    .empty-state,
    .guest-state {
        padding: 20px 15px;
    }
}

@media (max-width: 576px) {
    .sidebar-tabs .nav-tabs .nav-link {
        font-size: 0.75rem;
        padding: 8px 4px;
    }
    
    .sidebar-tabs .nav-tabs .nav-link span {
        display: none;
    }
    
    .chat-placeholder {
        padding: 20px 15px;
    }
    
    .chat-placeholder i {
        font-size: 3rem;
        margin-bottom: 15px;
    }
    
    .chat-placeholder h2 {
        font-size: 1.25rem;
    }
    
    .chat-placeholder p {
        font-size: 0.9rem;
    }
}

/* Dark theme specific adjustments */
[data-bs-theme="dark"] .sidebar-tabs .nav-tabs .nav-link.active {
    border-bottom-color: var(--bs-primary);
}

/* Note: Dark theme avatar type styles removed as per user feedback */