/* Chat n8n AI - Interface Moderna */

:root {
    --primary-color: #0073aa;
    --secondary-color: #005a87;
    --success-color: #28a745;
    --error-color: #dc3545;
    --warning-color: #ffc107;
    --light-bg: #f8f9fa;
    --dark-bg: #343a40;
    --border-radius: 12px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

/* Reset global removido para evitar conflitos com o WordPress */

/* Garante que o plugin não afete o scroll da página */
body:not(.nai-chat-page) {
    overflow: auto !important;
    height: auto !important;
}

/* Isola o plugin para não afetar o resto da página */
.nai-chat-container {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    isolation: isolate;
    contain: layout style paint;
}

#nai-chat-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    position: relative;
}

#nai-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 60px;
    width: 100%;
    position: relative;
    z-index: 10;
    background: #fff;
    padding: 0 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    min-height: 60px;
}

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

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

/* ===== LOGO E TÍTULO ===== */
.nai-logo {
    background: #0a2540;
    color: #fff;
    font-weight: bold;
    font-size: 20px;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nai-title {
    font-size: 18px;
    font-weight: 700;
    color: #0a2540;
}

.nai-beta {
    background: #c53030;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    padding: 2px 6px;
    margin-left: 4px;
}

/* ===== BOTÃO NOVO CHAT ===== */
button.nai-new-chat {
    padding: 6px 10px;
    background: #9b9b9b;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.nai-new-chat:hover {
    background: #c53030;
}

/* ===== SUGESTÕES ===== */
.nai-suggestion {
    background: #f6f7fb;
    border-radius: 10px;
    padding: 16px 14px 10px 14px;
    margin-bottom: 10px;
    font-size: 15px;
    font-weight: 700;
    color: #0a2540;
    cursor: pointer;
    border: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    transition: background 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.nai-suggestion span {
    display: block;
    font-size: 13px;
    color: #6b7280;
    font-weight: 400;
    margin-top: 4px;
}

.nai-suggestion:hover, 
.nai-suggestion.active {
    background: #e5e7eb;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

#nai-chat-main {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    position: relative;
    background: #f6f7fb;
    overflow: hidden;
    height: 100%;
}

#nai-welcome,
#chat-box {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    height: calc(100% - 140px);
    display: none !important;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background: #f6f7fb;
    gap: 18px;
    scroll-behavior: smooth;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 32px 32px 16px 32px;
    box-sizing: border-box;
}

#nai-welcome.active,
#chat-box.active {
    display: flex !important;
}

#chat-box::-webkit-scrollbar {
    width: 6px;
}

#chat-box::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

#chat-box::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

#chat-box::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

#chat-box .message {
    max-width: 70%;
    padding: 14px 18px;
    border-radius: 16px;
    word-wrap: break-word;
    line-height: 1.5;
    position: relative;
    animation: messageSlide 0.3s ease-out;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    font-size: 15px;
    background: #fff;
    color: #222;
}

#chat-box .user {
    background: #2563eb;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 6px;
    border-top-right-radius: 16px;
    border-top-left-radius: 16px;
    border-bottom-left-radius: 16px;
}

#chat-box .bot {
    background: #fff;
    color: #222;
    align-self: flex-start;
    border-bottom-left-radius: 6px;
    border-top-right-radius: 16px;
    border-top-left-radius: 16px;
    border-bottom-right-radius: 16px;
}

#chat-box .bot.typing {
    background: #e9ecef;
    color: #6c757d;
    font-style: italic;
}

#chat-box .error {
    background: var(--error-color);
    color: white;
    align-self: center;
    text-align: center;
    font-size: 14px;
}

.message-timestamp {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 6px;
    text-align: right;
}

#chat-form {
    flex: 0 0 70px;
    width: 100%;
    position: relative;
    z-index: 10;
    background: #fff;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px 16px 24px;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.03);
    border-top: 1px solid #e5e7eb;
}

