/**
 * =====================================================
 * ZEUS - Estilos CSS
 * Design dark mode com glassmorphism e animações
 * =====================================================
 */

/* ============================================
   VARIÁVEIS CSS
   ============================================ */
:root {
    /* Cores principais */
    --color-bg-primary: #0a0a0f;
    --color-bg-secondary: #12121a;
    --color-bg-tertiary: #1a1a25;

    /* Cores de destaque */
    --color-accent-primary: #6366f1;
    --color-accent-secondary: #8b5cf6;
    --color-accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);

    /* Cores de texto */
    --color-text-primary: #f8fafc;
    --color-text-secondary: #a1a1aa;
    --color-text-muted: #71717a;

    /* Cores semânticas */
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    --color-error: #ef4444;
    --color-info: #3b82f6;

    /* Glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);

    /* Dimensões */
    --sidebar-width: 280px;
    --header-height: 77px;
    --input-height: 56px;
    --border-radius: 12px;
    --border-radius-sm: 8px;

    /* Transições */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;

    /* Fontes */
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Layout */
    --chat-max-width: 900px;
}


/* ============================================
   RESET E BASE
   ============================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

input,
button,
textarea,
select {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
}

a {
    color: inherit;
    text-decoration: none;
}

ul,
ol {
    list-style: none;
}


/* ============================================
   PÁGINA DE LOGIN
   ============================================ */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
    position: relative;
}

/* Animação de fundo */
.background-animation {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    z-index: -1;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 20s ease-in-out infinite;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: var(--color-accent-primary);
    top: -100px;
    left: -100px;
    animation-delay: 0s;
}

.orb-2 {
    width: 300px;
    height: 300px;
    background: var(--color-accent-secondary);
    bottom: -50px;
    right: -50px;
    animation-delay: -7s;
}

.orb-3 {
    width: 250px;
    height: 250px;
    background: #ec4899;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -14s;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    25% {
        transform: translate(50px, -30px) scale(1.1);
    }

    50% {
        transform: translate(20px, 40px) scale(0.9);
    }

    75% {
        transform: translate(-40px, 20px) scale(1.05);
    }
}

/* Card de Login */
.login-container {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    box-shadow: var(--glass-shadow);
    padding: 2.5rem;
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header do Login */
.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    color: var(--color-accent-primary);
}

.logo h1 {
    font-size: 2rem;
    font-weight: 700;
    background: var(--color-accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
}

/* Formulário */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 1rem;
    width: 20px;
    height: 20px;
    color: var(--color-text-muted);
    pointer-events: none;
}

.input-wrapper input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 2.75rem;
    background: var(--color-bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    color: var(--color-text-primary);
    transition: all var(--transition-fast);
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--color-accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.input-wrapper input::placeholder {
    color: var(--color-text-muted);
}

.toggle-password {
    position: absolute;
    right: 1rem;
    padding: 0.25rem;
    color: var(--color-text-muted);
    transition: color var(--transition-fast);
}

.toggle-password:hover {
    color: var(--color-text-primary);
}

.toggle-password .eye-icon {
    width: 20px;
    height: 20px;
}

/* Mensagem de Erro */
.error-message {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--border-radius-sm);
    color: var(--color-error);
    font-size: 0.875rem;
    animation: shake 0.3s ease;
}

.error-message svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.error-message[hidden] {
    display: none;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* Botão de Login */
.btn-login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--color-accent-gradient);
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    color: white;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.btn-login:active {
    transform: translateY(0);
}

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

.btn-loader {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Footer do Login */
.login-footer {
    margin-top: 1.5rem;
    text-align: center;
}

.login-footer p {
    color: var(--color-text-muted);
    font-size: 0.8rem;
}


/* ============================================
   PÁGINA DE CHAT
   ============================================ */
.chat-page {
    display: flex;
    position: fixed;
    inset: 0;
    width: 100%;
    overflow: hidden;
    /* Garante que o conteúdo não fique atrás da barra de status/notch */
    padding-top: env(safe-area-inset-top, 0px);
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    height: 100svh;
    background: var(--color-bg-secondary);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform var(--transition-normal);
}

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

.btn-new-chat {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--color-accent-gradient);
    border-radius: var(--border-radius-sm);
    font-weight: 500;
    color: white;
    transition: all var(--transition-fast);
}

