:root {
    /* Brand Colors - Lightened for User Comfort */
    --primary-color: #004AAD; /* Clearer Blue */
    --primary-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); /* Bright Cyan-Blue */
    --accent-color: #007bff;

    /* Backgrounds - Lighter */
    --bg-body: #F0F2F5; /* Light Gray-Blue */
    --bg-chat: #ffffff; /* Clean White */
    --bg-header: #ffffff;

    /* Text - High Contrast */
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-dark: #1a1a1a;

    /* Messages */
    --bot-msg-bg: #E4E6EB; /* Light Gray */
    --bot-msg-text: #050505;
    --user-msg-bg: #0084FF; /* Messenger Blue */
    --user-msg-text: #ffffff;

    /* UI */
    --border-radius: 18px;
    --input-height: 60px;
    --shadow-soft: 0 4px 12px rgba(0,0,0,0.1);
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden; /* Prevent body scroll */
}

body {
    background: var(--bg-body);
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
}

/* Global Header Fix */
.global-header {
    flex-shrink: 0;
}

/* Texture Pattern for Chat Background */
.chat-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    height: 100%; /* Fill remaining height */
    flex-grow: 1;
    min-height: 0; /* Crucial for nested flex scrolling */
    background-color: #ffffff;
    background-image: radial-gradient(#e5e7eb 1px, transparent 1px);
    background-size: 20px 20px; /* Subtle dots texture */
    box-shadow: 0 0 30px rgba(0,0,0,0.05);
    position: relative;
    border-left: 1px solid rgba(0,0,0,0.05);
    border-right: 1px solid rgba(0,0,0,0.05);
}

/* LGPD Notice */
.lgpd-notice {
    background-color: #fff3cd;
    color: #856404;
    padding: 10px 15px;
    font-size: 12px;
    text-align: center;
    border-bottom: 1px solid #ffeeba;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    line-height: 1.4;
    flex-shrink: 0;
    transition: opacity 0.5s ease;
}

.lgpd-notice.hidden-fade {
    opacity: 0;
    pointer-events: none;
    display: none;
}

.lgpd-notice i {
    font-size: 14px;
}

/* --- Header --- */
.chat-header {
    background-color: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    padding: 15px 25px;
    border-bottom: 1px solid #e5e5e5;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0; /* Don't shrink */
}

.brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.agent-info {
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #333;
    font-weight: 700;
}

.status-dot {
    width: 10px;
    height: 10px;
    background-color: #31a24c;
    border-radius: 50%;
    box-shadow: 0 0 5px rgba(49, 162, 76, 0.5);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(49, 162, 76, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(49, 162, 76, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(49, 162, 76, 0); }
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 14px;
    color: #666;
}

.progress-bar-bg {
    flex-grow: 1;
    height: 8px;
    background-color: #e5e5e5;
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--user-msg-bg);
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Chat Area --- */
/* Wrapper landmark (<main>) around .chat-messages: mantém o comportamento de flex/scroll */
.chat-messages-landmark {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0;
    overflow: hidden;
}

.chat-messages {
    flex-grow: 1;
    overflow-y: auto; /* Enable internal scrolling */
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
    padding-bottom: 25px;
    /* height: 100%; Removed to prevent overflow issues with flex-grow */
}

/* Custom Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 4px;
}

/* Extra space at bottom to prevent sticking to input */
.chat-messages::after {
    content: "";
    display: block;
    height: 120px; /* Ensure enough space for fixed input area */
    flex-shrink: 0;
    width: 100%;
}

.message {
    max-width: 85%;
    padding: 18px 22px;
    border-radius: var(--border-radius);
    font-size: 18px;
    line-height: 1.6;
    position: relative;
    opacity: 0;
    transform: translateY(20px);
    animation: messageEntry 0.4s cubic-bezier(0.19, 1, 0.22, 1) forwards;
    word-wrap: break-word;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* Markdown Styles inside Messages */
.message p {
    margin: 0 0 10px 0;
}
.message p:last-child {
    margin-bottom: 0;
}
.message strong {
    font-weight: 700;
}
.message ul, .message ol {
    margin: 5px 0 10px 0;
    padding-left: 20px;
}
.message li {
    margin-bottom: 5px;
}

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

.message.bot {
    align-self: flex-start;
    background-color: var(--bot-msg-bg);
    color: var(--bot-msg-text);
    border-bottom-left-radius: 4px;
}

.message.user {
    align-self: flex-end;
    background: var(--user-msg-bg);
    color: var(--user-msg-text);
    border-bottom-right-radius: 4px;
    text-align: right;
}

/* Typing Indicator */
.typing-indicator {
    padding: 15px 20px;
    background-color: #E4E6EB;
    border-radius: var(--border-radius);
    align-self: flex-start;
    display: none;
    gap: 6px;
}

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

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

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

/* --- Input Area --- */
.chat-input-area {
    padding: 20px 25px;
    background: rgba(255, 255, 255, 0.98);
    border-top: 1px solid #e5e5e5;
    z-index: 100;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.03);
    flex-shrink: 0;
    max-height: 85vh; /* Prevent taking full screen */
    overflow-y: auto; /* Allow scroll if content is too tall */
}

/* Custom Scrollbar for Input Area */
.chat-input-area::-webkit-scrollbar {
    width: 6px;
}
.chat-input-area::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.2);
    border-radius: 3px;
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

