/* Estilos Gerais - Nova Paleta de Cores */
:root {
    /* Tema Principal - Inspirado na imagem do CyberBot */
    --primary-color: #0cd5ca; /* Verde turquesa principal */
    --primary-dark: #0a9e96; /* Verde turquesa escuro */
    --primary-light: #5febe3; /* Verde turquesa claro */
    --accent-color: #ff7a30; /* Laranja do detalhe do robô */
    --accent-secondary: #ffcc00; /* Amarelo dos detalhes */
    --text-light: #ffffff;
    --text-dark: #1a2236;
    
    /* Tema Escuro (Padrão) */
    --bg-color: rgba(16, 25, 40, 0.4);
    --container-bg: rgba(26, 34, 54, 0.85);
    --header-bg: rgba(10, 18, 30, 0.9);
    --header-text: var(--text-light);
    --message-bot-bg: rgba(22, 32, 48, 0.9);
    --message-bot-text: var(--text-light);
    --message-user-bg: rgba(12, 213, 202, 0.9);
    --message-user-text: var(--text-dark);
    --input-bg: rgba(22, 32, 48, 0.95);
    --input-border: #2a3a56;
    --input-text: var(--text-light);
    --button-bg: var(--primary-color);
    --button-hover: var(--primary-light);
    --link-color: var(--primary-light);
    --user-link-color: var(--text-dark);
    --chat-area-bg: rgba(16, 25, 40, 0.8);
    --border-color: #2a3a56;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --overlay-color: rgba(10, 18, 30, 0.7);
}

.light-theme {
    /* Tema Claro Alternativo */
    --bg-color: rgba(240, 245, 255, 0.4);
    --container-bg: #eee;
    --header-bg: #eee;
    --header-text: var(--text-dark);
    --message-bot-bg: rgba(240, 245, 255, 0.9);
    --message-bot-text: var(--text-dark);
    --message-user-bg: rgba(12, 213, 202, 0.2);
    --message-user-text: var(--text-dark);
    --input-bg: rgba(255, 255, 255, 0.95);
    --input-border: #e0e0e0;
    --input-text: var(--text-dark);
    --button-bg: var(--primary-color);
    --button-hover: var(--primary-light);
    --link-color: var(--primary-dark);
    --user-link-color: var(--primary-dark);
    --chat-area-bg: rgba(248, 249, 250, 0.75);
    --border-color: #e0e0e0;
    --shadow-color: rgba(0, 0, 0, 0.25);
    --overlay-color: rgba(255, 255, 255, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease, transform 0.2s ease;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-color);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

/* Background de imagem cybernética */
.background-image {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: -99;
    background-image: url('../img/cyberpunk-background.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    pointer-events: none;
}

.background-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: -98;
    background-color: var(--overlay-color);
    transition: background-color 0.3s ease;
}

/* Container do Chat - Design Futurista */
.chat-container {
    width: 100%;
    max-width: 420px;
    height: 85vh;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(12, 213, 202, 0.3), 
                0 0 40px rgba(12, 213, 202, 0.1);
    display: flex;
    flex-direction: column;
    background-color: var(--container-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 10;
    position: relative;
    border: 1px solid rgba(12, 213, 202, 0.3);
}

/* Cabeçalho Futurista */
.chat-header {
    background-color: var(--header-bg);
    color: var(--header-text);
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--primary-color);
    position: relative;
    overflow: hidden;
}

/* Efeito de linha no topo do header */
.chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(to right, 
                                transparent, 
                                var(--primary-color), 
                                var(--accent-color), 
                                var(--primary-color), 
                                transparent);
    animation: scanline 4s linear infinite;
}

