/**
 * NPC Chat Panel Styles
 * Right-side panel for AI NPC conversations (Barrin the Keeper).
 * Dark parchment aesthetic matching builder-chat.css.
 */

/* ─── Chat Panel ────────────────────────────── */
.npc-chat {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 480px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    background: rgba(26, 22, 16, 0.96);
    border-left: 1px solid #6B6155;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.5);
    transform: translateX(100%);
    transition: transform 0.25s ease;
    pointer-events: none;
    font-family: 'Inter', sans-serif;
}
.npc-chat.is-open {
    transform: translateX(0);
    pointer-events: auto;
}

/* ─── Header ────────────────────────────────── */
.npc-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(107, 97, 85, 0.5);
    background: rgba(42, 34, 21, 0.6);
    flex-shrink: 0;
}
.npc-chat__header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.npc-chat__header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.npc-chat__title {
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: #d4a853;
    letter-spacing: 0.5px;
}
.npc-chat__subtitle {
    font-size: 0.68rem;
    color: rgba(196, 181, 154, 0.4);
    letter-spacing: 0.3px;
}
.npc-chat__header-actions {
    display: flex;
    gap: 4px;
}
.npc-chat__plaque-btn,
.npc-chat__clear,
.npc-chat__close {
    background: none;
    border: none;
    color: rgba(196, 181, 154, 0.35);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 3px;
    transition: all 0.15s;
    line-height: 1;
}
.npc-chat__plaque-btn:hover,
.npc-chat__clear:hover,
.npc-chat__close:hover {
    color: #C4B59A;
    background: rgba(196, 181, 154, 0.08);
}
.npc-chat__plaque-btn {
    font-size: 14px;
    color: rgba(196, 181, 154, 0.45);
}
.npc-chat__plaque-btn:hover {
    color: #d4a853;
}

/* ─── Custom Action Buttons (per-NPC, e.g. Spar) */
.npc-chat__custom-actions {
    display: contents;
}
.npc-chat__action-btn {
    background: rgba(212, 168, 83, 0.08);
    border: 1px solid rgba(212, 168, 83, 0.25);
    color: #d4a853;
    font-size: 0.72rem;
    font-family: 'Georgia', serif;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 4px;
    transition: all 0.15s;
    line-height: 1;
    letter-spacing: 0.3px;
}
.npc-chat__action-btn:hover {
    background: rgba(212, 168, 83, 0.15);
    border-color: #d4a853;
    color: #e8c06a;
}

/* ─── Messages Area ─────────────────────────── */
.npc-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scrollbar-width: thin;
    scrollbar-color: #6B6155 transparent;
}
.npc-chat__messages::-webkit-scrollbar {
    width: 5px;
}
.npc-chat__messages::-webkit-scrollbar-track {
    background: transparent;
}
.npc-chat__messages::-webkit-scrollbar-thumb {
    background: #6B6155;
    border-radius: 3px;
}

/* ─── Welcome Message ───────────────────────── */
.npc-chat__welcome {
    text-align: center;
    padding: 32px 16px;
}
.npc-chat__welcome-icon {
    font-size: 24px;
    color: #d4a853;
    margin-bottom: 12px;
}
.npc-chat__welcome p {
    font-size: 0.8rem;
    color: rgba(196, 181, 154, 0.5);
    line-height: 1.6;
    margin: 0;
    font-style: italic;
}

/* ─── Message Bubbles ───────────────────────── */
.npc-chat__msg {
    display: flex;
    flex-direction: column;
    max-width: 95%;
}
.npc-chat__msg--user {
    align-self: flex-end;
}
.npc-chat__msg--assistant {
    align-self: flex-start;
}

.npc-chat__msg-label {
    font-size: 0.6rem;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    margin-bottom: 4px;
    padding: 0 2px;
}
.npc-chat__msg--user .npc-chat__msg-label {
    color: rgba(196, 181, 154, 0.3);
    text-align: right;
}
.npc-chat__msg--assistant .npc-chat__msg-label {
    color: rgba(212, 168, 83, 0.4);
}

.npc-chat__msg-content {
    font-size: 0.82rem;
    line-height: 1.65;
    padding: 10px 14px;
    border-radius: 8px;
}
.npc-chat__msg--user .npc-chat__msg-content {
    background: rgba(196, 181, 154, 0.1);
    color: #C4B59A;
    border: 1px solid rgba(196, 181, 154, 0.12);
}
.npc-chat__msg--assistant .npc-chat__msg-content {
    background: rgba(42, 34, 21, 0.5);
    color: rgba(196, 181, 154, 0.85);
    border: 1px solid rgba(107, 97, 85, 0.3);
}

/* ─── Markdown in NPC Messages ──────────────── */
.npc-chat__msg--assistant .npc-chat__msg-content p {
    margin: 0 0 8px;
}
.npc-chat__msg--assistant .npc-chat__msg-content p:last-child {
    margin-bottom: 0;
}
.npc-chat__msg--assistant .npc-chat__msg-content strong {
    color: #C4B59A;
    font-weight: 600;
}
.npc-chat__msg--assistant .npc-chat__msg-content em {
    font-style: italic;
    color: rgba(196, 181, 154, 0.7);
}

/* ─── Typing Indicator ──────────────────────── */
.npc-chat__typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    align-self: flex-start;
}
.npc-chat__typing-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #d4a853;
    animation: npc-chat-pulse 1.4s ease-in-out infinite;
}
.npc-chat__typing-dot:nth-child(2) { animation-delay: 0.2s; }
.npc-chat__typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes npc-chat-pulse {
    0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* ─── Input Area ────────────────────────────── */
.npc-chat__input {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 18px 14px;
    border-top: 1px solid rgba(107, 97, 85, 0.5);
    background: rgba(26, 22, 16, 0.8);
    flex-shrink: 0;
}
.npc-chat__input textarea {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(107, 97, 85, 0.4);
    border-radius: 6px;
    color: #C4B59A;
    font-size: 0.82rem;
    font-family: 'Inter', sans-serif;
    padding: 8px 12px;
    resize: none;
    min-height: 36px;
    max-height: 100px;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s;
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
}
.npc-chat__input textarea::placeholder {
    color: rgba(196, 181, 154, 0.25);
}
.npc-chat__input textarea:focus {
    border-color: rgba(212, 168, 83, 0.4);
}
.npc-chat__send {
    background: none;
    border: 1px solid rgba(212, 168, 83, 0.3);
    color: #d4a853;
    font-size: 14px;
    padding: 7px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1;
    flex-shrink: 0;
}
.npc-chat__send:hover {
    background: rgba(212, 168, 83, 0.1);
    border-color: #d4a853;
}
.npc-chat__send:disabled {
    opacity: 0.3;
    cursor: default;
}

/* ─── Error Message ─────────────────────────── */
.npc-chat__error {
    font-size: 0.75rem;
    color: #C47070;
    background: rgba(196, 112, 112, 0.08);
    border: 1px solid rgba(196, 112, 112, 0.2);
    padding: 8px 14px;
    border-radius: 6px;
    text-align: center;
}

/* ─── Responsive ────────────────────────────── */
@media (max-width: 600px) {
    .npc-chat {
        width: 100vw;
    }
}
