/* ============================================
   Vera Chat PWA - Styles
   Aesthetic: Dark, warm, intimate chat feel
   ============================================ */

:root {
    --bg-deep: #0a0a0f;
    --bg-surface: #12121a;
    --bg-raised: #1a1a25;
    --bg-input: #16161f;
    --border: #252533;
    --border-subtle: #1e1e2a;

    --text-primary: #e8e6e1;
    --text-secondary: #8a8898;
    --text-muted: #555566;

    --accent: #e8a44a;
    --accent-dim: #c4883a;
    --accent-glow: rgba(232, 164, 74, 0.12);

    --bubble-mine: #1c2a3a;
    --bubble-theirs: #1a1a25;

    --danger: #d94848;
    --success: #48b868;
    --online: #48d97a;

    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    --font-body: 'DM Sans', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg-deep);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

#app {
    height: 100%;
}

/* ---- App Shell ---- */
.app-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
}

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

.chat-header__left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header__avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--accent), var(--accent-dim));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: var(--bg-deep);
    flex-shrink: 0;
}

.chat-header__info h1 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.chat-header__status {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
}

.chat-header__status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--online);
    display: inline-block;
}

.chat-header__status.offline::before {
    background: var(--text-muted);
}

.chat-header__actions {
    display: flex;
    gap: 4px;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
}

.icon-btn:hover {
    background: var(--bg-raised);
    color: var(--text-primary);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

/* ---- Notification Banner ---- */
.notification-banner {
    display: none;
    padding: 10px 20px;
    background: var(--accent-glow);
    border-bottom: 1px solid rgba(232, 164, 74, 0.2);
    font-size: 13px;
    color: var(--accent);
    cursor: pointer;
    align-items: center;
    gap: 8px;
    transition: opacity 0.2s;
}

.notification-banner.visible {
    display: flex;
}

.notification-banner:hover {
    opacity: 0.85;
}

.notification-banner svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ---- Messages Area ---- */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

/* ---- Message Bubbles ---- */
.message {
    max-width: 80%;
    animation: messageIn 0.25s ease-out;
}

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

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

.message__bubble {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 14.5px;
    line-height: 1.5;
    word-wrap: break-word;
}

.message--mine .message__bubble {
    background: var(--bubble-mine);
    border-bottom-right-radius: 4px;
    color: var(--text-primary);
}

.message--theirs .message__bubble {
    background: var(--bubble-theirs);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.message__meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

.message--mine .message__meta {
    justify-content: flex-end;
}

/* ---- Day Divider ---- */
.day-divider {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    padding: 12px 0;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-weight: 500;
}

/* ---- Typing Indicator ---- */
.typing-indicator {
    display: none;
    align-self: flex-start;
    padding: 12px 16px;
    background: var(--bubble-theirs);
    border-radius: var(--radius-md);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-subtle);
    gap: 4px;
    align-items: center;
}

.typing-indicator.visible {
    display: flex;
}

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

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

/* ---- Composer ---- */
.chat-composer {
    padding: 12px 16px;
    padding-bottom: calc(12px + var(--safe-bottom));
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.chat-composer__inner {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 4px 4px 4px 16px;
    transition: border-color 0.15s;
}

.chat-composer__inner:focus-within {
    border-color: var(--accent-dim);
}

.chat-composer__input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 15px;
    padding: 8px 0;
    resize: none;
    max-height: 120px;
    line-height: 1.4;
}

.chat-composer__input::placeholder {
    color: var(--text-muted);
}

.chat-composer__send {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--accent);
    border: none;
    color: var(--bg-deep);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s;
    opacity: 0.4;
    pointer-events: none;
}

.chat-composer__send.active {
    opacity: 1;
    pointer-events: auto;
}

.chat-composer__send:hover {
    transform: scale(1.05);
}

.chat-composer__send svg {
    width: 18px;
    height: 18px;
    margin-left: 1px;
}

/* ---- Empty State ---- */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
    gap: 12px;
}

.empty-state__icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    background: var(--accent-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.empty-state__icon svg {
    width: 28px;
    height: 28px;
    color: var(--accent);
}

.empty-state__title {
    font-size: 18px;
    font-weight: 600;
}

.empty-state__subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ---- Connection Status Toast ---- */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    padding: 10px 20px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 500;
    z-index: 100;
    transition: transform 0.3s ease;
    pointer-events: none;
}

.toast.visible {
    transform: translateX(-50%) translateY(0);
}

.toast--success {
    background: var(--success);
    color: var(--bg-deep);
}

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

/* ---- Animations ---- */
@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* ---- Responsive ---- */
@media (min-width: 601px) {
    .app-shell {
        border-left: 1px solid var(--border-subtle);
        border-right: 1px solid var(--border-subtle);
    }
}
