/* ===== SignalAI House - Chat App (Scandinavian Light) ===== */

:root {
    --app-bg: #FAFAF8;
    --app-sidebar: #F5F3EF;
    --app-surface: #FFFFFF;
    --app-surface-hover: #F5F3EF;
    --app-border: rgba(0, 0, 0, 0.06);
    --app-primary: #5B8C6A;
    --app-primary-light: #6FA37E;
    --app-primary-dark: #4A7558;
    --app-text: #1a1a1a;
    --app-text-muted: #6b7280;
    --app-text-dim: #9ca3af;
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'DM Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--app-bg);
    color: var(--app-text);
    -webkit-font-smoothing: antialiased;
}

/* --- Layout --- */
.app-layout {
    display: flex;
    height: 100vh;
}

/* --- Sidebar --- */
.app-sidebar {
    width: 260px;
    background: var(--app-sidebar);
    border-right: 1px solid var(--app-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--app-border);
}

.sidebar-logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--app-text);
    letter-spacing: -0.5px;
    text-decoration: none;
    display: inline-block;
    margin-bottom: 16px;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    background: rgba(91, 140, 106, 0.08);
    border: 1px solid rgba(91, 140, 106, 0.15);
    border-radius: 10px;
    color: var(--app-primary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s ease;
}

.new-chat-btn:hover {
    background: rgba(91, 140, 106, 0.12);
    border-color: rgba(91, 140, 106, 0.25);
}

.sidebar-chats {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.sidebar-chats::-webkit-scrollbar {
    width: 4px;
}

.sidebar-chats::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.chat-history-item {
    padding: 12px;
    border-radius: 10px;
    color: var(--app-text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-history-item:hover,
.chat-history-item.active {
    background: var(--app-surface);
    color: var(--app-text);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--app-border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    background: rgba(91, 140, 106, 0.08);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: var(--app-text-muted);
}

.sidebar-user span {
    font-size: 0.85rem;
    color: var(--app-text-muted);
}

.sidebar-links {
    display: flex;
    gap: 16px;
}

.sidebar-links a {
    font-size: 0.8rem;
    color: var(--app-text-dim);
    text-decoration: none;
    transition: color 0.2s ease;
}

.sidebar-links a:hover {
    color: var(--app-primary);
}

/* --- Main Content --- */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--app-border);
    background: var(--app-surface);
}

.app-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--app-text);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--app-text);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px;
}

.model-badge {
    font-size: 0.75rem;
    padding: 4px 12px;
    background: var(--app-surface-hover);
    border: 1px solid var(--app-border);
    border-radius: 100px;
    color: var(--app-text-muted);
}

/* Messages Area */
.app-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    background: var(--app-bg);
}

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

.app-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 4px;
}

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

.empty-state-icon {
    width: 72px;
    height: 72px;
    background: rgba(91, 140, 106, 0.08);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    font-size: 2rem;
    animation: float 3s ease infinite;
}

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

.empty-state h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--app-text);
}

.empty-state p {
    color: var(--app-text-muted);
    margin-bottom: 32px;
}

.suggestions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    max-width: 500px;
}

.suggestion-card {
    padding: 16px;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 14px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    color: var(--app-text);
}

.suggestion-card:hover {
    border-color: rgba(91, 140, 106, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.suggestion-card h4 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--app-text);
}

.suggestion-card p {
    font-size: 0.75rem;
    color: var(--app-text-muted);
    margin: 0;
}

/* Dev notice */
.dev-notice {
    text-align: center;
    padding: 12px;
    font-size: 0.8rem;
    color: var(--app-text-dim);
    border-top: 1px solid var(--app-border);
}

.dev-notice strong {
    color: #D4A574;
}

/* Messages */
.message {
    display: flex;
    gap: 16px;
    padding: 20px 0;
    max-width: 768px;
    margin: 0 auto;
    width: 100%;
}

.message + .message {
    border-top: 1px solid var(--app-border);
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.85rem;
}

.message-avatar.bot {
    background: var(--app-primary);
    color: #fff;
}

.message-avatar.user {
    background: rgba(91, 140, 106, 0.08);
    color: var(--app-text-muted);
}

.message-body {
    flex: 1;
    min-width: 0;
}

.message-body p {
    line-height: 1.7;
    font-size: 0.95rem;
    color: var(--app-text);
}

.message-body code {
    background: var(--app-surface-hover);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-size: 0.85em;
}

.message-body pre {
    background: #1e293b;
    border: 1px solid var(--app-border);
    border-radius: 10px;
    padding: 16px;
    overflow-x: auto;
    margin: 12px 0;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: #e2e8f0;
}

/* Input Area */
.app-input {
    padding: 20px 24px;
    border-top: 1px solid var(--app-border);
    background: var(--app-surface);
}

.app-input-wrapper {
    max-width: 768px;
    margin: 0 auto;
    position: relative;
}

.app-input textarea {
    width: 100%;
    background: var(--app-bg);
    border: 1px solid var(--app-border);
    border-radius: 14px;
    padding: 14px 56px 14px 18px;
    color: var(--app-text);
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    outline: none;
    min-height: 52px;
    max-height: 200px;
    line-height: 1.5;
    transition: border-color 0.2s ease;
}

.app-input textarea:focus {
    border-color: var(--app-primary);
}

.app-input textarea::placeholder {
    color: var(--app-text-dim);
}

.app-send-btn {
    position: absolute;
    right: 12px;
    bottom: 10px;
    width: 36px;
    height: 36px;
    background: var(--app-primary);
    border: none;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

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

.app-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.app-disclaimer {
    text-align: center;
    padding: 8px;
    font-size: 0.72rem;
    color: var(--app-text-dim);
}

/* Typing indicator in chat */
.typing-indicator-app {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-indicator-app span {
    width: 7px;
    height: 7px;
    background: var(--app-primary);
    border-radius: 50%;
    animation: typingBounce 1.2s infinite;
}

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

@keyframes typingBounce {
    0%, 100% { transform: translateY(0); opacity: 0.4; }
    50% { transform: translateY(-5px); opacity: 1; }
}

/* Mobile overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.2);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
    }

    .app-sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: block;
    }

    .suggestions-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .app-messages {
        padding: 16px;
    }

    .message {
        gap: 12px;
    }

    .empty-state {
        padding: 20px;
    }
}