@keyframes scanline {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.logo {
    display: flex;
    align-items: center;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo img {
    width: 50px;
    height: 50px;
    border-radius: 15px;
    margin-right: 12px;
    object-fit: cover;
    border: 2px solid var(--primary-color);
    box-shadow: 0 0 10px var(--primary-color),
                0 0 20px rgba(12, 213, 202, 0.3);
    transition: all 0.3s ease;
}

.logo img:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px var(--primary-color),
                0 0 30px rgba(12, 213, 202, 0.5);
}

.logo h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
    color: var(--primary-color);
    text-shadow: 0 0 5px rgba(12, 213, 202, 0.5);
}

.status {
    font-size: 12px;
    display: flex;
    align-items: center;
    opacity: 0.8;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--primary-color);
    margin-left: 5px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.5;
        transform: scale(0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
    100% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

.header-controls {
    display: flex;
    align-items: center;
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--header-text);
    cursor: pointer;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.theme-toggle:hover {
    background-color: rgba(12, 213, 202, 0.2);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
}

.theme-toggle:active {
    transform: translateY(1px);
}

/* Área de Mensagens - Estilo Futurista */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: var(--chat-area-bg);
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) transparent;
}

.message-container {
    display: flex;
    margin-bottom: 20px;
    animation: fadeIn 0.3s;
    align-items: flex-end;
}

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

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    margin-right: 12px;
    flex-shrink: 0;
    border: 1px solid var(--primary-color);
    box-shadow: 0 0 8px var(--primary-color);
    object-fit: cover;
    transition: all 0.3s ease;
    overflow: hidden;
}

.avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 0 12px var(--primary-color),
                0 0 20px rgba(12, 213, 202, 0.3);
}

.user .avatar {
    display: none;
}

.message {
    max-width: calc(80% - 50px);
    padding: 12px 16px;
    border-radius: 18px;
    word-break: break-word;
    position: relative;
    line-height: 1.4;
}

.message.bot {
    background-color: var(--message-bot-bg);
    color: var(--message-bot-text);
    border-bottom-left-radius: 5px;
    border-left: 2px solid var(--primary-color);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.message.user {
    background-color: var(--message-user-bg);
    color: var(--message-user-text);
    border-bottom-right-radius: 5px;
    margin-left: auto;
    border-right: 2px solid var(--primary-color);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}

.message a {
    color: var(--link-color);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    pointer-events: auto !important;
    cursor: pointer !important;
    position: relative;
    z-index: 10;
    display: inline-block;
}

.message.bot a {
    color: var(--link-color);
    border-bottom: 1px solid rgba(12, 213, 202, 0.4);
}

.message.user a {
    color: var(--user-link-color);
    border-bottom: 1px solid rgba(26, 34, 54, 0.4);
}

.message a:hover {
    text-decoration: underline;
    opacity: 0.8;
}

/* Efeito de digitação */
.typing::after {
    content: '|';
    display: inline-block;
    animation: blink 0.7s infinite;
    margin-left: 2px;
    color: var(--primary-color);
}

@keyframes blink {
    0%, 100% {
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
}

/* Área de Input - Estilo Futurista */
.chat-input {
    display: flex;
    padding: 15px;
    background-color: var(--input-bg);
    border-top: 1px solid var(--primary-color);
    position: relative;
}

/* Efeito de linha brilhante na área de input */
.chat-input::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(to right, 
                                transparent 5%, 
                                var(--primary-color) 20%, 
                                var(--primary-color) 80%, 
                                transparent 95%);
}

.chat-input input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--primary-color);
    border-radius: 24px;
    outline: none;
    font-size: 14px;
    background-color: rgba(22, 32, 48, 0.6);
    color: var(--input-text);
    box-shadow: 0 0 5px rgba(12, 213, 202, 0.2);
    transition: all 0.3s ease;
}

.chat-input input:focus {
    box-shadow: 0 0 8px rgba(12, 213, 202, 0.4);
    border-color: var(--primary-light);
}

.chat-input input::placeholder {
    color: var(--input-text);
    opacity: 0.6;
}

