/* Orc Advisor - Visual Novel AI Chat */

.advisor-container {
    position: relative;
    z-index: 2;
    max-width: 1100px;
    margin: 0 auto;
    padding: 70px 1rem 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

/* ========== Main Layout ========== */

.advisor-layout {
    display: flex;
    gap: 1.2rem;
    flex: 1;
    min-height: 0;
    max-height: calc(100vh - 160px);
}

/* ========== Orc Panel ========== */

.orc-panel {
    flex: 0 0 38%;
    align-self: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.orc-portrait {
    width: 100%;
    max-width: 460px;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius-lg, 12px);
    transition: opacity 0.3s ease, filter 0.3s ease, transform 0.3s ease;
    filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.6));
}

.orc-portrait.idle {
    animation: orcBreathe 4s ease-in-out infinite;
}

.orc-portrait.thinking {
    animation: orcThink 2s ease-in-out infinite;
    filter: drop-shadow(0 0 25px rgba(212, 160, 23, 0.4));
}

.orc-portrait.talking {
    animation: orcTalk 0.6s ease-in-out infinite;
    filter: drop-shadow(0 0 15px rgba(212, 160, 23, 0.25));
}

@keyframes orcBreathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.015); }
}

@keyframes orcThink {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 25px rgba(212, 160, 23, 0.4)); }
    50% { transform: scale(1.01); filter: drop-shadow(0 0 35px rgba(212, 160, 23, 0.6)); }
}

@keyframes orcTalk {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

.orc-nameplate {
    font-family: var(--font-display, 'Cinzel', serif);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-accent, #D4A017);
    text-align: center;
    padding: 0.5rem 0;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

/* ========== Chat Panel ========== */

.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: rgba(28, 24, 18, 0.7);
    border: 1px solid rgba(138, 106, 58, 0.3);
    border-radius: var(--radius-lg, 12px);
    overflow: hidden;
    backdrop-filter: blur(4px);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(138, 106, 58, 0.4);
    border-radius: 3px;
}

.chat-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: rgba(248, 240, 224, 0.5);
    font-family: var(--font-body, 'Crimson Text', serif);
    font-size: 1.1rem;
    font-style: italic;
    text-align: center;
}

/* ========== Chat Messages ========== */

.chat-message {
    display: flex;
    max-width: 88%;
}

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

.chat-message.advisor {
    align-self: flex-start;
}