#user-input {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    padding: 12px 18px;
    border: 1.5px solid #e5e7eb;
    border-radius: 25px;
    font-size: 15px;
    background: #fff;
    outline: none;
    resize: none;
    margin-right: 8px;
    box-sizing: border-box;
}

#user-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.08);
}

#user-input::placeholder {
    color: #6b7280;
}

#chat-form button {
    padding: 12px 28px;
    border: none;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 25px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 100px;
    justify-content: center;
    font-size: 15px;
    box-shadow: 0 2px 8px rgba(16,35,54,0.04);
    transition: background 0.2s;
}

#chat-form button:hover {
    background: #c53030;
}

#chat-form button:active {
    background: #1d4ed8;
}

#chat-form button:disabled {
    background: #6b7280;
    cursor: not-allowed;
}

#chat-form button svg {
    width: 16px;
    height: 16px;
}

/* ===== AVATAR E DROPDOWN DO USUÁRIO ===== */
.nai-user-dropdown {
    position: relative;
    display: flex;
    align-items: center;
}

.nai-avatar {
    width: 32px;
    height: 32px;
    background: #102336;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: box-shadow 0.2s;
    outline: none;
}

.nai-avatar:focus {
    box-shadow: 0 0 0 2px #e74c3c44;
}

.nai-user-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    min-width: 180px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(16,35,54,0.12);
    z-index: 100;
    padding: 0.3rem 0;
    animation: fadeInMenu 0.18s ease;
}

.nai-user-dropdown:hover .nai-user-menu,
.nai-user-dropdown:focus-within .nai-user-menu {
    display: block;
}

.nai-user-info-menu {
    padding: 0.6rem 1rem 0.4rem 1rem;
    border-bottom: 1px solid #f0f1f3;
    margin-bottom: 0.15rem;
}

.nai-user-info {
    display: flex;
    flex-direction: column;
}

.nai-user-name {
    font-size: 14px;
    font-weight: 600;
    color: #0a2540;
}

.nai-user-email {
    font-size: 12px;
    color: #6b7280;
}

.nai-user-menu-item {
    display: flex;
    align-items: center;
    gap: 0.6em;
    padding: 0.55em 1em;
    font-size: 0.98rem;
    color: #102336;
    cursor: pointer;
    transition: background 0.13s;
    white-space: nowrap;
}

.nai-user-menu-item:hover {
    background: #f6f7fa;
}

.nai-user-menu-icon {
    font-size: 1.1em;
    width: 1.3em;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #7a8597;
}

.nai-header-right .nai-user-info, 
.nai-header-right .nai-user-name, 
.nai-header-right .nai-user-email {
    display: none !important;
}

/* ===== HEADER DO CHAT ===== */
#chat-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 20px 32px;
    text-align: center;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #e5e7eb;
}

#chat-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    flex: 1;
    text-align: center;
}

#chat-status {
    position: absolute;
    top: 18px;
    right: 32px;
    width: 12px;
    height: 12px;
    background: var(--success-color);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

/* ===== TELA DE BOAS-VINDAS ===== */
#nai-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    background: transparent;
    padding: 48px 12px 0 12px;
    animation: fadeInMenu 0.3s;
    padding-bottom: 90px;
    background-color: #f6f7fb;
    height: calc(100vh - 60px - 86px);
    min-height: 0;
    max-height: none;
    box-sizing: border-box;
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
    overflow-y: auto;
    background-color: #f6f7fb;
}

.nai-welcome-greeting {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    font-weight: 400;
    color: #102336;
    margin-bottom: 32px;
}

.nai-welcome-title {
    font-weight: 600;
    font-size: 2rem;
    color: #102336;
}

.nai-welcome-suggestions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 800px;
    margin-top: 10px;
}

.nai-suggestion-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: none;
    border-radius: 12px;
    padding: 13px 18px;
    font-size: 1.08rem;
    color: #102336;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(16,35,54,0.03);
    outline: none;
}

.nai-suggestion-btn:hover, 
.nai-suggestion-btn:focus {
    background: #0073aa;
}

