/* Hera Syndulla Chatbot — Star Wars Dark Blue/Gold Theme */

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #0f1629;
    --bg-header: #07091a;
    --accent-gold: #c9a227;
    --accent-gold-dim: #8a6f1a;
    --bubble-hera: #1a2744;
    --bubble-user: #1e3a5f;
    --text-primary: #e8eaf0;
    --text-muted: #7a8299;
    --border: #1f2d4a;
    --danger: #c0392b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

#app {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
}

/* --- Header --- */

header {
    flex-shrink: 0;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    text-align: center;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
}

.header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center top;
    border: 1px solid var(--accent-gold-dim);
    flex-shrink: 0;
}

.header-content h1 {
    font-size: 1.1rem;
    letter-spacing: 3px;
    color: var(--accent-gold);
    font-weight: 600;
}

.star {
    color: var(--accent-gold);
    font-size: 0.9rem;
}

/* --- Empty State --- */

#empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 16px;
    padding: 24px;
    opacity: 0.85;
}

#empty-state img {
    width: min(300px, 78vw);
    border-radius: 16px;
    object-fit: cover;
}

#empty-state p {
    color: var(--accent-gold-dim);
    font-size: 0.85rem;
    font-style: italic;
    text-align: center;
    max-width: 300px;
    line-height: 1.5;
}

#empty-state.hidden {
    display: none;
}

/* --- Chat Container --- */

#chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    scroll-behavior: smooth;
}

#messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 700px;
    margin: 0 auto;
}

/* --- Chat Bubbles --- */

.message {
    max-width: 80%;
    display: flex;
    flex-direction: column;
}

.message-assistant {
    align-self: flex-start;
}

.message-user {
    align-self: flex-end;
}

.message-name {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent-gold);
    margin-bottom: 3px;
    padding-left: 4px;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 0.9rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.message-assistant .message-bubble {
    background: var(--bubble-hera);
    border-bottom-left-radius: 4px;
}

.message-user .message-bubble {
    background: var(--bubble-user);
    border-bottom-right-radius: 4px;
}

.message-timestamp {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 3px;
    padding: 0 4px;
}

.message-user .message-timestamp {
    text-align: right;
}

/* --- Game SVG (card / dice) --- */

.game-result {
    margin-top: 8px;
}

.game-result svg {
    max-width: 100px;
    height: auto;
}

/* --- Typing Indicator --- */

.typing-indicator {
    align-self: flex-start;
    display: flex;
    flex-direction: column;
}

.typing-dots {
    background: var(--bubble-hera);
    padding: 12px 18px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 5px;
    align-items: center;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing-pulse 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-pulse {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* --- Input Area --- */

#input-area {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-header);
    border-top: 1px solid var(--border);
}

#message-input {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 10px 16px;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
}

#message-input::placeholder {
    color: var(--text-muted);
}

#message-input:focus {
    border-color: var(--accent-gold-dim);
}

#send-btn, #clear-btn {
    border: none;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#send-btn {
    background: var(--accent-gold);
    color: var(--bg-primary);
}

#send-btn:hover {
    background: var(--accent-gold-dim);
}

#send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#clear-btn {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--border);
}

#clear-btn:hover {
    background: rgba(192, 57, 43, 0.15);
}

/* --- Scrollbar --- */

#chat-container::-webkit-scrollbar {
    width: 6px;
}

#chat-container::-webkit-scrollbar-track {
    background: transparent;
}

#chat-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* --- Confirm Modal --- */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    max-width: 320px;
    width: 90%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal p {
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.5;
    text-align: center;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-buttons button {
    padding: 8px 18px;
    border-radius: 8px;
    border: none;
    font-size: 0.9rem;
    cursor: pointer;
}

#modal-cancel {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border) !important;
}

#modal-cancel:hover {
    color: var(--text-primary);
}

#modal-confirm {
    background: var(--danger);
    color: #fff;
}

#modal-confirm:hover {
    opacity: 0.85;
}

/* --- Mobile responsive --- */

@media (max-width: 480px) {
    .message {
        max-width: 90%;
    }

    header {
        padding: 10px 12px;
    }

    .header-content h1 {
        font-size: 0.95rem;
        letter-spacing: 2px;
    }

    #input-area {
        padding: 10px 12px;
    }
}
