/* ── Trinetra Jyotish Chatbot Widget ── */

#cb-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}

/* ── FAB Button ── */
#cb-fab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #c8950a, #e8a820);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(200, 149, 10, 0.5);
    transition: transform 0.2s, box-shadow 0.2s;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    gap: 2px;
    padding: 0;
}
#cb-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(200, 149, 10, 0.65);
}
#cb-fab-icon { font-size: 1.5rem; line-height: 1; }
#cb-fab-label { font-size: 0.58rem; letter-spacing: 0.03em; }

/* ── Chat Panel ── */
#cb-panel {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 560px;
    max-width: calc(100vw - 32px);
    max-height: 620px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e8ddc8;
}

/* ── Header ── */
#cb-header {
    background: linear-gradient(135deg, #0b0b0f, #1a1a28);
    color: #f2f2f2;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
#cb-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
#cb-header-icon { font-size: 1.4rem; }
#cb-header-title {
    font-weight: 700;
    font-size: .9rem;
    color: #c8950a;
}
#cb-header-sub {
    font-size: .7rem;
    color: #aaa;
    margin-top: 1px;
}
#cb-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}
#cb-timer {
    font-size: .78rem;
    background: rgba(200,149,10,.15);
    padding: 3px 8px;
    border-radius: 12px;
    white-space: nowrap;
}
#cb-close {
    background: none;
    border: none;
    color: #aaa;
    font-size: 1rem;
    cursor: pointer;
    padding: 2px 4px;
    line-height: 1;
    border-radius: 4px;
    transition: color 0.15s;
}
#cb-close:hover { color: #fff; }

/* (top header email icon + mid-chat email form removed —
   emailing the transcript now happens in the end-of-session prompt,
   see .cb-end-email below) */

/* ── Body ── */
#cb-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ── Payment Gate ── */
#cb-gate {
    padding: 24px 20px;
    text-align: center;
    overflow-y: auto;
    flex: 1;
}
#cb-gate-icon { font-size: 2.5rem; margin-bottom: 10px; }
#cb-gate-title {
    font-size: 1rem;
    font-weight: 700;
    color: #3a2a00;
    margin-bottom: 8px;
}
#cb-gate-desc {
    font-size: .83rem;
    color: #555;
    line-height: 1.6;
    margin-bottom: 14px;
}
#cb-gate-features {
    list-style: none;
    padding: 0;
    margin: 0 0 18px;
    text-align: left;
}
#cb-gate-features li {
    font-size: .82rem;
    color: #444;
    padding: 4px 0;
    border-bottom: 1px solid #f0ead8;
}
#cb-gate-features li:last-child { border-bottom: none; }

.cb-btn-primary {
    background: linear-gradient(135deg, #c8950a, #e8a820);
    color: #fff;
    border: none;
    padding: 12px 28px;
    border-radius: 8px;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    transition: opacity 0.15s, transform 0.15s;
    box-shadow: 0 3px 12px rgba(200,149,10,.4);
}
.cb-btn-primary:hover:not(:disabled) {
    opacity: 0.92;
    transform: translateY(-1px);
}
.cb-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#cb-pay-note {
    font-size: .7rem;
    color: #999;
    margin-top: 8px;
}

.cb-info-box {
    background: #fff8e0;
    border: 1px solid #c8950a;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: .8rem;
    color: #7a5500;
    margin-bottom: 14px;
    text-align: left;
}

/* ── Chat Area ── */
#cb-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#cb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
#cb-messages::-webkit-scrollbar { width: 4px; }
#cb-messages::-webkit-scrollbar-track { background: transparent; }
#cb-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

/* ── Messages ── */
.cb-msg {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 92%;
    animation: cbFadeIn 0.2s ease;
}
@keyframes cbFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.cb-msg-assistant { align-self: flex-start; }
.cb-msg-user      { align-self: flex-end; }
.cb-msg-system    { align-self: center; max-width: 100%; }

/* Row holding the icon + bubble; feedback thumbs sit below this, not beside it */
.cb-msg-row {
    display: flex;
    gap: 8px;
}
.cb-msg-user .cb-msg-row { flex-direction: row-reverse; }