.nai-suggestion-btn .dashicons {
    font-size: 1.25em;
    color: #b7b7b7;
    margin-right: 2px;
}

/* ===== ANIMAÇÕES ===== */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

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

@keyframes fadeInMenu {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ===== LOADING ANIMATION ===== */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    align-self: flex-start;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 6px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #6c757d;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

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

/* ===== RESPONSIVO ===== */
@media (max-width: 900px) {
    #nai-header {
        height: 54px;
        padding: 0 8px;
    }
    #chat-form {
        height: 54px;
        padding: 10px 8px;
        gap: 6px;
    }
    #chat-box, #nai-welcome {
        padding: 12px 6px 6px 6px;
    }
    
    #nai-chat-wrapper {
        flex-direction: column;
        max-width: 100%;
        min-width: 0;
        width: 100%;
        height: 100%;
        min-height: 100%;
        border-radius: 0;
        margin: 0;
    }
    
    .nai-logo {
        width: 30px;
        height: 30px;
        font-size: 16px;
    }
    
    .nai-title {
        font-size: 15px;
    }
    
    .nai-new-chat {
        padding: 10px 18px;
        font-size: 15px;
    }
    
    #nai-chat-main, 
    #nai-welcome {
        padding: 0;
        height: calc(100% - 60px - 86px);
    }
    
    #chat-box {
        padding: 12px 6px 6px 6px;
    }
    
    #chat-form {
        padding: 10px 6px;
    }
    #user-input {
        font-size: 13px;
        padding: 10px 10px;
    }
    #chat-form button {
        padding: 10px 12px;
        font-size: 13px;
        min-width: 70px;
    }
}

@media (max-width: 600px) {
    #nai-header {
        padding: 0 4px;
        height: 54px;
    }
    
    .nai-logo {
        width: 24px;
        height: 24px;
        font-size: 13px;
    }
    
    .nai-title {
        font-size: 13px;
    }
    
    .nai-new-chat {
        padding: 8px 10px;
        font-size: 13px;
    }
    
    #nai-chat-main, 
    #nai-welcome {
        margin-top: 54px;
        padding: 0;
        height: calc(100% - 54px - 56px);
    }
    
    #chat-header {
        padding: 12px 8px;
    }
    
    #chat-box {
        padding: 6px 2px 2px 2px;
    }
    
    #chat-box .message {
        font-size: 13px;
        padding: 10px 12px;
    }
    
    #chat-form {
        padding: 6px 2px;
    }
    
    #nai-welcome {
        padding: 32px 4px 0 4px;
        min-height: 180px;
    }
    
    .nai-welcome-title, 
    .nai-welcome-greeting {
        font-size: 1.1rem;
    }
    
    .nai-welcome-suggestions {
        max-width: 98vw;
    }
    
    .nai-suggestion-btn {
        font-size: 0.98rem;
        padding: 11px 10px;
    }
    
    .nai-user-menu {
        min-width: 130px;
        right: -10px;
    }
    
    .nai-avatar {
        width: 22px;
        height: 22px;
        font-size: 0.95rem;
    }
}

/* ===== DARK MODE ===== */
@media (prefers-color-scheme: dark) {
    #chat-container {
        background: var(--dark-bg);
        color: white;
    }
    
    #chat-box {
        background: #2c3e50;
    }
    
    #chat-box .bot {
        background: #34495e;
        color: white;
        border-color: #4a5568;
    }
    
    #user-input {
        background: #2c3e50;
        border-color: #4a5568;
        color: white;
    }
    
    #user-input::placeholder {
        color: #a0aec0;
    }
    
    #chat-form {
        background: var(--dark-bg);
        border-top-color: #4a5568;
    }
}

/* ===== ACESSIBILIDADE ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

#user-input:focus,
#chat-form button:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.nai-user-menu .nai-user-info-menu, .nai-user-menu .nai-user-name, .nai-user-menu .nai-user-email {
    display: block !important;
    opacity: 1 !important;
    color: #102336 !important;
}
