/* CryptoBox Assistant - Mobile-first Chat UI */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0f1923;
    --bg-secondary: #1a2836;
    --bg-message-bot: #1e3448;
    --bg-message-user: #2563eb;
    --bg-header: #0d1520;
    --text-primary: #e8edf2;
    --text-secondary: #8899aa;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #22c55e;
    --border: #2a3a4a;
    --btn-primary: #3b82f6;
    --btn-primary-hover: #2563eb;
    --btn-secondary: #374a5e;
    --btn-secondary-hover: #445d75;
    --btn-danger: #ef4444;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-text-size-adjust: 100%;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 600px;
    margin: 0 auto;
}

/* Header */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 10;
}

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

.header-icon {
    font-size: 24px;
}

.header-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse 2s infinite;
}

.status-dot.offline {
    background: var(--btn-danger);
    animation: none;
}

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

/* Chat container */
#chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

#messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 8px;
}

/* Messages */
.message {
    max-width: 90%;
    animation: fadeIn 0.3s ease;
}

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

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

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

.message-bubble {
    padding: 12px 16px;
    border-radius: var(--radius);
    line-height: 1.5;
    font-size: 14px;
    word-wrap: break-word;
    white-space: pre-wrap;
}

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

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

/* Step image */
.step-image {
    width: 100%;
    max-width: 400px;
    border-radius: var(--radius-sm);
    margin-top: 10px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.2s;
}

.step-image:active {
    transform: scale(0.98);
}

/* Image lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    cursor: pointer;
}

.lightbox img {
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--radius-sm);
}

/* Remote keys highlight */
.remote-keys {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.remote-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    background: #2a3a4a;
    border: 1px solid #4a5a6a;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    color: #ccc;
    text-transform: uppercase;
}

/* Buttons area */
.buttons-area {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.btn {
    display: block;
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    line-height: 1.3;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.98);
}

.btn.primary {
    background: var(--btn-primary);
    color: white;
}

.btn.primary:hover {
    background: var(--btn-primary-hover);
}

.btn.secondary {
    background: var(--btn-secondary);
    color: var(--text-primary);
}

.btn.secondary:hover {
    background: var(--btn-secondary-hover);
}

.btn.danger {
    background: var(--btn-danger);
    color: white;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Language selector special layout */
.lang-buttons {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.lang-btn {
    flex: 1;
    padding: 14px 8px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
}

.lang-btn:hover, .lang-btn:active {
    border-color: var(--accent);
    background: var(--bg-message-bot);
}

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

.input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

#text-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#text-input:focus {
    border-color: var(--accent);
}

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

#send-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--btn-primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

#send-btn:hover {
    background: var(--btn-primary-hover);
}

/* Typing indicator */
.typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bg-message-bot);
    border-radius: var(--radius);
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Scrollbar */
#chat-container::-webkit-scrollbar {
    width: 4px;
}

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

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

/* Desktop adjustments */
@media (min-width: 601px) {
    #app {
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }

    body {
        background: #080e15;
    }
}

/* Small phones */
@media (max-height: 600px) {
    header {
        padding: 8px 12px;
    }

    .header-title {
        font-size: 14px;
    }

    #chat-container {
        padding: 10px;
    }

    .btn {
        padding: 10px 14px;
        font-size: 13px;
    }
}
