/* ══════════════════════════════════════════════════════════════
   Chat — layout, estructura y animaciones.
   Sin hex / rgba aquí: todos los colores vienen de las variables
   declaradas en assets/brands/<brand>/css/skin.css.
   ══════════════════════════════════════════════════════════════ */

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

body {
    font-family: var(--font-family);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    color: var(--text);
}

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

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

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

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 14px;
    background: transparent;
    border: 1px solid var(--sidebar-divider-on-dark);
    border-radius: var(--radius-sm);
    color: var(--sidebar-text-strong);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}
.new-chat-btn:hover { background: var(--sidebar-hover); }
.new-chat-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-conversations {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.sidebar-section-title {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 8px 6px;
}

.conv-item {
    display: block;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--sidebar-text);
    font-family: inherit;
    font-size: 0.84rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conv-item:hover { background: var(--sidebar-hover); }
.conv-item.active { background: var(--sidebar-hover); color: var(--sidebar-text-strong); }

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

.sidebar-footer a {
    color: var(--text-muted);
    font-size: 0.78rem;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s;
}
.sidebar-footer a:hover { color: var(--sidebar-text); }

/* ── Main chat area ── */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
    min-width: 0;
}

/* ── Top bar ── */
.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--chat-bg);
    flex-shrink: 0;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text);
    padding: 4px;
}
.menu-toggle svg { width: 22px; height: 22px; }

.topbar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text);
}
.topbar-logo svg { width: 28px; height: 31px; color: var(--cube-color); }
.topbar-logo .wordmark {
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: -0.03em;
}
.topbar-logo .wordmark em {
    font-style: normal;
    color: var(--cube-color);
}

.topbar-badge {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--cube-color);
    background: var(--accent-soft);
    padding: 3px 8px;
    border-radius: 6px;
    letter-spacing: 0.02em;
}

/* ── Messages area ── */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.messages-inner {
    max-width: 768px;
    margin: 0 auto;
    padding: 24px 20px 100px;
}

/* ── Welcome screen ── */
.welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px 40px;
}

.welcome-logo {
    color: var(--cube-color);
}
.welcome-logo svg {
    width: 56px;
    height: 62px;
    margin-bottom: 20px;
}

.welcome h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.welcome p {
    color: var(--text-muted);
    font-size: 0.95rem;
    max-width: 460px;
    line-height: 1.5;
    margin-bottom: 36px;
}

.suggestions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    max-width: 600px;
}

.suggestion-btn {
    padding: 14px 16px;
    background: var(--chat-input-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.84rem;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1.45;
}
.suggestion-btn:hover {
    background: var(--chat-bg);
    border-color: var(--suggestion-hover-border);
    box-shadow: var(--suggestion-hover-shadow);
}

.suggestion-icon {
    display: inline-block;
    margin-right: 6px;
    opacity: 0.5;
}

/* ── Message bubbles ── */
.message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: fadeIn 0.25s ease;
}

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

.message.user { justify-content: flex-end; }

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 700;
}

.message.assistant .message-avatar {
    background: var(--assistant-avatar-bg);
    color: var(--assistant-avatar-color);
}

.message.user .message-avatar {
    background: var(--accent);
    color: var(--user-text);
    order: 2;
}

.message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-wrap;
}

.message.assistant .message-bubble {
    background: var(--assistant-bubble);
    color: var(--assistant-text);
    border-bottom-left-radius: 4px;
}

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

/* ── Typing indicator ── */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}
.typing-indicator span {
    width: 7px;
    height: 7px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.2s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.85); }
    30% { opacity: 1; transform: scale(1); }
}

/* ── Input area ── */
.input-area {
    position: sticky;
    bottom: 0;
    background: linear-gradient(transparent, var(--chat-bg) 20%);
    padding: 12px 20px 20px;
}

.input-wrapper {
    max-width: 768px;
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--chat-input-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 10px 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.input-wrapper:focus-within {
    border-color: var(--chat-input-focus-border);
    box-shadow: 0 0 0 3px var(--chat-input-focus-ring);
}

.input-wrapper textarea {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text);
    resize: none;
    min-height: 24px;
    max-height: 150px;
    line-height: 1.5;
}
.input-wrapper textarea::placeholder { color: var(--text-muted); }

.send-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--user-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, opacity 0.15s;
}
.send-btn:hover { background: var(--accent-light); }
.send-btn:disabled { opacity: 0.4; cursor: default; }
.send-btn svg { width: 18px; height: 18px; }

.input-hint {
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 8px;
    max-width: 768px;
    margin-left: auto;
    margin-right: auto;
}

/* ── Sidebar overlay (mobile) ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--sidebar-overlay);
    z-index: 49;
}
.sidebar-overlay.active { display: block; }

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

    .menu-toggle { display: block; }

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

    .message-bubble { max-width: 88%; }

    .welcome h1 { font-size: 1.3rem; }
}