/* Finalization progress bar (mesma linguagem visual do overlay de
   processamento do formulário), exibida na barra inferior do chat enquanto
   o pedido é enviado/processado. */
.chat-processing-bar {
    width: 100%;
    padding: 6px 4px;
}

.chat-processing-text {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--user-msg-bg, #0084ff);
    font-weight: 600;
    margin-bottom: 10px;
    text-align: center;
}

.chat-processing-progress {
    height: 14px;
    background-color: #e5e5e5;
    border-radius: 8px;
    overflow: hidden;
}

.chat-processing-progress .progress-bar {
    transition: width 0.4s ease;
}

.chat-processing-percent {
    margin-top: 6px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: #666;
}

/* Text Input */
.chat-input-text {
    width: 100%;
    height: 55px;
    padding: 0 20px;
    background: #f0f2f5;
    border: 2px solid transparent;
    border-radius: 30px;
    font-size: 18px;
    color: #333;
    outline: none;
    transition: all 0.2s;
}

.chat-input-text::placeholder {
    color: #999;
}

.chat-input-text:focus {
    background: #fff;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.1);
}

/* Buttons */
.chat-btn {
    height: 55px;
    padding: 0 30px;
    background: var(--user-msg-bg);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 10px rgba(0, 132, 255, 0.3);
    min-width: 120px;
}

.chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 132, 255, 0.4);
    background: #0073e6;
}

.chat-btn:active {
    transform: scale(0.98);
}

.chat-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.4);
}

.chat-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* O botão "Enviar" fica esmaecido (opacity: .65) quando desabilitado, o que
   deixa o spinner de carregamento pequeno e apagado demais para ser
   reconhecido como um ícone circular. Mantemos opacidade total e um traço
   mais grosso enquanto está em estado de carregamento. */
/* Especificidade elevada de propósito: o botão "Enviar" real usa as classes
   "chat-btn glass-btn" simultaneamente, e ".glass-btn:disabled" (mais abaixo
   neste arquivo) empata em especificidade com uma regra de duas classes só
   — nesse empate, quem vem depois no arquivo vence, reaplicando opacity:.65
   e esmaecendo o spinner de novo. Encadear as três classes evita depender
   da ordem das regras no arquivo. */
.chat-btn.glass-btn.is-loading,
.chat-btn.is-loading {
    opacity: 1;
    cursor: wait;
}

/* O spinner-border padrão do Bootstrap é um anel de duas cores só (traço
   sólido + metade transparente): em tamanho pequeno isso engana o olho e
   parece "balançar" em vez de girar, mesmo com o eixo de rotação
   matematicamente centralizado. Trocamos o miolo por um degradê cônico
   (mascarado para formar um anel), que gira de forma visualmente contínua
   e inequívoca — sem depender de nenhuma fonte de ícone externa. */
