/* FONTES SOHNE - CARREGAMENTO LOCAL */
@font-face {
    font-family: 'Sohne';
    src: url('../fonts/sohne-font-family-1768268478-0/TestSohne-Extraleicht-BF663d89cd3f5c5.otf') format('opentype');
    font-weight: 200;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Sohne';
    src: url('../fonts/sohne-font-family-1768268478-0/TestSohne-Leicht-BF663d89cd4952e.otf') format('opentype');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Sohne';
    src: url('../fonts/sohne-font-family-1768268478-0/TestSohne-Buch-BF663d89cd32e6a.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Sohne';
    src: url('../fonts/sohne-font-family-1768268478-0/TestSohne-BuchKursiv-BF663d89cd3e887.otf') format('opentype');
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: 'Sohne';
    src: url('../fonts/sohne-font-family-1768268478-0/TestSohne-Halbfett-BF663d89cd2d67b.otf') format('opentype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Sohne';
    src: url('../fonts/sohne-font-family-1768268478-0/TestSohne-HalbfettKursiv-BF663d89cd41624.otf') format('opentype');
    font-weight: 500;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: 'Sohne';
    src: url('../fonts/sohne-font-family-1768268478-0/TestSohne-Kraftig-BF663d89cd37e26.otf') format('opentype');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Sohne';
    src: url('../fonts/sohne-font-family-1768268478-0/TestSohne-KraftigKursiv-BF663d89cd2bd4b.otf') format('opentype');
    font-weight: 600;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: 'Sohne';
    src: url('../fonts/sohne-font-family-1768268478-0/TestSohne-Fett-BF663d89cca89ff.otf') format('opentype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Sohne';
    src: url('../fonts/sohne-font-family-1768268478-0/TestSohne-FettKursiv-BF663d89cc64878.otf') format('opentype');
    font-weight: 700;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: 'Sohne';
    src: url('../fonts/sohne-font-family-1768268478-0/TestSohne-Extrafett-BF663d89cc9f2c0.otf') format('opentype');
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Sohne';
    src: url('../fonts/sohne-font-family-1768268478-0/TestSohne-ExtrafettKursiv-BF663d89ccb8000.otf') format('opentype');
    font-weight: 800;
    font-style: italic;
    font-display: swap;
}

/* TEMA ÍRIS - NOVO DESIGN BASEADO NO LAYOUT ESPIRITUAL */
:root {
    /* Paleta Espiritual e Clean */
    --primary: #622703;
    --primary-hover: #7a3204;
    --accent: #E36518;
    --electric: #FEE72F;
    --black: #000000;
    --white: #ffffff;
    --bg-app: #FFF8EB;
    --bg-panel: #FFF8EB;
    --bg-panel-strong: #FFF0D6;
    --border-color: rgba(98, 39, 3, 0.15);
    --border-strong: rgba(98, 39, 3, 0.3);
    
    /* Cores do novo design espiritual */
    --color-greeting: #622703;
    --gradient-header-btn: linear-gradient(90deg, #2F9E92 0%, #49D8B8 100%);
    --gradient-input-border: linear-gradient(90deg, #77FC82 0%, #FEE72F 50%, #E36518 100%);
    --gradient-send-btn: linear-gradient(180deg, #2F9E92 0%, #49D8B8 100%);

    /* Tipografia */
    --font-ui: 'Sohne', sans-serif;
    --font-display: 'Sohne', sans-serif;

    /* Textos */
    --text-main: #622703;
    --text-muted: #8B5A2F;
    --text-light: #A67C52;

    /* Layout */
    --sidebar-width: 320px;
    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --radius-input: 30px;
    --shadow-soft: 0 12px 40px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 18px 50px rgba(70, 4, 72, 0.18);
    --gradient-primary: linear-gradient(135deg, #460448 0%, #6dddff 100%);
    --gradient-surface: linear-gradient(140deg, rgba(109, 221, 255, 0.14), rgba(255, 162, 255, 0.14));
}

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

/* Remove scrollbars padrão de toda a aplicação */
* {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE e Edge */
}

*::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

body {
    font-family: 'Sohne', sans-serif;
    background: #FFF8EB;
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Garante que todos os elementos usem Sohne, exceto código */
html, body, input, textarea, select, button, a, p, h1, h2, h3, h4, h5, h6, span, div, li, ul, ol, td, th, label {
    font-family: 'Sohne', sans-serif;
}

/* LAYOUT PRINCIPAL - ESTILO WEB APP */
.app-wrapper {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 100vh;
    max-width: none;
    background: #FFF8EB;
    position: relative;
    border: none;
    border-radius: 0;
    overflow: hidden;
}

/* HEADER */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: #FFF8EB;
    border: none;
    box-shadow: none;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #622703;
    transition: opacity 0.2s;
}

.menu-toggle:hover {
    opacity: 0.7;
}

/* Esconde botão de menu e logo quando sidebar está aberta (padrão) */
.app-wrapper:has(.sidebar:not(.closed)) .menu-toggle {
    display: none;
}

.app-wrapper:has(.sidebar:not(.closed)) .header-logo {
    display: none;
}

/* Mostra botão de menu quando sidebar está fechada */
.app-wrapper:has(.sidebar.closed) .menu-toggle {
    display: flex;
}

.header-logo {
    width: auto;
    height: 86px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.help-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #622703;
    transition: all 0.2s;
    border-radius: 50%;
    width: 36px;
    height: 36px;
}

.help-btn:hover {
    background: rgba(98, 39, 3, 0.1);
    color: #7a3204;
    transform: scale(1.1);
}

.help-btn:active {
    transform: scale(0.95);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.status-dot-header {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.status-dot-header.premium {
    background-color: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.status-dot-header.free {
    background-color: #f59e0b;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

.time-remaining {
    font-size: 14px;
    color: var(--text-muted);
    white-space: nowrap;
}

.btn-register {
    padding: 10px 20px;
    background: linear-gradient(180deg, #2F9E92 0%, #49D8B8 100%);
    border: 1px solid #2F9E92;
    color: #ffffff;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    white-space: nowrap;
}

.btn-register:hover {
    transform: translateY(-1px);
    background: linear-gradient(180deg, #49D8B8 0%, #2F9E92 100%);
    box-shadow: 0 4px 12px rgba(47, 158, 146, 0.4);
}

.btn-logout {
    width: 100%;
    margin-top: 16px;
    padding: 12px;
    background: rgba(255, 248, 235, 0.8);
    border: 1px solid rgba(98, 39, 3, 0.2);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-ui);
}

.btn-logout:hover {
    background: rgba(255, 248, 235, 1);
    border-color: rgba(98, 39, 3, 0.3);
    transform: translateY(-1px);
}

/* SIDEBAR (Aberto por padrão, expansível) */
.sidebar {
    width: var(--sidebar-width);
    background: #E8D9C4;
    display: flex;
    flex-direction: column;
    padding: 24px;
    z-index: 200;
    position: relative;
    height: 100vh;
    transition: width 0.3s ease, padding 0s ease 0s; /* Padding aparece imediatamente */
    overflow-y: auto; /* Permite scroll no sidebar */
    overflow-x: visible; /* Permite popups saírem dos limites */
    flex-shrink: 0;
}

/* Sidebar fechada (quando usuário fecha manualmente) */
.sidebar.closed {
    width: 0;
    padding: 0;
    transition: width 0.3s ease, padding 0s ease 0.3s; /* Padding só muda depois que width termina */
    overflow: hidden; /* Esconde conteúdo quando fechado */
}

/* Esconde elementos internos quando sidebar está fechado */
.sidebar.closed > * {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, visibility 0s ease 0.15s;
}

/* Mostra elementos internos quando sidebar está aberto (padrão) */
.sidebar:not(.closed) > * {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.25s ease 0.1s, visibility 0s ease 0s; /* Aparece após um pequeno delay */
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 250;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Mostra overlay quando sidebar está aberto (não fechado) */
.app-wrapper:has(.sidebar:not(.closed)) .sidebar-overlay {
    display: block;
    opacity: 1;
}

/* No desktop, overlay não bloqueia interação */
@media (min-width: 769px) {
    .sidebar-overlay {
        pointer-events: none;
        background: transparent;
    }
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
}

.sidebar-logo {
    height: 86px;
    width: auto;
}

.sidebar-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-main);
    transition: opacity 0.2s;
    border-radius: 8px;
}

.sidebar-close-btn:hover {
    opacity: 0.7;
    background: rgba(98, 39, 3, 0.1);
}

.sidebar-search {
    width: 100%;
    padding: 12px 16px;
    background: #FFF8EB;
    border: 2px solid rgba(98, 39, 3, 0.2);
    border-radius: 50px;
    font-size: 14px;
    color: var(--text-main);
    margin-bottom: 20px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.sidebar-search:focus {
    border-color: rgba(98, 39, 3, 0.4);
}

.sidebar-search::placeholder {
    color: var(--text-muted);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-main);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid rgba(98, 39, 3, 0.1);
    background: rgba(255, 248, 235, 0.5);
}

.nav-item:hover, .nav-item.active {
    background: rgba(255, 248, 235, 0.8);
    color: var(--text-main);
    border-color: rgba(98, 39, 3, 0.2);
}

.nav-item.active {
    background: rgba(255, 248, 235, 0.9);
    color: var(--text-main);
}

.user-profile-mini {
    margin-top: auto;
    padding-top: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar-circle {
    width: 36px;
    height: 36px;
    background: rgba(255, 248, 235, 0.8);
    color: var(--text-main);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    border: 1px solid rgba(98, 39, 3, 0.2);
}

.user-profile-mini span {
    color: var(--text-main);
}

/* Seção de Chats */
.chats-section {
    margin-top: 24px;
    padding-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-height: 0; /* Permite que o flex funcione corretamente */
    overflow-y: auto; /* Permite scroll nos chats */
}

.btn-new-chat {
    width: auto;
    padding: 10px 20px;
    background: rgba(255, 248, 235, 0.8);
    border: 2px solid rgba(98, 39, 3, 0.3);
    border-radius: 50px;
    color: var(--text-main);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    align-self: flex-start;
}

.btn-new-chat:hover {
    background: rgba(255, 248, 235, 1);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(98, 39, 3, 0.2);
}

.chats-list {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    gap: 4px;
    padding-right: 4px;
}

.chat-item {
    padding: 10px 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-main);
    background: transparent;
    border: none;
    cursor: pointer;
    position: relative;
    border-radius: 8px;
}

.chat-item:hover {
    background: rgba(255, 248, 235, 0.5);
}

.chat-item.active {
    color: var(--text-main);
    font-weight: 500;
    background: rgba(255, 248, 235, 0.7);
}

.chat-item a {
    text-decoration: none;
    color: inherit;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-item-icon {
    flex-shrink: 0;
    color: rgba(98, 39, 3, 0.6);
    display: flex;
    align-items: center;
}

.chat-item.active .chat-item-icon {
    color: var(--text-main);
}

.chat-item-menu-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    color: rgba(98, 39, 3, 0.6);
    cursor: pointer;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
    opacity: 0;
}

.chat-item:hover .chat-item-menu-btn {
    opacity: 1;
}

.chat-item-menu-btn:hover {
    background: rgba(98, 39, 3, 0.1);
    color: var(--text-main);
}

.chat-item-menu-popup {
    position: fixed; /* Fixed para não ser cortado pelo overflow */
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    padding: 8px;
    min-width: 180px;
    z-index: 99999; /* Z-index muito alto para ficar acima de tudo */
    display: none;
}

.chat-item-menu-popup.show {
    display: block;
}

.chat-item-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-main);
    font-size: 14px;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.chat-item-menu-item:hover {
    background: #f3f4f6;
}

.chat-item-menu-item i {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.chat-item-menu-item.delete-item {
    color: #ef4444;
}

.chat-item-menu-item.delete-item i {
    color: #ef4444;
}

.chat-item-menu-item.delete-item:hover {
    background: #fee2e2;
}

/* Botão de Apagar Todos (Danger) */
.btn-danger-reset {
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1px solid #d92c2c;
    border-radius: 10px;
    color: #b32626;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-danger-reset:hover {
    background: rgba(217, 44, 44, 0.08);
    border-color: #d92c2c;
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(217, 44, 44, 0.2);
}

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

/* ÁREA PRINCIPAL DO CHAT */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: #FFF8EB;
    overflow: hidden; /* Remove scroll do container principal */
    align-items: center;
    justify-content: flex-start;
    transition: margin-left 0.3s ease;
    min-width: 0;
    height: 100vh; /* Altura fixa da viewport */
    max-height: 100vh; /* Não ultrapassa a altura da tela */
}

/* Header do Chat */
.chat-header-simple {
    padding: 20px 32px;
    background: linear-gradient(90deg, rgba(255,248,235,0.92), rgba(255,248,235,0.72));
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.chat-title h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

.chat-status {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--electric);
    border-radius: 50%;
    box-shadow: 0 0 12px rgba(109, 221, 255, 0.8);
}

/* Decoração fixa no topo */
.deco-top-fixed {
    position: fixed;
    top: 0;
    height: auto;
    z-index: 160;
    pointer-events: none;
    object-fit: contain;
}

/* Área inicial centralizada - Fora do chat */
.chat-initial-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0;
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
    padding: 40px 24px 40px;
    flex: 1;
    min-height: 0; /* Permite que o flex funcione corretamente */
    overflow-y: auto; /* Permite scroll se necessário */
    position: relative;
}

.brain-logo-img {
    height: 216px;
    width: auto;
    margin-top: 100px;
    margin-bottom: 24px;
}

.greeting-text {
    color: var(--color-greeting);
    font-size: 16px;
    text-align: center;
    margin: 16px 0;
    line-height: 1.6;
    font-weight: 400;
}

/* Container das Mensagens - Layout Centralizado */
.chat-viewport {
    flex: 1;
    overflow-y: auto;
    padding: 40px 24px;
    display: none; /* Escondido inicialmente, aparece quando há mensagens */
    flex-direction: column;
    align-items: center;
    gap: 32px;
    scroll-behavior: smooth;
    background: #FFF8EB;
    width: 100%;
    max-width: 1024px;
    min-height: 0; /* Permite que o flex funcione corretamente */
    overflow-x: hidden; /* Previne scroll horizontal */
    /* Esconde a barra de scroll mas mantém funcionalidade */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE e Edge */
}

.chat-viewport::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.chat-viewport.has-messages {
    display: flex;
    align-items: flex-start;
}

/* Balões de Mensagem */
.message-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    opacity: 0;
    animation: fadeIn 0.4s forwards;
    align-items: flex-start;
    width: 100%;
    max-width: 100%;
}

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

.message-row.genius {
    flex-direction: row;
    justify-content: flex-start;
}

.msg-avatar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
    background: none;
    border: none;
    box-shadow: none;
    padding-top: 15px;
}

.msg-avatar i {
    width: 20px;
    height: 20px;
}

.genio-avatar { 
    color: #622703; 
}

.user-avatar { 
    color: #622703; 
}

.bubble {
    max-width: 600px;
    padding: 16px 24px;
    border-radius: 18px;
    font-size: 16px;
    line-height: 1.6;
    position: relative;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-color);
    background: transparent;
}

.message-row.genius .bubble {
    background: transparent;
    border-bottom-left-radius: 6px;
    color: var(--text-main);
    border: none;
    box-shadow: none;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    border-bottom-right-radius: 18px;
}

.message-row.genius .bubble.loading {
    background: transparent;
}

.message-row.user .bubble {
    background: #FFDECA;
    color: var(--text-main);
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 0;
    box-shadow: var(--shadow-soft);
    border-color: rgba(227, 101, 24, 0.2);
    font-weight: normal;
    position: relative;
}

.message-row.user .bubble:hover .edit-message-btn {
    opacity: 1;
}

.edit-message-btn:hover {
    background: rgba(0, 0, 0, 0.15);
}

.edit-message-input {
    width: 100%;
    min-height: 40px;
    max-height: 200px;
    padding: 8px 12px;
    border: 2px solid #E36518;
    border-radius: 12px;
    font-size: 14px;
    font-family: var(--font-ui);
    resize: none;
    outline: none;
    background: #FFF8EB;
    color: var(--text-main);
}

.edit-message-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.edit-save-btn {
    padding: 6px 16px;
    background: linear-gradient(180deg, #2F9E92 0%, #49D8B8 100%);
    border: 1px solid #2F9E92;
    color: #ffffff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: transform 0.2s;
}

.edit-save-btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.edit-save-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.edit-cancel-btn {
    padding: 6px 16px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.edit-cancel-btn:hover {
    background: var(--bg-panel-strong);
}

/* Formatação Markdown dentro do balão do Gênio */
.bubble p { margin-bottom: 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble strong { color: var(--primary); font-weight: 600; }
.message-row.user .bubble strong { color: #2b0c36; }

/* Input Area - Centralizado com Gradiente */
.input-area-wrapper {
    padding: 24px;
    background: #FFF8EB;
    display: flex;
    justify-content: center;
    width: 100%;
    flex-shrink: 0; /* Não encolhe */
    position: relative;
    z-index: 10;
}

.input-container {
    background: linear-gradient(90deg, #77FC82 0%, #FEE72F 50%, #E36518 100%);
    border-radius: var(--radius-input);
    padding: 2px;
    display: flex;
    align-items: center;
    max-width: 1024px;
    width: 100%;
    position: relative;
    transition: all 0.3s;
}

.input-container:focus-within {
    box-shadow: 0 8px 24px rgba(227, 101, 24, 0.3);
}

.input-wrapper {
    display: flex;
    align-items: center;
    flex: 1;
    padding: 12px 12px 12px 16px;
    gap: 12px;
    background: #FFF8EB;
    border-radius: calc(var(--radius-input) - 2px);
    width: 100%;
}

.input-icon {
    color: var(--text-muted);
    font-size: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

textarea.chat-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-family: var(--font-ui);
    font-size: 15px;
    resize: none;
    max-height: 100px;
    padding: 0;
    color: var(--text-main);
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(180deg, #2F9E92 0%, #49D8B8 100%);
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: auto;
    opacity: 1 !important;
    visibility: visible !important;
}

.send-btn svg,
.send-btn i {
    color: #ffffff !important;
    stroke: #ffffff !important;
    fill: none !important;
    opacity: 1 !important;
}

.send-btn:hover { 
    background: linear-gradient(180deg, #49D8B8 0%, #2F9E92 100%);
    transform: scale(1.05); 
    box-shadow: 0 4px 16px rgba(47, 158, 146, 0.4); 
}

.send-btn:disabled { 
    background: #d1d5db; 
    color: #9ca3af; 
    cursor: not-allowed; 
    box-shadow: none;
    transform: none;
}

/* Animações */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.typing-dot { background-color: var(--text-muted); }

.typing-indicator {
    display: flex;
    gap: 5px;
    align-items: center;
}

.typing-indicator .typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
    background: var(--electric);
    box-shadow: 0 0 8px rgba(109,221,255,0.5);
}
.typing-indicator .typing-dot:nth-child(2) { animation-delay: -0.2s; }
.typing-indicator .typing-dot:nth-child(3) { animation-delay: -0.4s; }

/* Paywall Card Integrado ao Chat */
.paywall-card-inline {
    background: linear-gradient(135deg, rgba(109,221,255,0.16), rgba(255,162,255,0.14));
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    margin-top: 16px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.12);
    color: var(--text-main);
}

.btn-gold {
    background: linear-gradient(180deg, #2F9E92 0%, #49D8B8 100%);
    border: 1px solid #2F9E92;
    color: #ffffff;
    padding: 12px 30px;
    border-radius: 30px;
    text-decoration: none;
    font-weight: 700;
    display: inline-block;
    margin-top: 16px;
    transition: all 0.3s;
    box-shadow: 0 14px 40px rgba(47, 158, 146, 0.25);
}

.btn-gold:hover { 
    transform: translateY(-2px); 
    background: linear-gradient(180deg, #49D8B8 0%, #2F9E92 100%);
    box-shadow: 0 18px 50px rgba(47, 158, 146, 0.35); 
}


/* MOBILE RESPONSIVE */
@media (max-width: 768px) {
    /* Layout Principal */
    .app-wrapper {
        border-radius: 0;
        border: none;
        box-shadow: none;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height para mobile */
    }
    
    .main-content {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height para mobile */
        max-height: 100vh;
        max-height: 100dvh;
        width: 100%;
        overflow: hidden; /* Remove scroll do container principal */
    }
    
    /* Garante que o conteúdo scrollável não ultrapasse */
    .chat-viewport,
    .chat-initial-area {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        width: 100%;
        min-height: 0; /* Permite que o flex funcione corretamente */
    }
    
    /* Header */
    .app-header {
        padding: 12px 16px;
        position: sticky;
        top: 0;
        z-index: 150;
        background: #ffffff;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    }
    
    .header-left {
        gap: 12px;
    }
    
    .header-logo {
        height: 48px;
    }
    
    .header-right {
        gap: 8px;
        flex-wrap: wrap;
    }
    
    .help-btn {
        width: 32px;
        height: 32px;
        padding: 6px;
    }
    
    .help-btn i {
        width: 18px;
        height: 18px;
    }
    
    .time-remaining {
        font-size: 11px;
        display: none; /* Esconde em telas muito pequenas */
    }
    
    .btn-register {
        padding: 8px 14px;
        font-size: 12px;
        white-space: nowrap;
    }
    
    /* Sidebar - Overlay no mobile */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        height: 100dvh;
        z-index: 300;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    }
    
    .sidebar.open {
        width: 85vw;
        max-width: 320px;
    }
    
    /* Overlay para fechar sidebar no mobile - já definido acima, apenas ajustes */
    .sidebar-overlay {
        pointer-events: auto; /* Permite clicar no mobile */
        background: rgba(0, 0, 0, 0.5);
    }
    
    /* Chat Viewport */
    .chat-viewport {
        padding: 20px 12px;
        gap: 24px;
    }
    
    .chat-header-simple {
        padding: 16px 20px;
    }
    
    .chat-title h2 {
        font-size: 16px;
    }
    
    .chat-status {
        font-size: 11px;
    }
    
    /* Área Inicial */
    .chat-initial-area {
        padding: 40px 20px 30px;
        gap: 0;
    }
    
    .logo-text-img {
        height: 48px;
        margin-bottom: 20px;
    }
    
    .brain-logo-img {
        height: 100px;
        margin-bottom: 20px;
    }
    
    .greeting-text {
        font-size: 14px;
        margin: 12px 0;
        padding: 0 8px;
    }
    
    /* Bubbles */
    .bubble {
        max-width: 85%;
        padding: 14px 18px;
        font-size: 14px;
        line-height: 1.5;
    }
    
    .bubble.user {
        align-self: flex-end;
    }
    
    .bubble.assistant {
        align-self: flex-start;
    }
    
    /* Input Area */
    .input-area-wrapper {
        padding: 12px;
        position: relative; /* Muda de sticky para relative no mobile */
        bottom: auto;
        background: #ffffff;
        z-index: 100;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
        flex-shrink: 0; /* Não encolhe */
        width: 100%;
    }
    
    .input-area {
        gap: 8px;
    }
    
    .chat-input {
        font-size: 14px;
        padding: 12px 16px;
        min-height: 44px; /* Tamanho mínimo para touch */
    }
    
    .send-button {
        min-width: 44px;
        min-height: 44px;
        padding: 0;
    }
    
    /* Modais */
    .modal-overlay {
        padding: 20px;
    }
    
    .modal-content {
        width: 100%;
        max-width: 100%;
        max-height: 90vh;
        max-height: 90dvh;
        margin: 0;
        padding: 20px;
        border-radius: 16px;
    }
    
    .register-modal-content {
        width: 100%;
        max-width: 100%;
        max-height: 90vh;
        max-height: 90dvh;
        margin: 0;
        padding: 20px;
        border-radius: 16px;
    }
    
    .register-modal-header {
        margin-bottom: 20px;
    }
    
    .register-modal-header h2 {
        font-size: 20px;
    }
    
    .register-form-group {
        margin-bottom: 16px;
    }
    
    .register-form-input,
    .register-form-select {
        padding: 12px 16px;
        font-size: 14px;
        min-height: 44px;
    }
    
    .register-form-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .register-form-submit {
        padding: 14px;
        font-size: 15px;
        min-height: 48px;
    }
    
    /* Genius Modal */
    .genius-modal-content {
        max-width: 100%;
        margin: 10px;
        max-height: 95vh;
        max-height: 95dvh;
        border-radius: 16px;
    }
    
    .genius-cards-container {
        grid-template-columns: 1fr;
        padding: 12px;
        gap: 12px;
    }
    
    .genius-card {
        padding: 16px;
    }
    
    .genius-card-icon {
        width: 48px;
        height: 48px;
        font-size: 24px;
    }
    
    .genius-card-title {
        font-size: 16px;
    }
    
    .genius-card-description {
        font-size: 13px;
    }
    
    /* Sidebar Elements */
    .sidebar-header {
        margin-bottom: 20px;
        padding-bottom: 12px;
    }
    
    .sidebar-logo {
        height: 40px;
    }
    
    .sidebar-search {
        padding: 10px 14px;
        font-size: 14px;
        margin-bottom: 16px;
        min-height: 44px;
    }
    
    .btn-new-chat {
        padding: 12px 16px;
        font-size: 14px;
        min-height: 44px;
    }
    
    .chat-item {
        padding: 12px;
        font-size: 14px;
    }
    
    .user-profile-mini {
        padding: 12px;
        font-size: 13px;
    }
    
    /* Chat Item Menu Popup */
    .chat-item-menu-popup {
        font-size: 13px;
        padding: 8px 0;
    }
    
    .chat-item-menu-item {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    /* Status Messages */
    .status-message {
        font-size: 13px;
        padding: 10px 14px;
    }
    
    /* Typing Indicator */
    .typing-indicator {
        gap: 4px;
    }
    
    .typing-dot {
        width: 6px;
        height: 6px;
    }
    
    /* Scroll Indicator */
    .scroll-indicator {
        width: 40px;
        height: 40px;
        bottom: 80px;
    }
    
    .scroll-indicator i {
        font-size: 18px;
    }
    
    /* Payment Modal */
    .modal-content {
        max-width: 100%;
    }
    
    .modal-title {
        font-size: 20px;
    }
    
    .modal-description {
        font-size: 13px;
    }
    
    /* Scroll to bottom button */
    .scroll-to-bottom-btn {
        width: 44px;
        height: 44px;
        bottom: 100px; /* Acima do input no mobile */
    }
    
    .scroll-to-bottom-btn i {
        font-size: 18px;
    }
}

/* Tablet Responsive */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar.open {
        width: 280px;
    }
    
    .chat-viewport {
        padding: 32px 20px;
    }
    
    .bubble {
        max-width: 75%;
    }
    
    .input-area-wrapper {
        padding: 16px 20px;
    }
}

/* Small Mobile (menos de 480px) */
@media (max-width: 480px) {
    .app-header {
        padding: 10px 12px;
    }
    
    .header-logo {
        height: 40px;
    }
    
    .time-remaining {
        display: none;
    }
    
    .btn-register {
        padding: 6px 12px;
        font-size: 11px;
    }
    
    .sidebar.open {
        width: 90vw;
    }
    
    .chat-viewport {
        padding: 16px 10px;
        gap: 20px;
    }
    
    .bubble {
        max-width: 90%;
        padding: 12px 16px;
        font-size: 13px;
    }
    
    .input-area-wrapper {
        padding: 10px;
    }
    
    .chat-input {
        font-size: 13px;
        padding: 10px 14px;
    }
    
    .modal-content,
    .register-modal-content {
        padding: 16px;
        border-radius: 12px;
    }
    
    .register-modal-header h2 {
        font-size: 18px;
    }
    
    .genius-modal-content {
        margin: 5px;
        border-radius: 12px;
    }
    
    .genius-cards-container {
        padding: 8px;
        gap: 10px;
    }
    
    .genius-card {
        padding: 12px;
    }
}

/* ADMIN PAINEL - LOOK & FEEL ÍRIS */
.admin-shell {
    min-height: 100vh;
    background: var(--bg-app);
}

.admin-header {
    background: rgba(19, 12, 31, 0.92);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 40px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.35);
}

.admin-header__content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.admin-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
    text-decoration: none;
    font-weight: 600;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: rgba(255,255,255,0.02);
    transition: all 0.2s;
}

.admin-link:hover { background: rgba(255,255,255,0.05); border-color: var(--border-strong); }

.admin-primary-btn {
    padding: 10px 16px;
    background: linear-gradient(180deg, #2F9E92 0%, #49D8B8 100%);
    border: 1px solid #2F9E92;
    color: #ffffff;
    border-radius: 10px;
    text-decoration: none;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    box-shadow: 0 12px 30px rgba(47, 158, 146, 0.25);
}

.admin-body {
    padding: 40px;
    max-width: 1400px;
    margin: 0 auto;
}

.admin-card {
    background: linear-gradient(150deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 22px;
    box-shadow: 0 18px 50px rgba(0,0,0,0.35);
}

.admin-card + .admin-card { margin-top: 20px; }

.admin-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-main);
    font-size: 20px;
    margin-bottom: 10px;
}

.admin-muted {
    color: var(--text-muted);
    font-size: 13px;
}

.admin-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--border-color);
    background: rgba(109,221,255,0.08);
    color: var(--text-main);
}

.admin-alert {
    background: linear-gradient(135deg, rgba(109,221,255,0.08), rgba(255,162,255,0.08));
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    padding: 16px;
    color: var(--text-main);
}

.admin-pill-btn {
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: rgba(255,255,255,0.02);
    color: var(--text-main);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.admin-pill-btn:hover { border-color: var(--border-strong); background: rgba(255,255,255,0.05); }

.admin-modal {
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(12px);
}

.admin-modal__card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.45);
}

.admin-input, .admin-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: rgba(255,255,255,0.02);
    color: var(--text-main);
    font-size: 14px;
}

.admin-textarea { font-family: monospace; resize: vertical; }

.admin-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 11px;
    border: 1px solid var(--border-color);
    background: rgba(255,255,255,0.04);
    color: var(--text-main);
}

/* Modal de Seleção de Gênio */
.genius-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.genius-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(12px);
}

.genius-modal-content {
    position: relative;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.genius-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.genius-modal-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

.genius-modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.genius-modal-close:hover {
    background: var(--bg-panel-strong);
    color: var(--text-main);
}

.genius-cards-container {
    padding: 24px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    max-height: calc(90vh - 100px);
}

@media (min-width: 1024px) {
    .genius-cards-container {
        grid-template-columns: 1fr;
    }
}

.genius-card {
    background: linear-gradient(140deg, rgba(255,255,255,0.6), rgba(255,255,255,0.4));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: row;
    align-items: center;
    text-align: left;
    gap: 16px;
    position: relative;
    overflow: hidden;
}

.genius-card-premium {
    background: linear-gradient(140deg, rgba(109, 221, 255, 0.08), rgba(255, 162, 255, 0.06));
    border: 1.5px solid rgba(109, 221, 255, 0.3);
}

.genius-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(109, 221, 255, 0.1), rgba(255, 162, 255, 0.1));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.genius-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-hover);
}

.genius-card:hover::before {
    opacity: 1;
}

.genius-card:hover .genius-card-action {
    opacity: 1;
}

.genius-card-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(109, 221, 255, 0.2), rgba(255, 162, 255, 0.2));
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border-color);
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

.genius-card-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.genius-card-avatar i {
    color: var(--primary);
}

.genius-card-content {
    flex: 1;
    position: relative;
    z-index: 1;
}

.genius-card-content h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 6px 0;
}

