/* Custom Fixes for High Contrast / Visibility - v15 (Sticky Date & Inline Time) */

/* =========================================
   1. GLOBAL VARIABLES & RESET
   ========================================= */
:root {
    --wa-outgoing-bg: #d9fdd3;
    --wa-incoming-bg: #ffffff;
    --wa-chat-bg: #efeae2;
    --wa-header-bg: #f0f2f5;
    --wa-text-primary: #111b21;
    --wa-text-secondary: #667781;
    --wa-green-accent: #00a884;
    --wa-green-active-bg: #d9fdd3;
    --wa-green-active-text: #008069;
    --wa-chip-inactive-bg: #f0f2f5;
    --wa-chip-inactive-border: #e9edef;
    --wa-chip-text: #54656f;
    --wa-time-color: rgba(17, 27, 33, 0.5);
}

/* =========================================
   2. UNIFIED FILTER TABS
   ========================================= */
html body .dashboard .chatbox-area__left,
html body .dashboard .chatbox-wrapper,
html body .dashboard .chatbox-wrapper__header,
html body .dashboard .chatbox-wrapper__tab {
    position: relative !important;
    z-index: 100 !important; /* Force high z-index to stay above chatbody */
    overflow: visible !important; /* Prevent clipping of dropdowns */
}

html body .dashboard .chatbody {
    position: relative !important;
    z-index: 1 !important; /* Lower than header/tabs */
    display: block !important;
    overflow: hidden !important;
}

html body .dashboard .chat-list {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    padding: 0 12px !important;
}

html body .dashboard .chat-list__item {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    width: 100% !important;
    gap: 12px !important;
    padding: 10px 14px !important;
}

html body .dashboard .chat-list__content {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    width: 100% !important;
    min-width: 0 !important;
    overflow: hidden !important;
    gap: 2px !important;
}

html body .dashboard .chat-list__content .text {
    flex: 1 1 auto !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    min-width: 0 !important;
}

html body .dashboard .last-message {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    display: flex !important;
    align-items: center !important;
    overflow: hidden !important;
}

html body .dashboard .last-message-row {
    display: flex !important;
    width: 100% !important;
    justify-content: space-between !important;
    align-items: center !important;
    min-width: 0 !important;
}

html body .dashboard .unseen-message {
    flex-shrink: 0 !important;
}

html body .dashboard .chatbox-wrapper__tab .nav-pills {
    display: flex !important;
    flex-wrap: wrap !important;
    overflow: visible !important;
    gap: 8px !important;
    padding: 8px 14px 4px !important;
    margin: 0 !important;
    border: none !important;
    align-items: center !important;
}

html body .dashboard .chatbox-wrapper__tab .nav-pills::-webkit-scrollbar {
    display: none !important;
}

html body .dashboard .chatbox-wrapper__tab .nav-item {
    flex-shrink: 0 !important;
    list-style: none !important;
    margin-bottom: 4px !important; /* Added space for wrapped rows */
}

html body .dashboard .chatbox-wrapper__tab #chat-filters .nav-link {
    background-color: #ffffff !important;
    color: var(--wa-chip-text) !important;
    border: 1px solid var(--wa-chip-inactive-border) !important;
    border-radius: 20px !important;
    padding: 6px 14px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    white-space: nowrap !important;
    transition: all 0.2s ease !important;
    display: block !important;
    line-height: normal !important;
    height: auto !important;
    width: auto !important;
    min-width: unset !important;
    margin: 0 !important;
}

html body .dashboard .chatbox-wrapper__tab #chat-filters .nav-link:hover {
    background-color: #f5f6f6 !important;
}

html body .dashboard .chatbox-wrapper__tab #chat-filters .nav-link.active {
    background-color: var(--wa-green-active-bg) !important;
    color: var(--wa-green-active-text) !important;
    border-color: var(--wa-green-accent) !important;
    font-weight: 600 !important;
}

html body .dashboard .chatbox-wrapper__tab #chat-filters .dropdown-toggle::after {
    display: inline-block;
    margin-left: 6px;
    vertical-align: middle;
    content: "";
    border-top: 4px solid;
    border-right: 3px solid transparent;
    border-bottom: 0;
    border-left: 3px solid transparent;
}

.label-filter-item.active {
    background-color: var(--wa-green-active-bg) !important;
    color: var(--wa-green-active-text) !important;
}