.chat-btn.is-loading .spinner-border {
    width: 1.2rem;
    height: 1.2rem;
    border: none;
    border-radius: 50%;
    vertical-align: -0.25em;
    background: conic-gradient(from 0deg, transparent 0deg, currentColor 320deg, currentColor 360deg);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
    animation: chat-spin-smooth 0.8s linear infinite;
}

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

.chat-btn-secondary {
    background: #f0f2f5;
    color: #333;
    box-shadow: none;
}
.chat-btn-secondary:hover {
    background: #e4e6eb;
}

/* Option Buttons Grid */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    padding-bottom: 5px; /* Spacing */
}

/* Colorful Option Buttons */
.option-btn {
    padding: 20px;
    background: #ffffff;
    border: 1px solid #e5e5e5;
    border-radius: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #333;
    font-size: 16px;
    font-weight: 500;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.option-btn:hover {
    border-color: var(--accent-color);
    background: #f8fbff;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.option-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.4);
}

.option-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.option-btn i {
    font-size: 28px;
    color: var(--accent-color);
}

/* Special styling for specific options if needed */
.option-btn:nth-child(1) i { color: #007bff; }
.option-btn:nth-child(2) i { color: #28a745; }
.option-btn:nth-child(3) i { color: #fd7e14; }

/* Carousel Container and Navigation */
.carousel-container {
    position: relative;
    width: 100%;
    margin-bottom: 10px;
}

/* Plan Cards */
.plan-carousel {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding: 10px 5px 25px 5px;
    align-items: stretch;
    margin: 0 -10px;
    padding-left: 10px;
    padding-right: 10px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Hide scrollbar Firefox */
}
.plan-carousel::-webkit-scrollbar {
    display: none; /* Hide scrollbar Chrome/Safari */
}

.carousel-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s;
    color: var(--primary-color);
    font-size: 20px;
}

.carousel-nav-btn:hover {
    background: #fff;
    box-shadow: 0 6px 18px rgba(0,0,0,0.2);
    transform: translateY(-50%) scale(1.05);
}

.carousel-nav-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.4);
}

.carousel-nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: translateY(-50%);
    box-shadow: none;
}

.carousel-nav-btn.prev {
    left: -15px;
}

.carousel-nav-btn.next {
    right: -15px;
}

.plan-card {
    min-width: 280px;
    background: #ffffff;
    border: 1px solid #e5e5e5;
    border-radius: 20px;
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    transition: all 0.3s;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.plan-card:hover {
    transform: translateY(-8px);
    border-color: var(--accent-color);
    box-shadow: 0 15px 30px rgba(0,0,0,0.1);
}

.plan-name {
    font-weight: 800;
    color: var(--primary-color);
    font-size: 22px;
}

.plan-speed {
    font-size: 32px;
    font-weight: 800;
    color: #333;
}

.plan-price {
    color: #FF6600;
    font-weight: 700;
    font-size: 26px;
}

.plan-benefits {
    list-style: none;
    padding: 0;
    margin: 15px 0;
    font-size: 15px;
    color: #555;
    max-height: 200px; /* Limit benefits height */
    overflow-y: auto; /* Scroll if too many items */
}
/* Custom Scrollbar for Benefits */
.plan-benefits::-webkit-scrollbar {
    width: 4px;
}
.plan-benefits::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 2px;
}

.plan-benefits li {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.plan-benefits i {
    color: #FF6600;
    font-size: 18px;
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed #ccc;
    border-radius: 20px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: #f9f9f9;
}

.upload-zone:hover {
    border-color: var(--accent-color);
    background: #f0f8ff;
}

.upload-zone:focus-visible {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.2);
}

.upload-zone i {
    font-size: 48px;
    color: var(--accent-color);
    margin-bottom: 10px;
    display: block;
}