.btn-new-chat:hover {
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

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

.sidebar-search {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.sidebar-search input {
    width: 100%;
    padding: 0.625rem 1rem;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
}

.sidebar-search input:focus {
    outline: none;
    border-color: var(--color-accent-primary);
}

/* Lista de Conversas */
.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
    margin-bottom: 0.25rem;
}

.conversation-item:hover {
    background: var(--color-bg-tertiary);
}

.conversation-item.active {
    background: rgba(99, 102, 241, 0.2);
}

.conversation-item .icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-tertiary);
    border-radius: 8px;
    flex-shrink: 0;
}

.conversation-item .icon svg {
    width: 16px;
    height: 16px;
    color: var(--color-text-secondary);
}

.conversation-info {
    flex: 1;
    min-width: 0;
}

.conversation-title {
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-date {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.conversation-actions {
    opacity: 0;
    display: flex;
    gap: 0.25rem;
    transition: opacity var(--transition-fast);
}

.conversation-item:hover .conversation-actions {
    opacity: 1;
}

.conversation-actions button {
    padding: 0.25rem;
    color: var(--color-text-muted);
    border-radius: 4px;
    transition: all var(--transition-fast);
}

.conversation-actions button:hover {
    color: var(--color-text-primary);
    background: var(--color-bg-tertiary);
}

.conversation-actions svg {
    width: 16px;
    height: 16px;
}

/* Em touch devices, sempre mostrar os botões de ação */
/* Usa hover: none para detectar dispositivos touch */
@media (hover: none) {
    .conversation-actions {
        opacity: 1;
    }

    .conversation-actions button {
        color: var(--color-text-secondary);
    }

    .conversation-actions svg {
        fill: currentColor;
    }
}

/* Fallback para dispositivos móveis baseado em largura de tela */
/* Garante compatibilidade com navegadores que não suportam hover: none */
@media (max-width: 768px) {
    .conversation-actions {
        opacity: 1;
    }

    .conversation-actions button {
        color: var(--color-text-secondary);
    }

    .conversation-actions svg {
        fill: currentColor;
    }
}

/* Loader de Processamento na Sidebar */
.processing-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: auto;
    margin-right: 0.5rem;
}

.processing-loader .spinner {
    width: 18px;
    height: 18px;
    color: var(--color-accent-primary);
    animation: spin 1s linear infinite;
}

/* Mostrar actions mesmo com loader */
.conversation-item:hover .processing-loader {
    margin-right: 0.25rem;
}

/* Footer da Sidebar */
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--glass-border);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    width: 100%;
    color: var(--color-text-secondary);
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
}

.btn-logout:hover {
    background: var(--color-bg-tertiary);
    color: var(--color-error);
}

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

/* Link de Gestão de Usuários */
.btn-users {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    width: 100%;
    color: var(--color-text-secondary);
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
    margin-bottom: 0.5rem;
    text-decoration: none;
}

.btn-users:hover {
    background: var(--color-bg-tertiary);
    color: var(--color-accent-primary);
}

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

/* Botão Meu Perfil */
.btn-profile {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    width: 100%;
    color: var(--color-text-secondary);
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
    margin-bottom: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
}

.btn-profile:hover {
    background: var(--color-bg-tertiary);
    color: var(--color-accent-primary);
}

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

/* Link Esqueci Minha Senha */
.forgot-password-link {
    display: inline-block;
    margin-top: 0.75rem;
    color: var(--color-accent-primary);
    font-size: 0.85rem;
    text-decoration: none;
    transition: color var(--transition-fast);
}

.forgot-password-link:hover {
    color: var(--color-accent-secondary);
    text-decoration: underline;
}


/* ============================================
   ÁREA PRINCIPAL DE CHAT
   ============================================ */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--color-bg-primary);
    position: relative;
    height: 100%;
    overflow: hidden;
}

/* Header do Chat */
.chat-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
    background: var(--color-bg-secondary);
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.btn-toggle-sidebar {
    display: none;
    padding: 0.5rem;
    color: var(--color-text-secondary);
    border-radius: var(--border-radius-sm);
}

.btn-toggle-sidebar:hover {
    background: var(--color-bg-tertiary);
}

