/* =====================================================================
   Realu.lt — Internal Chat Widget Styles
   Brand palette: #FF9400 (orange) · #1C1230 (dark navy/purple) · #ffffff
   ===================================================================== */

/* ── Reset / Variables ──────────────────────────────────────────────── */
@media (max-width: 620px) {
    body.rl-chat-body-lock {
        overflow: hidden;
    }
}

#rl-chat-widget,
#rl-chat-widget * {
    box-sizing: border-box;
    margin: 0;
    /* padding is intentionally NOT reset here — the ID selector's high
       specificity (1,0,0) would override all class-level padding rules. */
}

#rl-chat-widget {
    /* Brand */
    --chat-orange:       #FF9400;
    --chat-orange-dark:  #e07c00;
    --chat-orange-light: #fff4e0;
    --chat-navy:         #1C1230;
    --chat-navy-mid:     #2e1f4a;
    --chat-navy-light:   #f0eef5;

    /* Neutrals */
    --chat-white:        #ffffff;
    --chat-grey-bg:      #f6f6f8;
    --chat-grey-line:    #e6e3ed;
    --chat-grey-text:    #8a86a0;
    --chat-text:         #1C1230;
    --chat-bubble-in:    #ededf2;

    /* Layout */
    --chat-radius:       14px;
    --chat-shadow:       0 12px 48px rgba(28, 18, 48, .22);
    --chat-toggle-sz:    58px;
    --chat-popup-w:      840px;
    --chat-popup-h:      580px;
    --chat-sidebar-w:    280px;
    --chat-z:            9998;

    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: var(--chat-z);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.45;
    color: var(--chat-text);
}

/* ── Toggle button ──────────────────────────────────────────────────── */
.rl-chat__toggle {
    position: relative;
    width:  var(--chat-toggle-sz);
    height: var(--chat-toggle-sz);
    border: none;
    border-radius: 14px;
    background: var(--chat-orange);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(255, 148, 0, .45);
    transition: background .2s, transform .15s, box-shadow .2s;
    outline: none;
}

.rl-chat__toggle:hover {
    background: var(--chat-orange-dark);
    transform: scale(1.07);
    box-shadow: 0 8px 28px rgba(255, 148, 0, .55);
}

.rl-chat__toggle svg {
    width: 26px;
    height: 26px;
    pointer-events: none;
}

/* Unread badge on toggle button */
.rl-chat__badge {
    position: absolute;
    top: -7px;
    right: -7px;
    min-width: 22px;
    height: 22px;
    padding: 0 3px;
    border-radius: 11px;
    background: var(--chat-navy);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 22px;
    text-align: center;
    border: 2px solid var(--chat-white);
    pointer-events: none;
}

/* ── Popup ──────────────────────────────────────────────────────────── */
.rl-chat__popup {
    position: absolute;
    bottom: calc(var(--chat-toggle-sz) + 16px);
    right: 0;
    width: var(--chat-popup-w);
    height: min(var(--chat-popup-h), calc(100svh - 120px));
    max-height: calc(100svh - 120px);
    background: var(--chat-white);
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    display: flex;
    overflow: hidden;
    animation: chatSlideIn .22s cubic-bezier(.16,1,.3,1);
    border: 1px solid var(--chat-grey-line);
}

@keyframes chatSlideIn {
    from { opacity: 0; transform: translateY(16px) scale(.96); }
    to   { opacity: 1; transform: translateY(0)     scale(1);  }
}

/* ── Sidebar ────────────────────────────────────────────────────────── */
.rl-chat__sidebar {
    width: var(--chat-sidebar-w);
    flex-shrink: 0;
    border-right: 1px solid var(--chat-grey-line);
    display: flex;
    flex-direction: column;
    background: var(--chat-white);
}

/* Sidebar header — dark navy bar */
.rl-chat__sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 9px 8px;
    background: var(--chat-navy);
    flex-shrink: 0;
}