.chat-input button {
    background-color: var(--button-bg);
    color: var(--text-dark);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    margin-left: 10px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: 0 0 10px rgba(12, 213, 202, 0.3);
    position: relative;
    overflow: hidden;
}

.chat-input button:hover {
    background-color: var(--button-hover);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 5px 15px rgba(12, 213, 202, 0.5);
}

.chat-input button:active {
    transform: translateY(1px) scale(0.95);
}

.input-focus {
    box-shadow: 0 0 10px rgba(12, 213, 202, 0.4);
}

/* Efeito de pulso para o botão de enviar */
.pulse-effect::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(12, 213, 202, 0.5);
    border-radius: 50%;
    z-index: -1;
    animation: pulse-ring 2s linear infinite;
}

@keyframes pulse-ring {
    0% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.2);
        opacity: 0;
    }
    100% {
        transform: scale(0.8);
        opacity: 0;
    }
}

/* Animações */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Efeito do botão de enviar */
.sending {
    transform: scale(0.9);
    opacity: 0.8;
}

/* Efeito de brilho nas bordas */
@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 15px rgba(12, 213, 202, 0.3),
                    0 0 30px rgba(12, 213, 202, 0.1);
    }
    50% {
        box-shadow: 0 0 20px rgba(12, 213, 202, 0.5),
                    0 0 40px rgba(12, 213, 202, 0.2);
    }
}

.chat-container {
    animation: glow 4s infinite;
}

/* Scrollbar personalizada */
.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary-light);
}

/* Melhorias de responsividade para o CyberBot Chat - Versão 2.0 */

/* Reset global para garantir comportamento consistente em todos os dispositivos */
html, body {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* Melhoria na estrutura base do layout para todos os dispositivos */
.chat-container {
    display: flex;
    flex-direction: column;
    max-height: 100vh;
    height: 100%;
}

.chat-header {
    flex: 0 0 auto;
}

.chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    position: relative;
}

.chat-input {
    flex: 0 0 auto;
}

/* Ajustes gerais para dispositivos móveis */
@media (max-width: 768px) {
    body {
        position: fixed; /* Previne rolagem indesejada */
        overscroll-behavior: none; /* Previne scroll bounce em iOS */
    }
    
    .chat-container {
        border-radius: 0;
        margin: 0;
        border: none;
        box-shadow: none;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }
    
    .chat-header {
        padding: 10px;
        height: auto; /* Altura dinâmica baseada no conteúdo */
    }
    
    .logo img {
        width: 40px;
        height: 40px;
        margin-right: 10px;
    }
    
    .logo h1 {
        font-size: 18px;
    }
    
    .status {
        font-size: 12px;
    }
    
    .chat-messages {
        padding: 12px;
        -webkit-overflow-scrolling: touch; /* Scroll suave em dispositivos iOS */
    }
    
    .chat-input {
        padding: 10px;
        position: relative;
        z-index: 10;
        background-color: var(--input-bg);
    }
    
    .chat-input input {
        padding: 10px 12px;
        height: auto;
        min-height: 40px;
    }
    
    .message {
        max-width: 80%;
        padding: 10px 12px;
    }
    
    .message-container {
        margin-bottom: 16px;
    }
}

/* Ajustes para telas menores */
@media (max-width: 480px) {
    .chat-header {
        padding: 8px;
    }
    
    .logo img {
        width: 36px;
        height: 36px;
        margin-right: 8px;
    }
    
    .chat-messages {
        padding: 10px;
    }
    
    .message {
        max-width: 85%;
    }
}