.upload-preview {
    max-width: 100%;
    max-height: 250px;
    margin-top: 15px;
    border-radius: 10px;
    border: 1px solid #ddd;
    display: none;
}

/* Summary Box */
.summary-box {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    font-size: 16px;
    margin-bottom: 15px;
}
.summary-box h5 {
    color: var(--primary-color);
    font-weight: 700;
    margin-bottom: 15px;
}

/* Canvas Signature */
#signature-canvas {
    background: #fff;
    cursor: crosshair;
}

/* Toast Notification */
.toast-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    z-index: 2000;
    font-size: 15px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 90%;
    text-align: center;
}

.toast-notification.show {
    top: 30px;
    opacity: 1;
    visibility: visible;
}

.toast-notification.error { background: #dc3545; }
.toast-notification.success { background: #28a745; }
.toast-notification.warning { background: #ffc107; color: #333; }

/* Utilities */
.hidden { display: none; }
.text-center { text-align: center; }

/* Responsive */
@media (max-width: 576px) {
    .chat-container {
        border: none;
        max-width: 100%;
        min-height: 0; /* Reset */
        height: 100%; /* Keep full height */
    }

    .message {
        font-size: 16px;
        padding: 15px;
        max-width: 90%;
    }

    .chat-header {
        padding: 10px 15px;
    }

    .chat-input-area {
        padding: 15px;
        max-height: 60vh; /* Better mobile height limit */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Ensure no overlap on mobile keyboard open */
    .chat-messages {
        padding-bottom: 25px;
    }

    .chat-btn {
        height: 50px;
        font-size: 16px;
    }

    /* Plan Card Mobile Optims */
    .plan-card {
        min-width: 240px;
        padding: 15px;
        gap: 10px;
    }

    .plan-name { font-size: 18px; }
    .plan-speed { font-size: 24px; }
    .plan-price { font-size: 22px; }
    .plan-benefits {
        max-height: 120px;
        font-size: 13px;
    }

    /* Keep buttons on mobile but adjust */
    .carousel-nav-btn {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    .carousel-nav-btn.prev { left: -5px; }
    .carousel-nav-btn.next { right: -5px; }

    /* Upload Zone Mobile */
    .upload-zone {
        padding: 20px;
    }
    .upload-zone i {
        font-size: 32px;
    }

    /* Compact Option Buttons for Mobile */
    .option-btn {
        padding: 12px;
        font-size: 14px;
        gap: 6px;
    }
    .option-btn i {
        font-size: 20px;
    }
    .options-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 10px;
    }
}

/* Glass Button Styles */
.glass-btn {
    background: linear-gradient(135deg, #004AAD 0%, #007bff 100%);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    color: white;
}

.glass-btn:hover {
    background: linear-gradient(135deg, #003380 0%, #0056b3 100%);
    transform: translateY(-2px);
    box-shadow: 0 10px 40px 0 rgba(31, 38, 135, 0.45);
}

.glass-btn:active {
    transform: scale(0.98);
}

.glass-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Secondary Glass Button */
.chat-btn-secondary.glass-btn {
    background: rgba(240, 242, 245, 0.8);
    color: #333;
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.chat-btn-secondary.glass-btn:hover {
     background: rgba(240, 242, 245, 1);
     box-shadow: 0 6px 20px rgba(0,0,0,0.1);
}

/* Option Button Glass */
.option-btn.glass-btn {
    background: rgba(255, 255, 255, 0.9); /* Slightly more opaque */
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid rgba(0, 74, 173, 0.2); /* Slight border for visibility */
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    color: #333 !important; /* Force dark text */
}

.option-btn.glass-btn:hover {
    background: rgba(255, 255, 255, 1);
    border-color: var(--accent-color);
    box-shadow: 0 8px 25px rgba(0, 123, 255, 0.15);
    transform: translateY(-2px);
}

/* Input Error State */
.input-error {
    border-color: #dc3545 !important;
    background-color: #fff8f8 !important;
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}
