/* PAGE */
.chat-page {
    height: calc(100vh - 64px); /* navbar safe */
    background: #f4f6f9;
}

/* CONTAINER */
.chat-container {
    display: flex;
    height: 100%;
}

/* SIDEBAR */
.chat-sidebar {
    width: 320px;
    background: #ffffff;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid #eee;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: #111;
    border-bottom: 1px solid #f1f1f1;
}

.chat-item.active,
.chat-item:hover {
    background: #eef2ff;
}

.avatar {
    width: 42px;
    height: 42px;
    background: #cfa21b;
    color: #fff;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 600;
}

.chat-meta .name {
    font-weight: 600;
}

.chat-meta .status {
    font-size: 12px;
    color: #6b7280;
}

/* MAIN */
.chat-main {
    flex: 1;
    display: flex;
}

/* Chat Access Form Styles */

/* Prevent overlap with navbar */
.chat-access-section {
    min-height: calc(100vh - 80px); /* navbar-safe */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 120px 16px 40px; /* top padding protects navbar */
    background: #0f0f0f;
}

/* Card */
.chat-access-card {
    width: 100%;
    max-width: 420px;
    background: #161616;
    padding: 32px;
    border-radius: 14px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6);
    text-align: center;
}

/* Heading */
.chat-access-card h2 {
    color: #cfa21b;
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 10px;
}

/* Subtitle */
.chat-access-card p {
    color: #bbb;
    font-size: 14px;
    margin-bottom: 24px;
}

/* Input */
.chat-access-card input {
    width: 100%;
    padding: 14px 16px;
    border-radius: 8px;
    border: 1px solid #2a2a2a;
    background: #0f0f0f;
    color: #fff;
    font-size: 15px;
    outline: none;
    transition: border-color 0.3s;
}

.chat-access-card input::placeholder {
    color: #777;
}

.chat-access-card input:focus {
    border-color: #cfa21b;
}

/* Button */
.chat-access-card button {
    width: 100%;
    margin-top: 18px;
    padding: 14px;
    border-radius: 8px;
    border: none;
    background: #cfa21b;
    color: #000;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition:
        background 0.3s,
        transform 0.2s;
}

.chat-access-card button:hover {
    background: #ddb633;
    transform: translateY(-1px);
}

/* Mobile tweak */
@media (max-width: 576px) {
    .chat-access-card {
        padding: 26px 20px;
    }
}

/* Message box */
.form-message {
    margin-top: 10px;
    font-size: 14px;
    padding: 10px 12px;
    border-radius: 6px;
}

.form-message.error {
    background: rgba(220, 53, 69, 0.15);
    color: #dc3545;
}

.form-message.success {
    background: rgba(40, 167, 69, 0.15);
    color: #28a745;
}

/* Button spinner */
#submitBtn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 3px solid rgba(0, 0, 0, 0.2);
    border-top-color: #000;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* MOBILE TRADER STRIP */
.mobile-trader-strip {
    padding: 12px 14px 16px;
    border-bottom: 1px solid #eee;
    background: #fff;
}

/* Horizontal scroll */
.trader-scroll {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scrollbar-width: none;
}

.trader-scroll::-webkit-scrollbar {
    display: none;
}

/* Trader bubble */
.trader-bubble {
    text-align: center;
    min-width: 72px; /* give name room */
    text-decoration: none;
    color: #111;
}

/* Avatar */
.bubble-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #f5f5f5;
    border: 2px solid #cfa21b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    margin: auto;
}

/* Active avatar */
.trader-bubble.active .bubble-avatar {
    background: #cfa21b;
    color: #fff;
}

/* 🔥 CLEAR, READABLE NAME */
.bubble-name {
    display: block;
    margin-top: 8px;
    font-size: 13px; /* bigger */
    font-weight: 600; /* bolder */
    color: #333; /* higher contrast */
    line-height: 1.25;
    max-width: 72px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* clean cut */
}

/* Active trader name highlight */
.trader-bubble.active .bubble-name {
    color: #cfa21b;
    font-weight: 700;
}

.mobile-trader-strip {
    position: fixed;
    top: 70px; /* below navbar */
    left: 0;
    right: 0;
    height: 80px;
    background: #fff;
    border-bottom: 1px solid #eee;
    z-index: 100;
}

/* -------------------------
   CHAT BOX CONTAINER
------------------------- */
.chat-box {
    display: flex;
    flex-direction: column;
    width: 100%;
    background: #f9fafb;
    height: 100vh;
}

/* -------------------------
   HEADER
------------------------- */
.chat-header {
    padding: 16px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
}

/* -------------------------
   BODY / MESSAGES
------------------------- */
.chat-body {
    flex: 1;
    padding: 24px 16px; /* Increased top/bottom padding for spacing */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    display: flex;
    margin-bottom: 12px;
}

.message.investor {
    justify-content: flex-end; /* Sent messages */
}

.message.trader {
    justify-content: flex-start; /* Received messages */
}

/* Message bubbles */
.bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 10px;
    background: #ffffff;
    font-size: 14px;
}

.message.investor .bubble {
    background: #cfa21b;
    color: #fff;
}

.message.trader .bubble {
    background: #fff;
    color: #1a202c;
}

.bubble span {
    display: block;
    font-size: 11px;
    opacity: 0.6;
    margin-top: 4px;
}

/* -------------------------
   FOOTER / INPUT AREA
------------------------- */

.chat-footer {
    position: sticky;
    bottom: 0;
    padding: 14px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    z-index: 20;
}

.chat-footer form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-footer input {
    flex: 1;
    padding: 12px 14px;
    border-radius: 22px;
    border: 1px solid #ddd;
}

.chat-footer button {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: #cfa21b;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
}

/* -------------------------
   EMPTY / PLACEHOLDER
------------------------- */
.chat-placeholder {
    margin: auto;
    text-align: center;
    color: #9ca3af;
}

/* =========================
   MOBILE ADJUSTMENTS
========================= */
@media (max-width: 768px) {
    /* Hide sidebar on mobile */
    .chat-sidebar {
        display: none;
    }

    /* Chat box full screen */
    .chat-box {
        position: relative;
        height: 100vh;
        background: #f9fafb;
        display: flex;
        flex-direction: column;
        padding-top: 12px; /* Top space for better spacing */
    }

    /* Header adjustments */
    .chat-header {
        flex-shrink: 0;
        padding: 14px 16px;
        background: #fff;
        border-bottom: 1px solid #e5e7eb;
        position: fixed;
        margin-top: 18%;
    }

    /* Body adjustments */
    .chat-body {
        flex: 1;
        height: calc(100vh - 72px - 90px); /* 72px header + 90px footer */
        padding: 40px 15px 90px; /* top padding and bottom space for footer */
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        gap: 16px;
        -webkit-overflow-scrolling: touch;
    }

    /* Footer adjustments */
    .chat-footer {
        position: sticky;
        bottom: 0;
        padding: 14px;
        background: #fff;
        border-top: 1px solid #e5e7eb;
        z-index: 20;
    }

    .chat-footer form {
        display: flex;
        gap: 10px;
        align-items: center;
    }

    .chat-footer input {
        flex: 1;
        padding: 12px 14px;
        font-size: 14px;
        border-radius: 22px;
    }

    .chat-footer button {
        width: 42px;
        height: 42px;
        border-radius: 50%;
        flex-shrink: 0;
    }

    /* Message bubbles */
    .bubble {
        max-width: 88%;
        font-size: 14px;
        line-height: 1.5;
        padding: 12px 14px;
    }
}