.genius-card-content p {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.4;
}

.genius-card-action {
    position: absolute;
    top: 12px;
    right: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
    color: var(--text-muted);
    z-index: 1;
}

.genius-card-locked {
    opacity: 0.7;
    cursor: pointer;
    position: relative;
}

.genius-card-locked:hover {
    opacity: 0.9;
}

.genius-lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    color: #ffffff;
}

.genius-price {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 12px;
    background: rgba(47, 158, 146, 0.1);
    border: 1px solid rgba(47, 158, 146, 0.3);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #2F9E92;
}

.genius-purchase-content {
    padding: 24px;
    text-align: center;
}

.genius-purchase-price {
    margin: 20px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.genius-purchase-price .price-label {
    font-size: 14px;
    color: var(--text-muted);
}

.genius-purchase-price .price-value {
    font-size: 24px;
    font-weight: 700;
    color: #2F9E92;
}

.btn-purchase-genius {
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(180deg, #2F9E92 0%, #49D8B8 100%);
    border: 1px solid #2F9E92;
    color: #ffffff;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 20px;
}

.btn-purchase-genius:hover {
    transform: translateY(-2px);
    background: linear-gradient(180deg, #49D8B8 0%, #2F9E92 100%);
    box-shadow: 0 8px 20px rgba(47, 158, 146, 0.4);
}

.genius-card:hover .genius-card-action {
    opacity: 1;
    color: var(--primary);
}

.genius-loading,
.genius-empty {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    gap: 16px;
}

.genius-loading .typing-indicator {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
}

.genius-loading .typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    animation: bounce 1.4s infinite ease-in-out both;
}

.genius-loading .typing-dot:nth-child(1) { animation-delay: -0.32s; }
.genius-loading .typing-dot:nth-child(2) { animation-delay: -0.16s; }

.genius-empty i {
    color: var(--text-light);
}

.genius-empty p {
    font-size: 14px;
    margin: 0;
}

@media (max-width: 768px) {
    .genius-cards-container {
        grid-template-columns: 1fr;
        padding: 16px;
    }
    
    .genius-card-premium {
        flex-direction: column;
        text-align: center;
        padding: 20px;
    }
    
    .genius-card-premium .genius-card-content {
        text-align: center;
    }
    
    .genius-modal-content {
        max-width: 100%;
        margin: 20px;
    }
}