/* ============================================================
   SE Real Estate — AI Property Chat Widget
   Fully self-contained, no dependency on SE AI Chat
   ============================================================ */

:root {
    --sere-chat-color: #2E486B;
}

/* ── Widget wrapper & positioning ──────────────────────────── */
.sere-chat-widget {
    position: fixed !important;
    bottom: 0 !important;
    right: 0 !important;
    top: auto !important;
    left: auto !important;
    width: 0 !important;
    height: 0 !important;
    z-index: 99999 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    transform: none !important;
}

/* Left */
.sere-chat-widget.sere-chat-left #sere-chat-bubble { right: auto !important; left: 24px !important; }
.sere-chat-widget.sere-chat-left #sere-chat-panel { right: auto !important; left: 24px !important; }

/* Centre */
.sere-chat-widget.sere-chat-centre { right: auto; left: 50%; transform: translateX(-50%); }

/* Top */
.sere-chat-widget.sere-chat-top { bottom: auto; top: 24px; }

/* ── Bubble button ──────────────────────────────────────────── */
#sere-chat-bubble {
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--sere-chat-color);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    transition: transform 0.2s, opacity 0.2s, box-shadow 0.2s;
    z-index: 99999 !important;
    overflow: hidden;
}

/* Sheen pseudo-element — swept by JS-injected animation */
#sere-chat-bubble::after {
    content: '';
    position: absolute;
    top: -20%;
    left: -75%;
    width: 50%;
    height: 140%;
    background: linear-gradient(
        105deg,
        rgba(255,255,255,0)    0%,
        rgba(255,255,255,0.38) 50%,
        rgba(255,255,255,0)    100%
    );
    transform: skewX(-15deg) translateX(0);
    pointer-events: none;
    opacity: 0;
}

#sere-chat-bubble:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(0,0,0,0.25); }
#sere-chat-bubble.sere-chat-bubble-hidden { transform: scale(0); opacity: 0; pointer-events: none; }

.sere-bubble-label {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1;
}

/* Centre bubble needs translateX preserved */
.sere-chat-centre #sere-chat-bubble { margin-left: -30px; }

/* ── Chat panel ─────────────────────────────────────────────── */
#sere-chat-panel {
    position: fixed !important;
    bottom: 92px !important;
    right: 24px !important;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 540px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.22s, transform 0.22s;
}

#sere-chat-panel.sere-chat-panel-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Left alignment */


/* Centre alignment */
.sere-chat-centre #sere-chat-panel { right: auto; left: 50%; transform: translateX(-50%) translateY(12px) scale(0.96); }
.sere-chat-centre #sere-chat-panel.sere-chat-panel-open { transform: translateX(-50%) translateY(0) scale(1); }

/* Top positioning — panel drops down */
.sere-chat-top #sere-chat-panel { bottom: auto; top: 72px; transform: translateY(-12px) scale(0.96); }
.sere-chat-top #sere-chat-panel.sere-chat-panel-open { transform: translateY(0) scale(1); }
.sere-chat-top.sere-chat-centre #sere-chat-panel { transform: translateX(-50%) translateY(-12px) scale(0.96); }
.sere-chat-top.sere-chat-centre #sere-chat-panel.sere-chat-panel-open { transform: translateX(-50%) translateY(0) scale(1); }

/* ── Header ─────────────────────────────────────────────────── */
#sere-chat-header {
    background: var(--sere-chat-color);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.sere-chat-header-info { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; overflow: hidden; }

.sere-chat-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.sere-chat-avatar img { width: 100%; height: 100%; object-fit: cover; }

.sere-chat-title  { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sere-chat-status { font-size: 11px; opacity: 0.8; margin-top: 1px; white-space: nowrap; }

#sere-chat-header button {
    background: rgba(255,255,255,0.15);
    border: none; color: #fff;
    width: 30px; height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s;
}

#sere-chat-header button:hover { background: rgba(255,255,255,0.3); }
#sere-chat-header > div:last-child { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Messages ───────────────────────────────────────────────── */
#sere-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.sere-chat-msg { display: flex; gap: 8px; max-width: 85%; }

