/* Chat Support — full page + floating widget */

:root {
    --chat-accent: #0f766e;
    --chat-accent-soft: rgba(15, 118, 110, 0.1);
    --chat-border: #e2e8f0;
    --chat-bg: #f8fafc;
    --chat-mine: #0f766e;
    --chat-theirs: #ffffff;
}

.chat-app {
    display: grid;
    grid-template-columns: 320px 1fr;
    min-height: calc(100vh - 220px);
    background: #fff;
    border: 1px solid var(--chat-border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.06);
}

.chat-sidebar {
    border-right: 1px solid var(--chat-border);
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid var(--chat-border);
}

.chat-support-entry,
.chat-conversation-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    padding: 0.85rem 1.1rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.chat-support-entry:hover,
.chat-conversation-item:hover {
    background: var(--chat-accent-soft);
}

.chat-support-entry.is-active,
.chat-conversation-item.is-active {
    background: var(--chat-accent-soft);
    box-shadow: inset 3px 0 0 var(--chat-accent);
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: #e2e8f0;
    color: #475569;
    font-weight: 700;
    font-size: 0.85rem;
}

.chat-avatar-support {
    background: linear-gradient(135deg, #0f766e, #14b8a6);
    color: #fff;
}

.chat-entry-body {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.chat-entry-title {
    font-weight: 700;
    color: #0f172a;
    font-size: 0.9rem;
}

.chat-entry-sub {
    font-size: 0.75rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-sidebar-label {
    padding: 0.75rem 1.1rem 0.35rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #94a3b8;
}

.chat-conversation-list {
    flex: 1;
    overflow: auto;
    min-height: 0;
}

.chat-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background:
        radial-gradient(circle at top right, rgba(20, 184, 166, 0.08), transparent 40%),
        var(--chat-bg);
}

.chat-main-head {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--chat-border);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
}

.chat-messages,
.admin-support-messages {
    flex: 1;
    overflow: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 280px;
    max-height: calc(100vh - 360px);
}

.admin-support-detail {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
}

.admin-support-messages {
    max-height: none;
    flex: 1 1 auto;
    min-height: 240px;
}

.chat-bubble {
    max-width: min(78%, 520px);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.chat-bubble.is-mine {
    align-self: flex-end;
}

.chat-bubble.is-theirs {
    align-self: flex-start;
}

.chat-bubble-meta {
    font-size: 0.7rem;
    color: #94a3b8;
    padding: 0 0.35rem;
}

.chat-bubble.is-mine .chat-bubble-meta {
    text-align: right;
}

.chat-bubble-body {
    padding: 0.7rem 0.9rem;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.chat-bubble.is-mine .chat-bubble-body {
    background: var(--chat-mine);
    color: #fff;
    border-bottom-right-radius: 6px;
}

.chat-bubble.is-theirs .chat-bubble-body {
    background: var(--chat-theirs);
    color: #0f172a;
    border: 1px solid var(--chat-border);
    border-bottom-left-radius: 6px;
}

.chat-composer {
    display: flex;
    gap: 0.65rem;
    align-items: flex-end;
    padding: 0.9rem 1.1rem;
    border-top: 1px solid var(--chat-border);
    background: #fff;
}

.chat-composer textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--chat-border);
    border-radius: 14px;
    padding: 0.7rem 0.9rem;
    font-size: 0.9rem;
    max-height: 120px;
    background: #f8fafc;
}

.chat-composer textarea:focus {
    outline: none;
    border-color: #14b8a6;
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
    background: #fff;
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: var(--chat-accent);
    border-color: var(--chat-accent);
}

.chat-empty-inline {
    padding: 1.5rem;
    text-align: center;
    color: #94a3b8;
    font-size: 0.85rem;
}

/* Floating support widget */
.chat-fab {
    position: fixed;
    right: 1.35rem;
    bottom: 1.35rem;
    z-index: 1200;
    width: 58px;
    height: 58px;
    border-radius: 18px;
    border: 0;
    background: linear-gradient(145deg, #0f766e, #14b8a6);
    color: #fff;
    box-shadow: 0 12px 30px rgba(15, 118, 110, 0.35);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45rem;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    pointer-events: auto;
}

.chat-fab:hover {
    transform: translateY(-2px) scale(1.03);
    color: #fff;
    box-shadow: 0 16px 36px rgba(15, 118, 110, 0.4);
}

.chat-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.chat-fab-badge.is-on {
    display: inline-flex;
}

.chat-nav-badge {
    display: none;
    min-width: 18px;
    height: 18px;
    margin-left: auto;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

.chat-nav-badge.is-on {
    display: inline-flex;
}

.chat-widget {
    position: fixed;
    right: 1.35rem;
    bottom: 5.5rem;
    width: min(380px, calc(100vw - 1.5rem));
    height: min(520px, calc(100vh - 7rem));
    z-index: 1200;
    background: #fff;
    border-radius: 18px;
    border: 1px solid var(--chat-border);
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
    display: none;
    flex-direction: column;
    overflow: hidden;
    pointer-events: auto;
}

.chat-widget.is-open {
    display: flex;
}

.chat-widget-head {
    padding: 0.95rem 1rem;
    background: linear-gradient(135deg, #0f766e, #0d9488);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.chat-widget-head h6 {
    margin: 0;
    font-weight: 700;
}

.chat-widget-head small {
    opacity: 0.85;
}

.chat-widget-head .btn-close {
    filter: invert(1);
    opacity: 0.85;
}

.chat-widget-head-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-shrink: 0;
}

.visitor-chat-logout {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(0, 0, 0, 0.15);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.28rem 0.55rem;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
}

.visitor-chat-logout:hover {
    background: rgba(0, 0, 0, 0.28);
    color: #fff;
}

.visitor-chat-logout.d-none {
    display: none !important;
}

.visitor-chat-logout i {
    font-size: 0.95rem;
}

.chat-widget .chat-messages {
    max-height: none;
    flex: 1;
}

.chat-widget-link {
    display: block;
    text-align: center;
    font-size: 0.75rem;
    padding: 0.35rem;
    border-top: 1px solid var(--chat-border);
    color: #0f766e;
    text-decoration: none;
    background: #f8fafc;
}

.chat-widget-link:hover {
    background: #f1f5f9;
    color: #0d9488;
}

.visitor-chat-gate {
    padding: 1.15rem 1.1rem 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background:
        radial-gradient(ellipse at top right, rgba(20, 184, 166, 0.12), transparent 55%),
        linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.visitor-chat-otp {
    padding: 1.15rem 1.1rem 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.visitor-chat-otp.d-none,
.visitor-chat-gate.d-none {
    display: none !important;
}

.visitor-otp-input {
    font-size: 1.35rem !important;
    letter-spacing: 0.35em;
    font-weight: 700;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.visitor-chat-gate-copy {
    font-size: 0.875rem;
    color: #475569;
    margin-bottom: 1rem;
    line-height: 1.45;
}

.visitor-chat-gate-form .form-label {
    font-weight: 600;
    color: #334155;
}

.visitor-chat-room {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.visitor-chat-room.d-none {
    display: none !important;
}

.admin-support-fab-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    background: var(--chat-bg);
}

.admin-support-fab-list .chat-support-entry {
    border-bottom: 1px solid var(--chat-border);
}

@media (max-width: 900px) {
    .chat-app {
        grid-template-columns: 1fr;
        min-height: calc(100vh - 180px);
    }

    .chat-sidebar {
        max-height: 240px;
        border-right: 0;
        border-bottom: 1px solid var(--chat-border);
    }
}
