/* ================= BASE ================= */

.chat-page {
    --header-offset: 0px;
    background: radial-gradient(circle at top, #1a131f 0%, #050307 55%);
    height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    color: #fff;
}

/* ================= HEADER ================= */

.chat-header {
    display: flex;
    align-items: center;
    background: #141016;
    border-bottom: 1px solid #0b090d;
    padding: 10px 14px;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.65);
    border-radius: 0 0 18px 18px;

    will-change: transform;
    transform: translateY(var(--header-offset));
    transition: transform 0.16s ease-out, box-shadow 0.16s ease-out;
}

.chat-page.scrolled .chat-header {
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

.chat-back {
    background: transparent;
    border: none;
    color: #f3c7ff;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.chat-back:hover {
    background: #211827;
    transform: translateX(-1px);
}

.chat-header-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 18px rgba(0, 0, 0, 0.6);
}

.chat-header-info {
    flex: 1;
    display: flex;
    min-width: 0;
    justify-content: space-between;
    align-items: center;
}

.chat-header-name-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.chat-header-name {
    font: 700 1.15rem 'Montserrat', Arial, sans-serif;
    color: #fff;
    letter-spacing: -0.03em;
}

.chat-status-info {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
}

.chat-header-status-online {
    width: 9px;
    height: 9px;
    background: #43ff88;
    border-radius: 50%;
    box-shadow: 0 0 4px rgba(67, 255, 136, 0.9);
}

.chat-header-status-text {
    color: #d8cfff;
    font-size: 0.88rem;
}

.name-and-status {
    display: flex;
    align-items: center;
    flex-direction: column;
}
/* --- upload indicator --- */

.chat-upload-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    font-size: 0.83rem;
    color: #d5c9f6;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.chat-upload-indicator.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.chat-upload-progress {
    flex: 0 0 78px;
    height: 3px;
    border-radius: 999px;
    background: #312535;
    overflow: hidden;
}

.chat-upload-progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #ff4eb6, #ffbdf1);
    transition: width 0.15s linear;
}

.chat-upload-progress-fill.error {
    background: #ff5b74;
}

.chat-send-btn.is-uploading svg {
    opacity: 0.3;
}

.chat-send-btn.is-uploading {
    position: relative;
}

.chat-send-btn.is-uploading::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    animation: chat-upload-spin 0.8s linear infinite;
}

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

/* ================= MESSAGES ================= */

.chat-messages {
    width: 100%;
    flex: 1 1 auto;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 10px 96px;
    box-sizing: border-box;
    min-height: 0;
    scroll-behavior: smooth;
}


.chat-msg {
    display: flex;
    opacity: 0;
    transform: translateY(6px);
    animation: chatMsgIn 0.18s ease-out forwards;
}

@keyframes chatMsgIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-msg.ai {
    justify-content: flex-start;
    padding-right: 40px;
}

.chat-msg.user {
    justify-content: flex-end;
    padding-left: 40px;
}

.btn-teh {
    background: linear-gradient(135deg, #ff4eb6, #bb5cff);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 8px;
    width: 100%
}

.button-wrapper {
    text-align: center;
}

/* bubble */

.chat-msg-bubble {
    position: relative;
    display: inline-block;
    max-width: 80vw;
    padding: 11px 72px 15px 16px;
    border-radius: 22px;
    font-size: 0.96rem;
    word-break: break-word;
    font-family: 'Montserrat', Arial, sans-serif;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}


.chat-msg-bubble.ai {
    background: #18131f;
    color: #f8f4ff;
    border-radius: 20px 20px 20px 6px;
}


.chat-msg-bubble.user {
    background: linear-gradient(135deg, #ff4eb6, #bb5cff);
    color: #fff;
    border-radius: 20px 20px 6px 20px;
}


.chat-msg.ai + .chat-msg.ai .chat-msg-bubble {
    border-top-left-radius: 6px;
    margin-top: 3px;
}

.chat-msg.user + .chat-msg.user .chat-msg-bubble {
    border-top-right-radius: 6px;
    margin-top: 3px;
}

.chat-msg.ai + .chat-msg.user,
.chat-msg.user + .chat-msg.ai {
    margin-top: 12px;
}


.bubble-text {
    display: block;
    min-width: 0;
    overflow-wrap: anywhere;
}

.bubble-meta {
    position: absolute;
    right: 10px;
    bottom: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    opacity: 0.85;
}

.chat-msg-time {
    font-size: 0.68rem;
    line-height: 1;
    white-space: nowrap;
}

.chat-msg-bubble.ai .chat-msg-time {
    color: #9b8fa9;
}

.chat-msg-bubble.user .chat-msg-time {
    color: #f7e6ff;
}

.chat-msg-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.chat-msg-ticks-wrapper {
    display: inline-block;
    position: relative;
}

.chat-msg-status {
    width: 14px;
    height: 14px;
    opacity: 0.9;
}

.second-tick {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}


.chat-msg-img {
    max-width: 240px;
    max-height: 340px;
    border-radius: 14px;
    overflow: hidden;
}

.chat-msg-img img,
.chat-msg-img video {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    border-radius: 14px;
    display: block;
}


/* typing bubble */

.chat-msg.typing .chat-msg-bubble {
    background: #18131f;
    color: #f8f4ff;
    min-width: 56px;
    max-width: 96px;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 20px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #bb8efd;
    opacity: 0.7;
    animation: typingBlink 1.2s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.22s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.44s;
}

@keyframes typingBlink {
    0%,
    100% {
        opacity: 0.6;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-4px);
    }
    60% {
        opacity: 0.6;
        transform: translateY(0);
    }
}

/* ================= INPUT BAR ================= */

.chat-input-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: #120e13;
    border-top: 1px solid #281822;
    z-index: 99;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.8);
}