.message-bubble {
    padding: 0.65rem 1rem;
    border-radius: 10px;
    font-family: var(--font-body, 'Crimson Text', serif);
    font-size: 1.05rem;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.chat-message.user .message-bubble {
    background: rgba(138, 106, 58, 0.35);
    border: 1px solid rgba(138, 106, 58, 0.5);
    color: var(--color-text, #f8f0e0);
    border-bottom-right-radius: 3px;
}

.chat-message.advisor .message-bubble {
    background: rgba(30, 25, 18, 0.8);
    border: 1px solid rgba(212, 160, 23, 0.25);
    color: var(--color-text, #f8f0e0);
    border-bottom-left-radius: 3px;
}

.message-bubble .typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--color-accent, #D4A017);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: cursorBlink 0.7s step-end infinite;
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Thinking indicator */
.thinking-dots {
    display: inline-flex;
    gap: 4px;
    padding: 0.5rem 0;
}

.thinking-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-accent, #D4A017);
    animation: dotPulse 1.4s ease-in-out infinite;
}

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

@keyframes dotPulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* ========== Chat Input ========== */

.chat-input-bar {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    border-top: 1px solid rgba(138, 106, 58, 0.3);
    background: rgba(28, 24, 18, 0.5);
}

.chat-input-bar input {
    flex: 1;
    padding: 0.6rem 0.9rem;
    background: rgba(30, 25, 18, 0.8);
    border: 1px solid rgba(138, 106, 58, 0.4);
    border-radius: var(--radius-sm, 6px);
    color: var(--color-text, #f8f0e0);
    font-family: var(--font-body, 'Crimson Text', serif);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input-bar input:focus {
    border-color: var(--color-accent, #D4A017);
}

.chat-input-bar input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.chat-input-bar button {
    padding: 0.6rem 1.2rem;
    background: linear-gradient(135deg, rgba(138, 106, 58, 0.6), rgba(138, 106, 58, 0.8));
    border: 1px solid rgba(212, 160, 23, 0.4);
    border-radius: var(--radius-sm, 6px);
    color: var(--color-text, #f8f0e0);
    font-family: var(--font-display, 'Cinzel', serif);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.chat-input-bar button:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(138, 106, 58, 0.8), rgba(138, 106, 58, 1));
    border-color: var(--color-accent, #D4A017);
}

.chat-input-bar button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ========== Wallet Bar ========== */

.wallet-bar {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.7rem 1rem;
    margin-top: 0.8rem;
    background: rgba(28, 24, 18, 0.6);
    border: 1px solid rgba(138, 106, 58, 0.25);
    border-radius: var(--radius-lg, 12px);
    backdrop-filter: blur(4px);
}

.wallet-status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--font-body, 'Crimson Text', serif);
    font-size: 0.9rem;
    color: rgba(248, 240, 224, 0.7);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(248, 240, 224, 0.3);
    transition: background 0.3s;
}

.wallet-status.connected .status-dot {
    background: #4ade80;
    box-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
}

.wallet-btn {
    padding: 0.45rem 1rem;
    background: linear-gradient(135deg, rgba(138, 106, 58, 0.5), rgba(138, 106, 58, 0.7));
    border: 1px solid rgba(212, 160, 23, 0.35);
    border-radius: var(--radius-sm, 6px);
    color: var(--color-text, #f8f0e0);
    font-family: var(--font-display, 'Cinzel', serif);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.wallet-btn:hover {
    background: linear-gradient(135deg, rgba(138, 106, 58, 0.7), rgba(138, 106, 58, 0.9));
    border-color: var(--color-accent, #D4A017);
}

.wallet-btn-disconnect {
    background: rgba(80, 30, 30, 0.5);
    border-color: rgba(180, 60, 60, 0.3);
}

.wallet-btn-disconnect:hover {
    background: rgba(120, 40, 40, 0.6);
    border-color: rgba(200, 80, 80, 0.5);
}

/* ========== Wallet Modal (matches dao pattern) ========== */

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

.wallet-modal-card {
    background: rgba(20, 15, 10, 0.95);
    border: 1px solid rgba(138, 106, 58, 0.5);
    border-radius: var(--radius-lg, 12px);
    padding: 1.5rem;
    min-width: 300px;
    max-width: 400px;
}

.wallet-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-family: var(--font-display, 'Cinzel', serif);
    font-size: 1.1rem;
    color: var(--color-text, #f8f0e0);
}

.wallet-modal-close {
    background: none;
    border: none;
    color: rgba(248, 240, 224, 0.6);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 0.3rem;
}

.wallet-modal-close:hover {
    color: var(--color-text, #f8f0e0);
}

.wallet-modal-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.wallet-modal-option {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    width: 100%;
    padding: 0.8rem 1rem;
    background: rgba(30, 25, 18, 0.6);
    border: 1px solid rgba(138, 106, 58, 0.3);
    border-radius: var(--radius-sm, 6px);
    color: var(--color-text, #f8f0e0);
    font-family: var(--font-body, 'Crimson Text', serif);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.wallet-modal-option:hover {
    background: rgba(138, 106, 58, 0.3);
    border-color: var(--color-accent, #D4A017);
}

.wallet-modal-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
}

/* ========== Mobile Wallet Prompt ========== */

.mobile-wallet-prompt {
    text-align: center;
    padding: 1rem;
}

.mobile-wallet-prompt p {
    margin-bottom: 0.8rem;
    font-family: var(--font-body, 'Crimson Text', serif);
    color: var(--color-text, #f8f0e0);
}

.mobile-wallet-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.mobile-wallet-btn {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm, 6px);
    color: var(--color-text, #f8f0e0);
    font-family: var(--font-display, 'Cinzel', serif);
    font-size: 0.85rem;
    text-decoration: none;
    border: 1px solid rgba(138, 106, 58, 0.5);
    background: rgba(138, 106, 58, 0.3);
}

.mobile-wallet-btn:hover {
    background: rgba(138, 106, 58, 0.5);
}

/* ========== Error message ========== */

#errorMsg {
    display: none;
    padding: 0.8rem 1rem;
    background: rgba(180, 60, 60, 0.2);
    border: 1px solid rgba(180, 60, 60, 0.4);
    border-radius: var(--radius-sm, 6px);
    color: #f0a0a0;
    font-family: var(--font-body, 'Crimson Text', serif);
    font-size: 0.95rem;
    margin-top: 0.5rem;
}

/* ========== Footer ========== */

.advisor-footer {
    text-align: center;
    padding: 1.5rem 1rem 1.5rem;
    margin-top: auto;
    flex-shrink: 0;
}

.advisor-footer p {
    font-family: var(--font-body, 'Crimson Text', serif);
    color: rgba(248, 240, 224, 0.6);
    font-size: 0.9rem;
}

.advisor-footer a {
    color: var(--color-accent, #D4A017);
    text-decoration: none;
}

.advisor-footer a:hover {
    text-decoration: underline;
}

/* ========== Mobile ========== */

@media (max-width: 768px) {
    .advisor-container {
        padding-top: 60px;
    }

    .advisor-layout {
        flex-direction: column;
        max-height: none;
    }

    .orc-panel {
        flex: 0 0 auto;
        max-height: 200px;
    }

    .orc-portrait {
        max-width: 180px;
        max-height: 180px;
    }

    .orc-nameplate {
        font-size: 1rem;
        padding: 0.3rem 0;
    }

    .chat-panel {
        flex: 1;
        min-height: 300px;
    }

    .chat-messages {
        min-height: 250px;
    }

    .wallet-bar {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .message-bubble {
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    .advisor-container {
        padding: 55px 0.5rem 0.5rem;
    }

    .orc-panel {
        max-height: 150px;
    }

    .orc-portrait {
        max-width: 140px;
    }

    .chat-input-bar {
        padding: 0.5rem;
    }

    .chat-input-bar input {
        font-size: 0.9rem;
        padding: 0.5rem 0.7rem;
    }

    .chat-input-bar button {
        padding: 0.5rem 0.8rem;
        font-size: 0.75rem;
    }
}