/* =========================================
   3. MESSAGE BUBBLES & TIME
   ========================================= */

/* Common Bubble Styling */
html body .single-message .message-content {
    position: relative;
    padding: 6px 7px 8px 9px !important;
    max-width: 100%;
    width: auto !important;
    /* Let it grow naturally */
    display: inline-block !important;
    /* Allow it to be inline but block-like */
}

/* OUTGOING */
html body .single-message.message--right .message-content {
    background-color: var(--wa-outgoing-bg) !important;
    color: var(--wa-text-primary) !important;
    border-radius: 8px 0px 8px 8px !important;
    box-shadow: 0 1px 0.5px rgba(11, 20, 26, .13);
}

html body .single-message.message--right .message-content * {
    color: var(--wa-text-primary) !important;
}

/* INCOMING */
html body .single-message.message--left .message-content {
    background-color: var(--wa-incoming-bg) !important;
    color: var(--wa-text-primary) !important;
    border-radius: 0px 8px 8px 8px !important;
    box-shadow: 0 1px 0.5px rgba(11, 20, 26, .13);
}

html body .single-message.message--left .message-content * {
    color: var(--wa-text-primary) !important;
}

/* Links */
html body .single-message .message-content a {
    color: #027eb5 !important;
    text-decoration: underline;
}

/* INLINE TEXT */
html body .single-message .message-content .message-text {
    display: inline !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 14.2px !important;
    line-height: 19px !important;
}

/* TIME STYLING */
/* Handled mainly by inline styles in blade for precision, but defaults here */
html body .message-meta {
    float: right;
    margin-left: 8px;
    margin-top: 6px;
    position: relative;
    top: 2px;
}

html body .message-time {
    font-size: 11px !important;
    color: var(--wa-time-color) !important;
    white-space: nowrap;
}

html body .single-message.message--right .message-content .message-time,
html body .single-message.message--left .message-content .message-time {
    color: var(--wa-time-color) !important;
}

html body .single-message .message-content::after {
    content: "";
    display: table;
    clear: both;
}

/* =========================================
   4. CHAT BACKGROUND
   ========================================= */
html body .chatbox-area__body .body-middle,
html body .chat-box-area {
    background-color: var(--wa-chat-bg) !important;
}

/* =========================================
   5. RIGHT SIDEBAR DETAILS & STICKY DATE
   ========================================= */
.contact__details {
    background-color: #ffffff !important;
}

.contact__details p,
.contact__details span,
.contact__details div,
.contact__details .title,
.contact__details .profile-name,
.contact__details .details-content__text {
    color: var(--wa-text-primary) !important;
}

.chat-date-separator span {
    background-color: #ffffff !important;
    color: #54656f !important;
    box-shadow: 0 1px 0.5px rgba(11, 20, 26, .13) !important;
    font-size: 12.5px !important;
    text-transform: uppercase;
    border: none !important;
    padding: 5px 12px !important;
    border-radius: 7.5px !important;
    font-weight: 500 !important;
    display: inline-block;
}

/* STICKY DATE HEADER */
.chat-date-separator {
    margin: 12px 0 12px 0;
    text-align: center;
    width: 100%;
    position: sticky;
    /* Make it sticky */
    top: 10px;
    /* Stick 10px from top of scrolling area */
    z-index: 100;
    /* Ensure it floats above messages */
    pointer-events: none;
    /* Let clicks pass through if needed */
}

/* =========================================
   6. LAYOUT FIXES (Override main.css Safari hacks)
   ========================================= */

/* Fix 1: Restore d-none behavior inside chatbox which was overridden by display: flex !important */
html body.is-inbox .chatbox-area__body.d-none,
html body.is-inbox .empty-conversation.d-none {
    display: none !important;
}

/* Fix 2: Restore horizontal layout for chatbox-area__body so .chat-box and .body-right sit side by side */
html body.is-inbox .chatbox-area__body {
    flex-direction: row !important;
}

/* Fix 3: Ensure .msg-body takes remaining height instead of collapsing */
html body.is-inbox .chatbox-area__body .chat-box {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    flex: 1 1 auto !important; /* Grow and shrink */
    min-height: 0 !important;
}

html body.is-inbox .chat-box .msg-body {
    flex: 1 1 auto !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow-y: auto !important;
}