.chat-plus-btn {
    height: 34px;
    width: 34px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #ff4eb6, #ff9af0);
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 18px rgba(255, 78, 182, 0.8);
}

.chat-input-wrap {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #221822;
    border-radius: 999px;
    padding: 7px 12px;
}

.chat-input {
    flex: 1 1 auto;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    color: #fff;
    font-size: 0.98rem;
    font-family: 'Montserrat', Arial, sans-serif;
    resize: none;
}

.chat-input::placeholder {
    color: #817282;
}

.chat-input:focus {
    background: #2c1e33;
    border-radius: 999px;
}

.token-balance-wrap {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #2f2533;
    font-size: 0.85rem;
    color: #fff;
}

.token-balance {
    font-weight: 500;
}

.chat-send-btn {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: #ff4eb6;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 0 18px rgba(255, 78, 182, 0.8);
}

.chat-send-btn:hover {
    background: #e03d9f;
}

.chat-send-btn svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}


.chat-plus-menu {
    position: absolute;
    bottom: 70px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #1e141f;
    padding: 10px 12px;
    border-radius: 16px;
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.7);
    z-index: 100;
    transform: translateY(12px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.22s ease;
}

.chat-plus-menu.show {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.plus-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    color: #fff;
    background: #2a1d2c;
    border: none;
    padding: 9px 14px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.18s, transform 0.12s;
}

.plus-item:hover {
    background: #3a2640;
    transform: translateX(3px);
}

/* ================= MODAL ================= */

.modal {
    position: fixed;
    z-index: 999;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-photo,
.modal-video {
    max-width: 95vw;
    max-height: 90vh;
    border-radius: 18px;
    box-shadow: 0 6px 64px rgba(0, 0, 0, 0.25);
}

.modal-video {
    display: none;
    background: #000;
}

.close-modal {
    position: absolute;
    top: 30px;
    right: 40px;
    color: #fff;
    font-size: 2.2rem;
    cursor: pointer;
    z-index: 2;
    text-shadow: 0 2px 12px #222;
}

.asterisks {
    color: #c64789;
}

.quotes {
    font-style: italic;
    color: white; /* Optional: keep white color for italic */
}

.round-brackets {
    color: pink;
}

i {
    font-style: italic;
}

.chat-msg-date-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
    font-size: 12px;
    color: rgba(255, 192, 203, 0.62);
    position: relative;
}

.chat-msg-date-separator::before,
.chat-msg-date-separator::after {
    content: "";
    flex-grow: 1;
    border-top: 0.5px solid rgba(255, 192, 203, 0.62);;
    margin: 0 10px;
}

.date-text {
    padding: 0 10px;
    position: relative;
    z-index: 1;
    font-size: 14px;
}

.media-placeholder {
    background: #000;
    color: #aaa;
    text-align: center;
    font-size: 18px;
    display: flex;
    justify-content: center;
    flex-direction: column;

    align-items: center;
    border-radius: 22px;
}

.media-placeholder-label {
    font-size: 12px;
    color: #c64789;
    text-align: center;
}

.chat-history-loader {
    width: 100%;
    text-align: center;
    padding: 8px 0 10px;
    display: none;
    color: #c64789;

}

.chat-history-loader .loading-icon {
    width: 26px;
    height: 26px;
    animation: spin 1s linear infinite;
}

.scroll-anchor {
    height: 1px;
    opacity: 0;
    pointer-events: none;
}