.btn-toggle-sidebar svg {
    width: 24px;
    height: 24px;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-logo .logo-icon {
    width: auto;
    height: 32px;
    object-fit: contain;
}

.header-logo span {
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--color-accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ============================================
   WIDGET DE MÉTRICAS DO SISTEMA (CPU/Memória)
   ============================================ */
.system-metrics {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: 0.75rem;
    padding: 0.4rem 0.75rem;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
}

.metric-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: default;
}

.metric-icon {
    width: 16px;
    height: 16px;
    color: var(--color-accent-primary);
    flex-shrink: 0;
}

.metric-info {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.metric-label {
    font-size: 0.6rem;
    font-weight: 500;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-primary);
    min-width: 32px;
}

.metric-bar {
    width: 40px;
    height: 6px;
    background: var(--color-bg-secondary);
    border-radius: 3px;
    overflow: hidden;
}

.metric-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease, background 0.3s ease;
}

/* Cores dinâmicas baseadas no uso */
.cpu-bar {
    background: linear-gradient(90deg, var(--color-success), #22c55e);
}

.cpu-bar.warning {
    background: linear-gradient(90deg, var(--color-warning), #fbbf24);
}

.cpu-bar.danger {
    background: linear-gradient(90deg, var(--color-error), #f87171);
}

.ram-bar {
    background: linear-gradient(90deg, var(--color-accent-primary), #818cf8);
}

.ram-bar.warning {
    background: linear-gradient(90deg, var(--color-warning), #fbbf24);
}

.ram-bar.danger {
    background: linear-gradient(90deg, var(--color-error), #f87171);
}

/* Animação de pulse quando está em nível alto */
@keyframes pulse-warning {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.metric-bar-fill.danger {
    animation: pulse-warning 1.5s ease-in-out infinite;
}

/* Responsividade - Esconder em telas menores */
@media (max-width: 900px) {
    .system-metrics {
        display: none;
    }
}

@media (max-width: 1100px) {
    .system-metrics {
        padding: 0.3rem 0.5rem;
        gap: 0.5rem;
    }

    .metric-bar {
        width: 30px;
    }

    .metric-icon {
        width: 14px;
        height: 14px;
    }
}

/* Botão de Modelos no Header (Mobile) */
.btn-header-models {
    display: none;
    /* Escondido por padrão (desktop) */
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    color: var(--color-accent-primary);
    transition: all var(--transition-fast);
}

.btn-header-models:hover,
.btn-header-models:active {
    background: var(--color-accent-gradient);
    color: white;
    border-color: transparent;
}

.btn-header-models svg {
    width: 22px;
    height: 22px;
}

/* Seletores de Modelo (1ª, 2ª Instância e Mago) */
.model-selectors {
    display: flex;
    gap: 0.75rem;
    flex: 1;
    max-width: 700px;
    margin-left: auto;
}

.model-selector-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    min-width: 0;
}

.model-selector-item label {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Custom Select Wrapper (Dropdown com Filtro Integrado) */
.custom-select-wrapper {
    position: relative;
    width: 100%;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--color-text-primary);
    transition: border-color var(--transition-fast);
}

.custom-select-trigger:hover {
    border-color: var(--color-accent-primary);
}

.custom-select-trigger .selected-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.custom-select-trigger .arrow {
    font-size: 0.6rem;
    color: var(--color-text-muted);
    transition: transform var(--transition-fast);
}

.custom-select-wrapper.open .arrow {
    transform: rotate(180deg);
}

/* Dropdown de Opções */
.custom-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--color-bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 100;
    max-height: 300px;
    display: flex;
    flex-direction: column;
}

.custom-select-dropdown[hidden] {
    display: none !important;
}

/* Campo de Filtro Dentro do Dropdown */
.dropdown-filter {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: none;
    border-bottom: 1px solid var(--glass-border);
    background: var(--color-bg-tertiary);
    font-size: 0.8rem;
    color: var(--color-text-primary);
    border-radius: var(--border-radius-sm) var(--border-radius-sm) 0 0;
}

.dropdown-filter::placeholder {
    color: var(--color-text-muted);
}

.dropdown-filter:focus {
    outline: none;
    background: var(--color-bg-primary);
}

/* Área de Opções com Scroll */
.dropdown-options {
    overflow-y: auto;
    max-height: 250px;
    padding: 0.25rem 0;
}

.dropdown-option {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--color-text-secondary);
    transition: background var(--transition-fast);
}

.dropdown-option:hover {
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
}

.dropdown-option.selected {
    background: rgba(99, 102, 241, 0.2);
    color: var(--color-accent-primary);
}

.dropdown-option-group {
    padding: 0.25rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--color-bg-tertiary);
    margin-top: 0.25rem;
}

.dropdown-option-group:first-child {
    margin-top: 0;
}

.dropdown-no-results {
    padding: 1rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

/* Responsividade para telas menores */
@media (max-width: 1200px) {
    .model-selectors {
        max-width: 550px;
    }
}

@media (max-width: 900px) {
    .model-selectors {
        display: none;
    }
}

/* Status de Conexão */
.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-text-muted);
}

.connection-status.connected .status-dot {
    background: var(--color-success);
    box-shadow: 0 0 8px var(--color-success);
}

.connection-status.disconnected .status-dot {
    background: var(--color-error);
}


/* ============================================
   ÁREA DE MENSAGENS
   ============================================ */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    min-height: 0;
}

/* Tela de Boas-Vindas */
.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
}