.rl-chat__title {
    font-size: 16px;
    font-weight: 700;
    color: var(--chat-white);
    letter-spacing: .01em;
    padding: 1px 2px 1px 0;
}

.rl-chat__close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255,255,255,.10);
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,.80);
    transition: background .15s, color .15s;
    flex-shrink: 0;
}

.rl-chat__close-btn:hover {
    background: rgba(255,255,255,.22);
    color: #fff;
}

.rl-chat__close-btn svg {
    width: 16px;
    height: 16px;
}

.rl-chat__header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.rl-chat__settings-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255,255,255,.10);
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,.80);
    transition: background .15s, color .15s;
    flex-shrink: 0;
}

.rl-chat__settings-btn:hover {
    background: rgba(255,255,255,.22);
    color: #fff;
}

.rl-chat__settings-btn svg {
    width: 18px;
    height: 18px;
}

.rl-chat__settings {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 6;
    background: rgba(28, 18, 48, .45);
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.rl-chat__settings.is-open {
    display: flex;
}

.rl-chat__settings-card {
    width: 100%;
    max-width: 420px;
    max-height: 100%;
    overflow: auto;
    background: var(--chat-white);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--chat-shadow);
}

.rl-chat__settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}

.rl-chat__settings-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--chat-text);
}

.rl-chat__settings-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--chat-grey-bg);
    color: var(--chat-text);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.rl-chat__settings-close svg {
    width: 16px;
    height: 16px;
}

.rl-chat__settings-check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.4;
    color: var(--chat-text);
    cursor: pointer;
}

.rl-chat__settings-check input {
    margin-top: 2px;
    flex-shrink: 0;
}

.rl-chat__settings-message {
    width: 100%;
    min-height: 120px;
    resize: vertical;
    border: 1px solid var(--chat-grey-line);
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
    font-size: 14px;
    line-height: 1.45;
    color: var(--chat-text);
    background: var(--chat-grey-bg);
}

.rl-chat__settings-message:focus {
    outline: none;
    border-color: var(--chat-orange);
    background: var(--chat-white);
    box-shadow: 0 0 0 3px rgba(255,148,0,.12);
}

.rl-chat__settings-hint {
    margin-top: 8px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--chat-grey-text);
}

.rl-chat__settings-status {
    min-height: 18px;
    margin-top: 8px;
    font-size: 13px;
    color: var(--chat-navy-mid);
}

.rl-chat__settings-save {
    margin-top: 8px;
    border: none;
    border-radius: 10px;
    background: var(--chat-orange);
    color: #fff;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    padding: 10px 16px;
    cursor: pointer;
}

.rl-chat__settings-save:hover {
    background: var(--chat-orange-dark);
}

.rl-chat__settings-save:disabled {
    opacity: .6;
    cursor: default;
}

/* Filter tabs */
.rl-chat__filters {
    display: flex;
    gap: 8px;
    padding: 7px 8px 6px;
    border-bottom: 1px solid var(--chat-grey-line);
    flex-shrink: 0;
}

.rl-chat__filter {
    flex: 1;
    padding: 4px 6px;
    border: 1.5px solid var(--chat-grey-line);
    border-radius: 8px;
    background: var(--chat-white);
    font-size: 11px;
    font-weight: 600;
    color: var(--chat-grey-text);
    cursor: pointer;
    text-align: center;
    transition: all .15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.rl-chat__filter:hover {
    border-color: var(--chat-orange);
    color: var(--chat-orange);
    background: var(--chat-orange-light);
}

.rl-chat__filter--active {
    background: var(--chat-orange);
    border-color: var(--chat-orange);
    color: var(--chat-white);
}

/* Conversation list */
.rl-chat__conv-list {
    flex: 1;
    overflow-y: auto;
    padding: 5px 0 4px;
}

.rl-chat__conv-list::-webkit-scrollbar { width: 4px; }
.rl-chat__conv-list::-webkit-scrollbar-thumb {
    background: var(--chat-grey-line);
    border-radius: 2px;
}

.rl-chat__no-conv {
    padding: 12px 9px;
    text-align: center;
    color: var(--chat-grey-text);
    font-size: 13px;
    line-height: 1.5;
}

/* Conversation item */
.rl-chat__conv-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 7px 8px 7px 7px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background .12s, border-color .12s;
    border-bottom: 1px solid var(--chat-grey-line);
}

