/* ============================================
   Ask OptionsPlay — Demo Chat Client
   ============================================ */

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-tertiary: #242736;
    --bg-hover: #2a2e3f;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --text-muted: #6b7280;
    --accent: #4f8ff7;
    --accent-hover: #3b7de6;
    --accent-glow: rgba(79, 143, 247, 0.15);
    --green: #34d399;
    --red: #f87171;
    --orange: #fbbf24;
    --border: #2d3040;
    --radius: 12px;
    --radius-sm: 8px;
    --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

/* ---- App Shell ---- */
.app-shell {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---- Chat Container ---- */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

/* ---- Header ---- */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand-text h1 {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-primary);
}

.brand-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-new-chat {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-new-chat:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.connected {
    background: rgba(52, 211, 153, 0.15);
    color: var(--green);
}

.status-badge.disconnected {
    background: rgba(248, 113, 113, 0.15);
    color: var(--red);
}

/* ---- Login Panel ---- */
.login-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    max-width: 420px;
    width: 100%;
    text-align: center;
}

.login-card h2 {
    font-size: 22px;
    margin-bottom: 8px;
}

.login-card p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
}

.login-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 20px;
}

.login-tabs .tab {
    flex: 1;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.login-tabs .tab.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.input-field {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-sans);
    outline: none;
    transition: border-color 0.15s;
}

.input-field:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-primary {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.error-msg {
    margin-top: 12px;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: rgba(248, 113, 113, 0.1);
    color: var(--red);
    font-size: 13px;
}

/* ---- Messages Area ---- */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scroll-behavior: smooth;
}

/* Scrollbar styling */
.messages-area::-webkit-scrollbar {
    width: 6px;
}

.messages-area::-webkit-scrollbar-track {
    background: transparent;
}

.messages-area::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* ---- Welcome Screen ---- */
.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    text-align: center;
    padding: 40px 20px;
}

.welcome-icon {
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.welcome-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.welcome-screen h2 {
    font-size: 24px;
    font-weight: 600;
}

.welcome-screen p {
    color: var(--text-secondary);
    font-size: 15px;
    max-width: 400px;
}

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 12px;
    max-width: 520px;
}

.chip {
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.chip:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--text-primary);
}

/* ---- Message Bubbles ---- */
.message {
    display: flex;
    gap: 12px;
    padding: 16px 0;
}

.message + .message {
    border-top: 1px solid rgba(45, 48, 64, 0.5);
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    text-transform: uppercase;
}

.message.user .message-avatar {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.message.assistant .message-avatar {
    background: var(--bg-tertiary);
    padding: 4px;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-text {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
    word-wrap: break-word;
}

.message-text strong {
    color: var(--accent);
    font-weight: 600;
}

.message-text h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 16px 0 8px 0;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.message-text h3:first-child {
    margin-top: 0;
}

.message-text h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    margin: 12px 0 6px 0;
}

.message-text ul, .message-text ol {
    margin: 8px 0;
    padding-left: 20px;
}

.message-text ol {
    list-style: decimal;
}

.message-text li {
    margin: 4px 0;
    color: var(--text-primary);
}

.message-text code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--orange);
}

.message-text hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 12px 0;
}

.message-text br + br {
    display: block;
    content: "";
    margin-top: 8px;
}

.message-meta {
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

/* ---- Tool Indicator ---- */
.tool-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 6px;
    background: var(--accent-glow);
    color: var(--accent);
    font-size: 12px;
    font-weight: 500;
    margin-top: 8px;
}

.tool-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--accent-glow);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ---- Typing Indicator ---- */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: pulse 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

/* ---- Input Area ---- */
.input-area {
    padding: 16px 24px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    transition: border-color 0.15s;
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-wrapper textarea {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-sans);
    line-height: 1.5;
    resize: none;
    outline: none;
    max-height: 150px;
    padding: 4px 0;
}

.input-wrapper textarea::placeholder {
    color: var(--text-muted);
}

.btn-send {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
}

.btn-send:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.btn-send:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.input-footer {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ---- Animations ---- */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 80%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    40% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ---- Blazor infrastructure ---- */
#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    width: 100%;
    z-index: 1000;
    padding: 12px;
    background: var(--red);
    color: white;
    text-align: center;
}

    #blazor-error-ui .reload, #blazor-error-ui .dismiss {
        color: white;
        margin-left: 8px;
    }