.welcome-content {
    max-width: 500px;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.welcome-icon {
    width: auto;
    height: 120px;
    object-fit: contain;
    margin-bottom: 1.5rem;
}

.welcome-content h2 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.welcome-content>p {
    color: var(--color-text-secondary);
    margin-bottom: 1.5rem;
}

.capabilities-list {
    text-align: left;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}

.capabilities-list li {
    padding: 0.5rem 0;
    color: var(--color-text-secondary);
    font-size: 0.95rem;
}

.welcome-hint {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* Classes de visibilidade desktop/mobile */
.desktop-only {
    display: block;
}

.mobile-only {
    display: none;
}

@media (max-width: 900px) {
    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: block !important;
    }

    /* Mostrar botão de modelos no mobile */
    .btn-select-models {
        display: flex;
    }

    /* Botão de modelos no header - visível em mobile */
    .btn-header-models {
        display: flex !important;
    }
}

/* Botão Selecionar Modelos (centralizado, mobile only) */
.btn-select-models {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    background: var(--color-accent-gradient);
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    color: white;
    font-size: 0.95rem;
    transition: all var(--transition-fast);
    margin: 1rem auto 0;
    max-width: 250px;
}

.btn-select-models:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

/* Modal de Seleção de Modelos */
.models-modal {
    width: 600px;
    max-width: 90%;
    max-height: 85vh;
    overflow-y: auto;
}

.models-modal .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--glass-border);
}

.models-modal .modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.75rem;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
    transition: color var(--transition-fast);
    z-index: 10;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover,
.modal-close:active {
    color: var(--color-text-primary);
}

.models-modal .modal-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-model-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.modal-model-item label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.modal-model-item select {
    width: 100%;
    padding: 0.625rem 0.75rem;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    color: var(--color-text-primary);
}

.modal-model-item select:focus {
    outline: none;
    border-color: var(--color-accent-primary);
}

.btn-confirm-models {
    margin-top: 0.5rem;
    padding: 0.875rem 1rem;
    background: var(--color-accent-gradient);
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    color: white;
    font-size: 1rem;
    transition: all var(--transition-fast);
}

.btn-confirm-models:hover {
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

/* Mensagens */
.messages {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    max-width: var(--chat-max-width);
    margin: 0 auto;
}

.message {
    display: flex;
    gap: 1rem;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--color-accent-gradient);
}

.message.assistant .message-avatar {
    background: var(--color-bg-tertiary);
    border: 1px solid var(--glass-border);
}

.message-avatar svg {
    width: 20px;
    height: 20px;
    color: white;
}

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

.message-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.message-author {
    font-weight: 600;
    font-size: 0.9rem;
}