.rl-chat__conv-item:last-child {
    border-bottom: none;
}

.rl-chat__conv-item:hover {
    background: var(--chat-grey-bg);
}

.rl-chat__conv-item--active {
    background: var(--chat-orange-light);
    border-left-color: var(--chat-orange);
}

.rl-chat__ci-thumb {
    width: 46px;
    height: 46px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    background: var(--chat-grey-bg);
}

.rl-chat__ci-thumb--placeholder {
    background: var(--chat-grey-line);
}

.rl-chat__ci-body {
    flex: 1;
    min-width: 0;
    padding-right: 2px;
}

.rl-chat__ci-title {
    display: block;
    font-weight: 600;
    font-size: 12.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--chat-text);
    line-height: 1.4;
}

.rl-chat__ci-name {
    display: block;
    font-size: 10.5px;
    color: var(--chat-orange-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
    line-height: 1.35;
}

.rl-chat__ci-preview {
    display: block;
    font-size: 11.5px;
    color: var(--chat-grey-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 3px;
    line-height: 1.35;
}

.rl-chat__ci-preview--system {
    color: #8a5a00;
}

.rl-chat__ci-system-label {
    font-weight: 700;
    color: var(--chat-orange-dark);
}

.rl-chat__ci-right {
    display: flex;
    align-items: center;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

.rl-chat__ci-status {
    font-size: 10px;
    line-height: 1.2;
    color: var(--chat-grey-text);
    text-align: center;
}

.rl-chat__ci-status--read {
    color: var(--chat-orange);
    font-weight: 600;
}

.rl-chat__ci-check {
    width: 14px;
    height: 14px;
}

.rl-chat__ci-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 3px;
    border-radius: 10px;
    background: var(--chat-orange);
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
}

/* Loading spinner block */
.rl-chat__loading {
    display: flex;
    justify-content: center;
    padding: 12px 0;
}

/* ── Main chat area ─────────────────────────────────────────────────── */
.rl-chat__main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--chat-grey-bg);
}

.rl-chat__empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 20px 16px;
    color: var(--chat-grey-text);
    text-align: center;
    font-size: 13.5px;
    line-height: 1.6;
}

.rl-chat__empty svg {
    width: 64px;
    height: 64px;
    opacity: .25;
}

.rl-chat__active {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Conversation header — white bar with estate info */
.rl-chat__conv-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 10px 8px;
    border-bottom: 1px solid var(--chat-grey-line);
    background: var(--chat-white);
    flex-shrink: 0;
    min-height: 72px;
}

.rl-chat__conv-actions {
    display: none;
    flex-shrink: 0;
}

.rl-chat__conv-actions--right {
    margin-left: auto;
}

.rl-chat__mobile-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: var(--chat-grey-bg);
    color: var(--chat-navy);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.rl-chat__mobile-btn:hover {
    background: var(--chat-orange-light);
    color: var(--chat-orange-dark);
}

.rl-chat__mobile-btn svg {
    width: 18px;
    height: 18px;
}

.rl-chat__conv-thumb-link {
    flex-shrink: 0;
}

.rl-chat__conv-thumb {
    width: 56px;
    height: 44px;
    object-fit: cover;
    border-radius: 8px;
    background: var(--chat-grey-bg);
    flex-shrink: 0;
    border: 1px solid var(--chat-grey-line);
}

.rl-chat__conv-meta {
    min-width: 0;
    flex: 1;
}

.rl-chat__conv-title {
    display: block;
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--chat-navy);
    line-height: 1.4;
    padding-bottom: 1px;
}

