/* ================================================================
   DENAI AI — Dynamic Content Styles
   Hanya untuk elemen yang di-generate oleh JavaScript.
   Layout statis menggunakan Tailwind di index.html.
   ================================================================ */

:root {
    --primary:      #b7131a;
    --primary-dark: #db322f;
    --blue:         #4c56af;
    --surface:      #f8f9fc;
    --surface-low:  #f2f3f6;
    --border:       #e4beb9;
    --border-soft:  #e7e8eb;
    --text-1:       #191c1e;
    --text-2:       #5b403d;
    --text-3:       #9CA3AF;
    --shadow-sm:    0 4px 12px rgba(0,0,0,0.05);
    --shadow-md:    0 8px 24px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }

/* ================================================================
   STREAM CURSOR
   ================================================================ */
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
.stream-cursor {
    animation: blink 0.8s step-end infinite;
    font-weight: 300;
    color: var(--primary);
    margin-left: 2px;
}

/* ================================================================
   MESSAGES CONTAINER
   ================================================================ */
.messages-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 1rem;
}
.messages-container > * { width: 100%; max-width: 900px; margin: 0 auto; }
.messages-container::-webkit-scrollbar { width: 5px; }
.messages-container::-webkit-scrollbar-thumb { background: #e1e2e5; border-radius: 999px; }

/* ================================================================
   MESSAGE BUBBLES
   ================================================================ */
.msg {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.75rem;
    align-items: flex-start;
    width: 100%;
}
.msg.user-msg { flex-direction: row-reverse; }
/* Prevent user chat-column from stretching full width */
.msg.user-msg .chat-column { flex: 0 1 auto; max-width: calc(100% - 46px); }
/* Extra breathing room between user message and bot response */
.msg.user-msg + .msg.bot { margin-top: 1.5rem; }

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
}
.msg.bot .avatar    { background: #b7131a; color: #fff; }
.msg.user-msg .avatar { background: #2e3133; color: #f0f1f4; }

.chat-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.bubble {
    padding: 14px 18px;
    border-radius: 12px;
    word-break: break-word;
    font-size: 16px;
    line-height: 1.7;
}

/* Bot bubble — no card/bubble, plain text like Gemini */
.msg.bot .bubble {
    background: transparent;
    color: var(--text-1);
    border: none;
    box-shadow: none;
    border-radius: 0;
    flex: 1;
    min-width: 0;
    width: 100%;
    padding: 4px 0;
}

/* Thinking/processing bubble — restore white card even though it's inside .msg.bot */
.msg.bot .bubble.thinking-bubble {
    background: #ffffff;
    border: 1px solid #e7e8eb;
    border-radius: 14px;
    box-shadow: 0 4px 16px rgba(25,28,30,0.07);
    padding: 18px 20px;
    width: auto;
    flex: none;
}

/* User bubble — white pill/card, right-aligned, shrinks to content */
.msg.user-msg .bubble {
    background: #ffffff;
    color: var(--text-2);
    font-weight: 500;
    font-size: 16px;
    line-height: 1.6;
    text-align: left;
    padding: 12px 18px;
    width: fit-content;
    max-width: 560px;
    border: 1px solid #e7e8eb;
    border-radius: 18px 18px 4px 18px;
    box-shadow: var(--shadow-sm);
    align-self: flex-start;
}
/* Timestamp untuk user */
.msg.user-msg .msg-timestamp {
    display: block;
    font-size: 10px;
    font-weight: 700;
    color: #d1d5db;
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-top: 6px;
    text-align: left;
}

/* Bot bubble typography */
.msg.bot .bubble h1 {
    font-weight: 700; color: #b7131a; margin: 1.2rem 0 0.5rem; line-height: 1.3;
    font-size: 22px; border-bottom: 1px solid var(--border-soft); padding-bottom: 0.4rem; margin-top: 0;
}
.msg.bot .bubble h2 {
    font-weight: 700; color: #b7131a; margin: 1.2rem 0 0.5rem; line-height: 1.3; font-size: 20px;
}
.msg.bot .bubble h3 {
    font-weight: 700; color: #b7131a; margin: 1.1rem 0 0.4rem; line-height: 1.4; font-size: 18px;
}
.msg.bot .bubble p  { margin: 0.4rem 0; color: var(--text-1); }
.msg.bot .bubble p:first-child { margin-top: 0; }
.msg.bot .bubble p:last-child  { margin-bottom: 0; }
.msg.bot .bubble ul,
.msg.bot .bubble ol { margin: 0.4rem 0 0.4rem 1.25rem; }
.msg.bot .bubble li { margin-bottom: 0.3rem; color: var(--text-1); line-height: 1.6; }
.msg.bot .bubble li::marker { color: var(--primary); }
.msg.bot .bubble strong,
.msg.bot .bubble b  { font-weight: 600; color: var(--text-1); }
.msg.bot .bubble code {
    background: #f0f1f4;
    color: var(--primary);
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'Fira Code', monospace;
}
.msg.bot .bubble pre {
    background: #f8f9fc;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    padding: 1rem;
    overflow-x: auto;
    margin: 0.75rem 0;
}
.msg.bot .bubble pre code { background: none; padding: 0; color: var(--text-1); font-size: 12px; }
.msg.bot .bubble .section {
    margin: 0.75rem 0;
    padding: 0.875rem 1rem;
    background: rgba(183,19,26,.03);
    border-left: 3px solid var(--primary);
    border-radius: 0 8px 8px 0;
}

/* Tables */
.msg.bot .bubble table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 0.75rem 0; }
.msg.bot .bubble th   { background: rgba(183,19,26,.05); color: #b7131a; font-weight: 600; padding: 0.6rem 0.875rem; text-align: left; border-bottom: 1px solid var(--border-soft); }
.msg.bot .bubble td   { padding: 0.6rem 0.875rem; border-bottom: 1px solid var(--border-soft); color: var(--text-1); }

/* HR text intro */
.hr-text-intro { margin-bottom: 10px; font-size: 14px; line-height: 1.6; color: var(--text-1); }
.hr-text-intro p { margin: 0.2rem 0; }
.analytics-query-title { margin: 0 !important; font-size: 14px !important; font-weight: 600; color: #b7131a; }

/* Data / Chart result blocks */
.data-result,
.chart-result,
.sql-action {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 4px;
}

/* Analytics rendered inline inside a streaming bubble */
.bubble-analytics-sep {
    border: none;
    border-top: 1px solid #e7e8eb;
    margin: 16px 0 12px;
}
.data-result--inline {
    padding-top: 0;
    max-width: 100%;
}
.data-result--inline .hr-stat-card,
.data-result--inline .hr-table-card-enhanced {
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid #e7e8eb;
}

/* System note */
.chat-system-note {
    font-size: 11px;
    color: var(--text-3);
    background: rgba(0,0,0,0.03);
    padding: 5px 10px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
    font-weight: 500;
    border: 1px solid rgba(0,0,0,0.05);
}

/* ================================================================
   FEEDBACK FOOTER (inside bot bubble)
   ================================================================ */
.feedback-wrapper { display: flex; flex-direction: column; gap: 0; }

.feedback-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #e7e8eb;
}
.feedback-text {
    font-size: 12px;
    color: #9ca3af;
    font-style: italic;
    flex: 1;
}
.feedback-btns { display: flex; align-items: center; gap: 6px; }

.feedback-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: #f8f9fc;
    border: 1.5px solid #e7e8eb;
    border-radius: 8px;
    color: #9ca3af;
    cursor: pointer;
    transition: color .15s, background .15s, border-color .15s, transform .12s;
}
.feedback-btn svg { width: 15px; height: 15px; pointer-events: none; }
.feedback-btn:hover:not(:disabled) {
    background: #f0f1f4;
    border-color: #9ca3af;
    color: #191c1e;
    transform: scale(1.1);
}
.feedback-btn.thumbs-up.feedback-selected  { color: #16a34a; border-color: #4ade80; background: #f0fdf4; }
.feedback-btn.thumbs-down.feedback-selected { color: #b7131a; border-color: #f87171; background: #fff1f1; }
.feedback-btn:disabled { cursor: default; opacity: 0.5; }

/* Comment box */
.feedback-comment-box {
    margin-top: 8px;
    padding: 10px;
    background: #fff8f8;
    border: 1px solid #fecaca;
    border-radius: 8px;
}
.feedback-comment-label { font-size: 12px; color: #9ca3af; margin: 0 0 6px 0; }
.feedback-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 10px;
    font-size: 12px;
    border: 1px solid #e7e8eb;
    border-radius: 6px;
    resize: vertical;
    font-family: inherit;
    outline: none;
    transition: border-color .15s;
}
.feedback-textarea:focus { border-color: #9ca3af; }
.feedback-comment-actions { display: flex; gap: 8px; margin-top: 8px; }
.feedback-send-btn {
    padding: 5px 14px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: background .15s;
    font-family: inherit;
}
.feedback-send-btn:hover:not(:disabled) { background: var(--primary-dark); }
.feedback-send-btn:disabled { opacity: 0.6; cursor: default; }
.feedback-cancel-btn {
    padding: 5px 10px;
    background: transparent;
    color: #9ca3af;
    border: 1px solid #e7e8eb;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
}
.feedback-cancel-btn:hover { background: #f0f1f4; }
.feedback-sent-msg { font-size: 12px; color: #16a34a; margin: 0; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

/* ================================================================
   SESSION LIST (Sidebar — di-generate oleh session-module.js)
   ================================================================ */
.session-section { display: flex; flex-direction: column; }
.starred-section { border-bottom: 1px solid #f0f1f4; padding-bottom: 0.75rem; margin-bottom: 0.75rem; }
.section-header {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #9CA3AF;
    padding: 0.4rem 0.5rem 0.6rem;
}
.session-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 9px 10px;
    margin-bottom: 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .12s;
    min-width: 0;
    font-family: 'Plus Jakarta Sans', sans-serif;
}
.session-item:hover { background: rgba(0,0,0,0.04); }
.session-item:hover .session-actions { opacity: 1; }
.session-item.active { background: rgba(183,19,26,.07); }
.session-item .title {
    flex: 1;
    font-size: 12px;
    color: #5b403d;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.4;
    font-weight: 500;
}
.session-item.active .title { font-weight: 600; color: #b7131a; }

.session-actions { display: flex; gap: 3px; flex-shrink: 0; opacity: 0; transition: opacity .15s; }
.session-action-btn {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 5px;
    color: #9CA3AF;
    cursor: pointer;
}
.session-action-btn svg { width: 13px; height: 13px; }
.session-action-btn.pin-btn:hover    { color: #f59e0b; background: rgba(245,158,11,.12); }
.session-action-btn.pin-btn.active   { color: #f59e0b; opacity: 1; }
.session-action-btn.delete-btn:hover { color: var(--primary); background: rgba(183,19,26,.1); }

.btn-show-more-sessions {
    width: 100%;
    padding: 7px 10px;
    margin-top: 4px;
    background: transparent;
    border: 1px dashed #e7e8eb;
    border-radius: 8px;
    color: #9CA3AF;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    transition: all .15s;
    font-family: 'Plus Jakarta Sans', sans-serif;
}
.btn-show-more-sessions:hover { background: #f2f3f6; color: #5b403d; border-color: #9CA3AF; }

/* ================================================================
   CALL MODE — Transcript log entries (di-generate oleh JS)
   ================================================================ */
.call-transcript-log { display: flex; flex-direction: column; gap: 1rem; }
.call-transcript-log::-webkit-scrollbar { width: 4px; }
.call-transcript-log::-webkit-scrollbar-thumb { background: #e7e8eb; border-radius: 999px; }

/* ================================================================
   MISC INPUT STATES (JS-controlled)
   ================================================================ */
.chat-input:disabled,
.landing-search-input:disabled { opacity: 0.6; }

/* Listening state for mic buttons */
.input-icon-btn.listening,
.landing-voice-btn.listening { color: var(--primary) !important; }


/* ================================================================
   SCHEMA MODAL (override untuk show/hide via JS)
   ================================================================ */
.schema-modal.open { display: flex !important; }