.sere-chat-msg-assistant { align-self: flex-start; }
.sere-chat-msg-user      { align-self: flex-end; flex-direction: row-reverse; justify-content: flex-end; }

.sere-chat-avatar-wrap {
    width: 28px; height: 28px; flex-shrink: 0;
    border-radius: 50%;
    background: var(--sere-chat-color);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    margin-top: 2px;
}

.sere-chat-avatar-img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.sere-chat-msg-content {
    background: #f3f4f6;
    padding: 10px 13px;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    font-size: 13.5px;
    line-height: 1.55;
    color: #1f2937;
    word-break: break-word;
}

.sere-chat-msg-user .sere-chat-msg-content {
    background: var(--sere-chat-color);
    color: #fff;
    border-radius: 14px;
    border-bottom-right-radius: 4px;
}

/* ── Typing dots ────────────────────────────────────────────── */
.sere-typing-dots { display: flex; gap: 4px; padding: 2px 0; }
.sere-typing-dots span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #9ca3af;
    animation: sere-bounce 1.2s infinite;
}
.sere-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.sere-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes sere-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
    40%            { transform: translateY(-6px); opacity: 1; }
}

/* ── Input area ─────────────────────────────────────────────── */
#sere-chat-input-area {
    padding: 12px 14px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
    background: #fff;
}

#sere-chat-input-area:not(.sere-input-ready) {
    pointer-events: none;
    opacity: 0.5;
}

#sere-chat-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 13.5px;
    font-family: inherit;
    resize: none;
    outline: none;
    line-height: 1.4;
    max-height: 120px;
    overflow-y: auto;
    transition: border-color 0.15s;
}

#sere-chat-input:focus { border-color: var(--sere-chat-color); }

#sere-chat-send {
    width: 38px; height: 38px; flex-shrink: 0;
    background: var(--sere-chat-color);
    border: none; border-radius: 10px;
    color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.15s;
}

#sere-chat-send:hover { opacity: 0.85; }

/* ── GDPR box ───────────────────────────────────────────────── */
#sere-gdpr-box {
    margin: 12px 14px;
    padding: 14px;
    background: #fefce8;
    border: 1px solid #fde68a;
    border-radius: 10px;
    font-size: 13px;
    color: #1f2937;
}

#sere-gdpr-box button {
    padding: 8px 18px;
    border-radius: 8px;
    border: none;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

#sere-gdpr-accept {
    background: var(--sere-chat-color);
    color: #fff;
}

#sere-gdpr-decline {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #e5e7eb !important;
}

/* ── Property cards ─────────────────────────────────────────── */
.sere-chat-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.sere-chat-card {
    display: flex;
    gap: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.15s, border-color 0.15s;
}

.sere-chat-card:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,0.1);
    border-color: var(--sere-chat-color);
}

.sere-chat-card-img {
    width: 80px;
    min-height: 80px;
    object-fit: cover;
    flex-shrink: 0;
}

.sere-chat-card-img-placeholder {
    width: 80px;
    min-height: 80px;
    flex-shrink: 0;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
}

.sere-chat-card-body {
    padding: 8px 10px;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
    justify-content: center;
}

.sere-chat-card-title {
    font-size: 11.5px;
    font-weight: 700;
    color: #1a1d26;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sere-chat-card-price {
    font-size: 13px;
    font-weight: 700;
    color: var(--sere-chat-color);
}

.sere-chat-card-meta {
    font-size: 11px;
    color: #6b7280;
    display: flex;
    flex-wrap: wrap;
    gap: 3px 8px;
}

.sere-chat-card-status {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    background: #dcfce7;
    color: #15803d;
    margin-top: 2px;
    align-self: flex-start;
}

.sere-chat-card-status.rent    { background: #dbeafe; color: #1d4ed8; }
.sere-chat-card-status.sold,
.sere-chat-card-status.rented  { background: #f3f4f6; color: #6b7280; }

/* ── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 480px) {
    #sere-chat-panel { width: calc(100vw - 24px); }
    #sere-chat-bubble { bottom: 16px !important; right: 12px !important; }
    #sere-chat-panel { bottom: 88px !important; right: 12px !important; width: calc(100vw - 24px) !important; }
    .sere-chat-widget.sere-chat-left { right: auto; left: 12px; }
}