.rl-chat__conv-title,
.rl-chat__conv-title:hover,
.rl-chat__conv-title:focus {
    text-decoration: none;
    color: var(--chat-navy);
}

.rl-chat__conv-specs {
    font-size: 12px;
    color: var(--chat-grey-text);
    margin-top: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
}

.rl-chat__presence--online {
    color: #2e7d32;
    font-weight: 600;
}

.rl-chat__presence--offline {
    color: #c62828;
    font-weight: 600;
}

/* Fraud prevention alert */
.rl-chat__fraud-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    position: relative;
    margin: 6px 7px 2px;
    padding: 5px 28px 5px 7px;
    background: #fff8e1;
    border: 1px solid #ffd54f;
    border-left: 3px solid var(--chat-orange);
    border-radius: 8px;
    font-size: 12px;
    color: #5a4200;
    flex-shrink: 0;
    line-height: 1.45;
}

.rl-chat__fraud-close {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 18px;
    height: 18px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #7a6200;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.rl-chat__fraud-close:hover,
.rl-chat__fraud-close:focus {
    color: var(--chat-navy);
    background: rgba(28, 18, 48, 0.08);
    outline: none;
}

.rl-chat__fraud-close svg {
    width: 14px;
    height: 14px;
}

.rl-chat__fraud-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--chat-orange);
    margin-top: 1px;
}

.rl-chat__fraud-alert strong {
    display: block;
    font-size: 12.5px;
    font-weight: 700;
    margin-bottom: 3px;
    color: var(--chat-navy);
}

.rl-chat__fraud-alert p {
    margin: 0;
    line-height: 1.4;
}

/* Messages scroll container */
.rl-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--chat-grey-bg);
}

.rl-chat__messages::-webkit-scrollbar { width: 5px; }
.rl-chat__messages::-webkit-scrollbar-thumb {
    background: var(--chat-grey-line);
    border-radius: 3px;
}

.rl-chat__loading-msg {
    display: flex;
    justify-content: center;
    padding: 12px 0;
}

/* Message bubbles */
.rl-chat__msg {
    display: flex;
    flex-direction: column;
    max-width: 76%;
}

.rl-chat__msg--mine {
    align-self: flex-end;
    align-items: flex-end;
}

.rl-chat__msg--theirs {
    align-self: flex-start;
    align-items: flex-start;
}

.rl-chat__msg--system {
    align-self: center;
    align-items: center;
    max-width: 88%;
}

.rl-chat__bubble {
    padding: 6px 9px;
    border-radius: 18px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
    white-space: pre-wrap;
}

.rl-chat__msg--mine .rl-chat__bubble {
    background: var(--chat-navy);
    color: #fff;
    border-bottom-right-radius: 5px;
}

.rl-chat__msg--theirs .rl-chat__bubble {
    background: var(--chat-white);
    color: var(--chat-text);
    border-bottom-left-radius: 5px;
    border: 1px solid var(--chat-grey-line);
}

.rl-chat__bubble--system {
    background: #fff7e8;
    color: #5a4200;
    border: 1px solid #ffd7a1;
    border-radius: 12px;
    text-align: left;
    box-shadow: 0 2px 8px rgba(255, 148, 0, .08);
}

.rl-chat__system-label {
    display: block;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
    color: var(--chat-orange-dark);
    margin-bottom: 4px;
}

.rl-chat__system-text {
    display: block;
}

.rl-chat__time {
    font-size: 10.5px;
    color: var(--chat-grey-text);
    margin-top: 4px;
    padding: 0 2px;
}

.rl-chat__meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.rl-chat__msg--mine .rl-chat__meta {
    justify-content: flex-end;
}

.rl-chat__msg--theirs .rl-chat__meta {
    justify-content: flex-start;
}

.rl-chat__msg--system .rl-chat__meta {
    justify-content: center;
}

.rl-chat__status {
    font-size: 10.5px;
    color: var(--chat-grey-text);
}