.message-time {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.message-body {
    color: var(--color-text-secondary);
    line-height: 1.7;
    /* Forçar quebra de linha em URLs e strings longas */
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.message-body p {
    margin-bottom: 0.75rem;
}

.message-body p:last-child {
    margin-bottom: 0;
}

/* Código nas mensagens */
.message-body pre {
    background: var(--color-bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    padding: 1rem;
    overflow-x: auto;
    margin: 1rem 0;
}

.message-body code {
    font-family: var(--font-mono);
    font-size: 0.875rem;
}

.message-body :not(pre)>code {
    background: var(--color-bg-tertiary);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
}

/* Listas nas mensagens */
.message-body ul,
.message-body ol {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
}

.message-body li {
    margin-bottom: 0.25rem;
    list-style: disc;
}

.message-body ol li {
    list-style: decimal;
}

/* Badge de Tempo de Execução */
.execution-time-badge {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    margin-top: 0.75rem;
    padding: 0.35rem 0.65rem;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--color-accent-primary);
    font-weight: 500;
    width: fit-content;
    margin-left: auto;
}

.execution-time-badge svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* ============================================
   INDICADOR DE DIGITAÇÃO
   ============================================ */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    background: var(--color-bg-secondary);
    border-top: 1px solid var(--glass-border);
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--color-accent-primary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0.8);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.typing-text {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}


/* ============================================
   ÁREA DE INPUT
   ============================================ */
.input-area {
    padding: 1rem 1.5rem 1.5rem;
    background: var(--color-bg-primary);
    position: relative;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.message-form {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    width: 100%;
    max-width: var(--chat-max-width);
    margin: 0 auto;
    background: var(--color-bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    transition: border-color var(--transition-fast);
}

.message-form:focus-within {
    border-color: var(--color-accent-primary);
}

.btn-upload {
    padding: 0.5rem;
    color: var(--color-text-muted);
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
}

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

.btn-upload svg {
    width: 24px;
    height: 24px;
}

.input-area .input-wrapper {
    flex: 1;
}

.input-area textarea {
    width: 100%;
    max-height: 600px;
    padding: 0.5rem;
    background: transparent;
    border: none;
    resize: vertical;
    line-height: 1.5;
}

.input-area textarea:focus {
    outline: none;
}

.input-area textarea::placeholder {
    color: var(--color-text-muted);
}

/* Estado de drag-over para upload de arquivos */
.input-area.drag-over {
    border-color: var(--color-accent-primary);
    background: rgba(99, 102, 241, 0.1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.input-area.drag-over::after {
    content: '📎 Solte os arquivos aqui';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-accent-primary);
    pointer-events: none;
    z-index: 10;
}

.btn-send {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-accent-gradient);
    border-radius: var(--border-radius-sm);
    color: white;
    transition: all var(--transition-fast);
}

.btn-send:hover:not(:disabled) {
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

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

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

/* Botão Cancelar Processamento */
.btn-cancel {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-error);
    border-radius: var(--border-radius-sm);
    color: white;
    transition: all var(--transition-fast);
    animation: pulse-cancel 1.5s infinite;
}

.btn-cancel:hover {
    background: #dc2626;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.5);
    transform: scale(1.05);
}

.btn-cancel svg {
    width: 22px;
    height: 22px;
}

.btn-cancel[hidden] {
    display: none;
}

/* Animação de pulso para chamar atenção */
@keyframes pulse-cancel {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
}

/* Preview de Arquivos */
.file-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    max-width: 800px;
    margin: 0.75rem auto 0;
    padding: 0.75rem;
    background: var(--color-bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
}

.file-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--color-bg-tertiary);
    border-radius: 6px;
    font-size: 0.875rem;
}

.file-item .file-name {
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-item .file-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.file-item .remove-file {
    padding: 0.125rem;
    color: var(--color-text-muted);
    border-radius: 4px;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-item .remove-file:hover {
    color: var(--color-error);
    background: rgba(239, 68, 68, 0.1);
}


/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-overlay[hidden] {
    display: none !important;
}

.modal {
    background: var(--color-bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    box-shadow: var(--glass-shadow);
    min-width: 300px;
    max-width: 90%;
    animation: scaleIn 0.2s ease;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.modal-body {
    padding: 1.5rem;
}

.tool-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.tool-name {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    padding: 0.25rem 0.75rem;
    background: var(--color-bg-tertiary);
    border-radius: 4px;
}

.tool-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}


/* ============================================
   SCROLLBAR PERSONALIZADA
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--color-bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}


/* ============================================
   OVERLAY SIDEBAR (Mobile)
   ============================================ */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1001;
    /* Maior que header (1000) */
    display: none;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.sidebar-overlay.active {
    display: block;
    animation: fadeIn 0.2s ease;
}


/* ============================================
   BOTÃO COPIAR MENSAGEM
   ============================================ */
.message {
    position: relative;
}

.btn-copy-message {
    position: absolute;
    top: 0.5rem;
    right: 0;
    padding: 0.4rem;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    color: var(--color-text-muted);
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.btn-copy-message:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
    border-color: var(--color-accent-primary);
}

.btn-copy-message.copied {
    background: var(--color-success);
    border-color: var(--color-success);
    color: white;
}

.btn-copy-message svg {
    width: 16px;
    height: 16px;
}

.message:hover .btn-copy-message {
    opacity: 1;
}

/* Em touch devices, sempre mostrar o botão */
@media (hover: none) {
    .btn-copy-message {
        opacity: 1;
    }
}


/* ============================================
   RESPONSIVO
   ============================================ */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 1002;
        /* Maior que overlay (1001) */
        transform: translateX(-100%);
        box-shadow: none;
        /* Adicionar padding para safe area (status bar) */
        padding-top: env(safe-area-inset-top, 0px);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
    }

    .btn-toggle-sidebar {
        display: flex;
    }

    .header-logo {
        margin-left: 0;
    }

    .model-selector {
        max-width: 200px;
    }

    .messages-container {
        padding: 1rem;
    }

    .input-area {
        padding: 0.75rem 1rem;
        /* Padding extra para evitar que a barra de navegação do móvel corte o input */
        padding-bottom: calc(2.5rem + env(safe-area-inset-bottom, 20px));
        margin-bottom: 5% !important;
    }

    /* Chat header mais compacto no mobile */
    .chat-header {
        padding: 0 1rem;
        gap: 0.5rem;
    }

    /* Status de conexão mais compacto */
    .connection-status .status-text {
        display: none;
    }

    /* Mensagens com padding menor */
    .message {
        gap: 0.75rem;
    }

    .message-avatar {
        width: 32px;
        height: 32px;
    }

    .message-avatar svg {
        width: 16px;
        height: 16px;
    }

    /* Botão copiar sempre visível no mobile */
    .btn-copy-message {
        opacity: 0.7;
    }

    /* Ajuste do welcome screen */
    .welcome-content {
        padding: 1rem;
    }

    .welcome-icon {
        width: 48px;
        height: 48px;
    }

    .welcome-content h2 {
        font-size: 1.5rem;
    }

    /* Input area ajustes */
    .message-form {
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .btn-upload svg,
    .btn-send svg,
    .btn-cancel svg {
        width: 20px;
        height: 20px;
    }

    .btn-send,
    .btn-cancel {
        width: 36px;
        height: 36px;
    }

    /* File preview mais compacto */
    .file-preview {
        padding: 0.5rem;
    }

    .file-item {
        padding: 0.375rem 0.5rem;
        font-size: 0.8rem;
    }

    .file-item .file-name {
        max-width: 100px;
    }

    /* Typing indicator mais compacto */
    .typing-indicator {
        padding: 0.5rem 1rem;
    }

    .typing-text {
        font-size: 0.8rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 60vw;
    }
}

@media (max-width: 480px) {
    .model-selector {
        display: none;
    }

    .login-card {
        padding: 1.5rem;
    }

    .welcome-content h2 {
        font-size: 1.25rem;
    }

    .welcome-content p {
        font-size: 0.9rem;
    }

    .capabilities-list {
        padding: 1rem;
    }

    .capabilities-list li {
        font-size: 0.85rem;
        padding: 0.375rem 0;
    }

    /* Header ainda mais compacto */
    .header-logo span {
        display: none;
    }

    .header-logo .logo-icon {
        width: 32px;
        height: 32px;
    }

    /* Mensagens ainda mais compactas */
    .message-author {
        font-size: 0.85rem;
    }

    .message-time {
        font-size: 0.7rem;
    }

    .message-body {
        font-size: 0.9rem;
        line-height: 1.5;
    }

    /* Código em mensagens */
    .message-body pre {
        padding: 0.75rem;
        font-size: 0.75rem;
    }
}