.cb-msg-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.cb-msg-content {
    background: #f5f0e8;
    border-radius: 12px 12px 12px 2px;
    padding: 10px 12px;
    font-size: .83rem;
    line-height: 1.6;
    color: #222;
}
.cb-msg-content p { margin: 0 0 6px; }
.cb-msg-content p:last-child { margin: 0; }
.cb-msg-content ul { margin: 6px 0; padding-left: 18px; }
.cb-msg-content li { margin-bottom: 3px; }
.cb-msg-content strong { color: #3a2a00; }

.cb-msg-user .cb-msg-content {
    background: linear-gradient(135deg, #c8950a, #e8a820);
    color: #fff;
    border-radius: 12px 12px 2px 12px;
}
.cb-msg-user .cb-msg-content strong { color: #fff8d0; }

.cb-msg-system .cb-msg-content {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #7a5500;
    border-radius: 8px;
    font-size: .78rem;
    text-align: center;
}

/* ── Typing indicator ── */
#cb-typing {
    padding: 8px 14px;
    display: flex;
    gap: 5px;
    align-items: center;
}
.cb-dot {
    width: 7px;
    height: 7px;
    background: #c8950a;
    border-radius: 50%;
    animation: cbBounce 1.2s infinite;
}
.cb-dot:nth-child(2) { animation-delay: 0.2s; }
.cb-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes cbBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%           { transform: translateY(-6px); opacity: 1; }
}

/* ── Input Footer ── */
#cb-footer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #e8ddc8;
    background: #fafaf5;
    flex-shrink: 0;
}
#cb-input {
    flex: 1;
    border: 1px solid #d0c090;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: .84rem;
    font-family: inherit;
    resize: none;
    outline: none;
    line-height: 1.5;
    max-height: 120px;
    overflow-y: auto;
    background: #fff;
    color: #222;
    transition: border-color 0.15s;
}
#cb-input:focus { border-color: #c8950a; }
#cb-input::placeholder { color: #aaa; }

#cb-send {
    background: linear-gradient(135deg, #c8950a, #e8a820);
    color: #fff;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity 0.15s, transform 0.15s;
}
#cb-send:hover {
    opacity: 0.88;
    transform: scale(1.05);
}

/* ── Direct Answer / Expandable Details ── */
.cb-direct-answer {
    font-size: .85rem;
    line-height: 1.6;
}
.cb-direct-answer p { margin: 0 0 6px; }
.cb-direct-answer p:last-child { margin: 0; }

.cb-toggle-detail {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    color: #c8950a;
    font-size: .76rem;
    font-weight: 700;
    cursor: pointer;
    padding: 6px 0 0;
    margin-top: 4px;
}
.cb-toggle-detail:hover { text-decoration: underline; }
.cb-toggle-icon {
    display: inline-block;
    transition: transform 0.15s;
    font-size: .7rem;
}

.cb-detail-box {
    margin-top: 8px;
    padding: 10px 12px;
    background: #fdfaf0;
    border-left: 3px solid #c8950a;
    border-radius: 0 8px 8px 0;
    font-size: .8rem;
    line-height: 1.6;
    color: #444;
}
.cb-detail-box p { margin: 0 0 6px; }
.cb-detail-box p:last-child { margin: 0; }
.cb-detail-box strong { color: #3a2a00; }

/* ── Per-message Thumbs Feedback ── */
.cb-feedback {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    margin-left: 28px;
}
.cb-thumb {
    background: none;
    border: 1px solid transparent;
    border-radius: 5px;
    font-size: .82rem;
    padding: 2px 6px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.15s, background 0.15s, border-color 0.15s;
}
.cb-thumb:hover { opacity: 1; background: #f5f0e8; }
.cb-thumb-active {
    opacity: 1;
    border-color: #c8950a;
    background: rgba(200,149,10,.12);
}
.cb-feedback-done .cb-thumb:not(.cb-thumb-active) {
    opacity: 0.2;
    pointer-events: none;
}

/* ── End-of-Session Star Rating ── */
.cb-star-prompt {
    align-self: center;
    text-align: center;
    background: #fff8e0;
    border: 1px solid #d0c090;
    border-radius: 12px;
    padding: 14px 20px;
    margin: 10px 0;
}
.cb-star-title {
    font-size: .85rem;
    font-weight: 700;
    color: #3a2a00;
    margin-bottom: 8px;
}
.cb-stars {
    display: flex;
    gap: 4px;
    justify-content: center;
}
.cb-star {
    font-size: 1.4rem;
    color: #ddd;
    cursor: pointer;
    transition: color 0.15s, transform 0.1s;
}
.cb-star:hover { transform: scale(1.15); }
.cb-star-filled { color: #f4c430; }
.cb-star-done .cb-star { pointer-events: none; }
.cb-star-thanks {
    margin-top: 8px;
    font-size: .8rem;
    color: #33aa33;
}

/* ── End-of-Session: email the transcript ── */
.cb-end-email {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #e8ddc8;
    text-align: left;
}
.cb-end-email-label {
    font-size: .82rem;
    font-weight: 700;
    color: #3a2a00;
    margin-bottom: 8px;
    text-align: center;
}
.cb-end-email-row {
    display: flex;
    gap: 8px;
}
.cb-end-email-input {
    flex: 1;
    border: 1px solid #d0c090;
    border-radius: 6px;
    padding: 7px 10px;
    font-size: .82rem;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
    background: #fff;
    color: #222;
}
.cb-end-email-input:focus { border-color: #c8950a; }
.cb-end-email-row .cb-btn-primary {
    flex-shrink: 0;
    padding: 7px 16px;
    font-size: .8rem;
    width: auto;
}
.cb-end-email-status {
    font-size: .76rem;
    margin-top: 6px;
    min-height: 14px;
    text-align: center;
}

/* ── Mobile ── */
@media (max-width: 480px) {
    #cb-widget {
        bottom: 16px;
        right: 16px;
    }
    #cb-panel {
        width: calc(100vw - 24px);
        right: -8px;
        max-height: 75vh;
    }
}