.rl-chat__status--read {
    color: var(--chat-orange);
    font-weight: 600;
}

.rl-chat__error {
    text-align: center;
    color: #c0392b;
    font-size: 13px;
    padding: 10px 9px;
    line-height: 1.5;
}

/* ── Message input area ─────────────────────────────────────────────── */
.rl-chat__input-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 7px 8px 8px;
    border-top: 1px solid var(--chat-grey-line);
    background: var(--chat-white);
    flex-shrink: 0;
}

.rl-chat__textarea {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    border: 1.5px solid var(--chat-grey-line);
    border-radius: 12px;
    padding: 5px 7px;
    font-size: 13.5px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color .15s, background .15s;
    background: var(--chat-grey-bg);
    line-height: 1.45;
    color: var(--chat-text);
    overflow-y: auto;
}

.rl-chat__textarea:focus {
    border-color: var(--chat-orange);
    background: var(--chat-white);
    box-shadow: 0 0 0 3px rgba(255,148,0,.12);
}

.rl-chat__textarea::placeholder {
    color: #b0a8c4;
}

@supports (-webkit-touch-callout: none) {
    .rl-chat__textarea {
        font-size: 16px;
    }
}

.rl-chat__send-btn {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border: none;
    border-radius: 12px;
    background: var(--chat-orange);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, transform .12s, box-shadow .15s;
    box-shadow: 0 3px 10px rgba(255,148,0,.35);
}

.rl-chat__send-btn:hover {
    background: var(--chat-orange-dark);
    transform: scale(1.06);
    box-shadow: 0 5px 16px rgba(255,148,0,.45);
}

.rl-chat__send-btn:active {
    transform: scale(.96);
}

.rl-chat__send-btn svg {
    width: 18px;
    height: 18px;
}

/* ── Spinner ────────────────────────────────────────────────────────── */
.rl-chat__spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 2.5px solid var(--chat-grey-line);
    border-top-color: var(--chat-orange);
    border-radius: 50%;
    animation: chatSpin .75s linear infinite;
}

@keyframes chatSpin {
    to { transform: rotate(360deg); }
}

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 920px) {
    #rl-chat-widget {
        --chat-popup-w: calc(100vw - 24px);
        --chat-popup-h: 78vh;
        --chat-sidebar-w: 230px;
        bottom: 18px;
        right: 12px;
    }

    .rl-chat__popup {
        height: min(var(--chat-popup-h), calc(100svh - 92px));
        max-height: calc(100svh - 92px);
    }
}

@media (max-width: 620px) {
    #rl-chat-widget {
        --chat-popup-w: 100vw;
        --chat-popup-h: 100svh;
        bottom: 18px;
    }

    body.product_product #rl-chat-widget,
    body.product_manufacturer_info #rl-chat-widget {
        bottom: 80px;
    }

    .rl-chat__popup {
        border-radius: 0;
        border: none;
        bottom: calc(var(--chat-toggle-sz) + 12px);
    }

    /* Stack sidebar / main as full-width layers on mobile */
    .rl-chat__popup {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
    }

    .rl-chat__sidebar {
        position: absolute;
        inset: 0;
        width: 100%;
        z-index: 2;
        transform: translateX(0);
        transition: transform .24s cubic-bezier(.16,1,.3,1);
    }

    .rl-chat--conv-open .rl-chat__sidebar {
        transform: translateX(-100%);
    }

    .rl-chat__main {
        width: 100%;
    }

    .rl-chat__conv-header {
        gap: 8px;
        padding: 8px 8px 8px;
    }

    .rl-chat__conv-actions {
        display: flex;
    }

    .rl-chat__conv-thumb {
        width: 44px;
        height: 38px;
    }

    .rl-chat__conv-meta {
        min-width: 0;
    }

    .rl-chat__messages {
        padding: 8px 8px 6px;
    }

    .rl-chat__input-row {
        padding: 6px 7px 7px;
    }
}