/* Ajustes específicos para dispositivos muito pequenos */
@media (max-width: 360px) {
    .chat-header {
        padding: 6px 8px;
    }
    
    .logo img {
        width: 32px;
        height: 32px;
        margin-right: 6px;
    }
    
    .logo h1 {
        font-size: 16px;
    }
    
    .status {
        font-size: 10px;
    }
    
    .chat-input {
        padding: 6px;
    }
    
    .chat-input input {
        padding: 8px 10px;
        font-size: 14px;
    }
    
    .chat-input button {
        width: 36px;
        height: 36px;
    }
    
    .message {
        padding: 8px 10px;
        font-size: 14px;
        max-width: 90%; /* Permitir mensagens mais largas em telas muito pequenas */
    }
    
    .message-container {
        margin-bottom: 12px;
    }
    
    .avatar {
        width: 30px;
        height: 30px;
        margin-right: 6px;
    }
}

/* Ajustes específicos para diferentes alturas de tela */
@media (max-height: 640px) {
    .logo h1 {
        font-size: 16px;
    }
    
    .header-controls button {
        width: 32px;
        height: 32px;
    }
    
    .message-container {
        margin-bottom: 10px;
    }
    
    .chat-input input {
        min-height: 36px;
    }
    
    .chat-input button {
        width: 36px;
        height: 36px;
    }
}

/* Ajustes para telas muito pequenas em altura */
@media (max-height: 480px) {
    .chat-header {
        padding: 4px 8px;
    }
    
    .logo img {
        width: 28px;
        height: 28px;
    }
    
    .logo h1 {
        font-size: 14px;
    }
    
    .status {
        font-size: 9px;
    }
    
    .chat-input {
        padding: 4px 6px;
    }
    
    .chat-input input {
        padding: 6px 10px;
        min-height: 32px;
    }
    
    .chat-input button {
        width: 32px;
        height: 32px;
    }
    
    .message {
        padding: 6px 8px;
        font-size: 13px;
    }
    
    .message-container {
        margin-bottom: 8px;
    }
}

/* Ajustes para modo paisagem em dispositivos móveis */
@media (max-height: 450px) and (orientation: landscape) {
    .chat-container {
        display: grid;
        grid-template-rows: auto 1fr auto;
        height: 100vh;
    }
    
    .chat-header {
        grid-row: 1;
        padding: 4px 8px;
        display: flex;
        align-items: center;
    }
    
    .logo img {
        width: 26px;
        height: 26px;
        margin-right: 6px;
    }
    
    .logo h1 {
        font-size: 14px;
        margin-bottom: 0;
    }
    
    .status {
        font-size: 9px;
    }
    
    .chat-messages {
        grid-row: 2;
        padding: 6px 10px;
        height: 100%;
    }
    
    .chat-input {
        grid-row: 3;
        padding: 4px 6px;
    }
    
    .message {
        padding: 6px 8px;
        font-size: 13px;
        max-width: 75%; /* Mensagens mais estreitas em modo paisagem */
    }
    
    .message-container {
        margin-bottom: 6px;
    }
}

/* Fix para teclado virtual em dispositivos móveis */
@media screen and (min-device-width: 375px) and (max-device-width: 812px) and (-webkit-min-device-pixel-ratio: 3) {
    .chat-container {
        height: -webkit-fill-available;
    }
}

/* Fix para visualização do viewport em dispositivos móveis */
@supports (-webkit-touch-callout: none) {
    .chat-container {
        height: -webkit-fill-available;
    }
    
    .chat-input input,
    .chat-input button {
        -webkit-appearance: none;
    }
}

/* Fix para problema de 100vh em navegadores móveis */
@supports (height: 100dvh) {
    .chat-container {
        height: 100dvh;
    }
}

/* Garantia de visibilidade para área de input quando o teclado virtual está aberto */
.input-visible {
    position: sticky;
    bottom: 0;
    z-index: 1000;
    background-color: var(--input-bg);
}

/* Adicionar classe utilitária para dispositivos baseados em toque */
@media (hover: none) and (pointer: coarse) {
    .chat-container {
        touch-action: manipulation;
    }
    
    .chat-input input {
        font-size: 16px; /* Prevenir zoom automático em inputs em iOS */
    }
}