/* Chat flutuante com IA — tema Catellix */
#catellix-chat-root {
    --chat-bg: #060b12;
    --chat-card: #0a111c;
    --chat-border: #1a2840;
    --chat-accent: #00A3FF;
    --chat-accent-dim: rgba(0, 163, 255, 0.2);
    --chat-text: #e8ecf1;
    --chat-muted: #8b9cad;
    font-family: 'Outfit', 'Segoe UI', sans-serif;
}

#catellix-chat-root .chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-accent), #0074D4);
    border: none;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 163, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    transition: transform 0.2s, box-shadow 0.2s;
}

#catellix-chat-root .chat-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(0, 163, 255, 0.5);
}

#catellix-chat-root .chat-toggle svg {
    width: 28px;
    height: 28px;
}

#catellix-chat-root .chat-panel {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 480px;
    max-height: calc(100vh - 140px);
    background: var(--chat-card);
    border: 1px solid var(--chat-border);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
}

#catellix-chat-root .chat-panel.hidden {
    display: none;
}

#catellix-chat-root .chat-header {
    padding: 14px 16px;
    background: linear-gradient(180deg, rgba(0, 163, 255, 0.12), transparent);
    border-bottom: 1px solid var(--chat-border);
    font-weight: 600;
    color: var(--chat-text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

#catellix-chat-root .chat-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

/* Símbolo Aurix dourado (igual ao login Proxy) — 3 círculos girando */
#catellix-chat-root .chat-aurix-orb {
    width: 22px;
    height: 22px;
    position: relative;
    flex-shrink: 0;
}

#catellix-chat-root .chat-aurix-orb .circle {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid transparent;
    box-sizing: border-box;
    display: block;
}

#catellix-chat-root .chat-aurix-orb .circle:nth-child(1) {
    border-top-color: #d4af37;
    animation: chat-aurix-spin 1s linear infinite;
}

#catellix-chat-root .chat-aurix-orb .circle:nth-child(2) {
    border-right-color: #e6c547;
    animation: chat-aurix-spin 1s linear infinite reverse;
    animation-delay: 0.15s;
}

#catellix-chat-root .chat-aurix-orb .circle:nth-child(3) {
    width: 60%;
    height: 60%;
    top: 20%;
    left: 20%;
    border-bottom-color: #c9a227;
    animation: chat-aurix-spin 0.9s linear infinite;
}

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

#catellix-chat-root .chat-header svg {
    width: 20px;
    height: 20px;
    color: var(--chat-accent);
    flex-shrink: 0;
}

#catellix-chat-root .chat-header-badge {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 500;
    color: var(--chat-accent);
    background: var(--chat-accent-dim);
    padding: 4px 8px;
    border-radius: 8px;
    white-space: nowrap;
}

#catellix-chat-root .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#catellix-chat-root .chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

#catellix-chat-root .chat-msg.user {
    align-self: flex-end;
    background: var(--chat-accent-dim);
    border: 1px solid var(--chat-accent);
    color: var(--chat-text);
}

#catellix-chat-root .chat-msg.assistant {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--chat-border);
    color: var(--chat-text);
}

#catellix-chat-root .chat-msg.error {
    align-self: flex-start;
    background: rgba(220, 53, 69, 0.15);
    border: 1px solid rgba(220, 53, 69, 0.5);
    color: #f8b4b4;
}

#catellix-chat-root .chat-msg.typing {
    color: var(--chat-muted);
    font-style: italic;
}

#catellix-chat-root .chat-form {
    padding: 12px;
    border-top: 1px solid var(--chat-border);
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#catellix-chat-root .chat-input {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    padding: 10px 14px;
    border: 1px solid var(--chat-border);
    border-radius: 10px;
    background: var(--chat-bg);
    color: var(--chat-text);
    font-size: 14px;
    font-family: inherit;
    resize: none;
}

#catellix-chat-root .chat-input::placeholder {
    color: var(--chat-muted);
}

#catellix-chat-root .chat-input:focus {
    outline: none;
    border-color: var(--chat-accent);
    box-shadow: 0 0 0 2px var(--chat-accent-dim);
}

#catellix-chat-root .chat-send {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: none;
    background: var(--chat-accent);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#catellix-chat-root .chat-send:hover:not(:disabled) {
    filter: brightness(1.1);
}

#catellix-chat-root .chat-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#catellix-chat-root .chat-send svg {
    width: 20px;
    height: 20px;
}

#catellix-chat-root .chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

#catellix-chat-root .chat-messages::-webkit-scrollbar-thumb {
    background: var(--chat-border);
    border-radius: 3px;
}

#catellix-chat-root .chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--chat-accent);
}

/* ── Formulário de contato dentro do chat ─────────────────────────── */
#catellix-chat-root .chat-contact-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#catellix-chat-root .chat-contact-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--chat-accent);
    margin: 0 0 2px 0;
}

#catellix-chat-root .chat-contact-subtitle {
    font-size: 12px;
    color: var(--chat-muted);
    margin: 0 0 4px 0;
    line-height: 1.4;
}

#catellix-chat-root .chat-contact-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--chat-muted);
    margin: 4px 0 0 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#catellix-chat-root .chat-contact-select,
#catellix-chat-root .chat-contact-email,
#catellix-chat-root .chat-contact-msg {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--chat-border);
    border-radius: 8px;
    background: var(--chat-bg);
    color: var(--chat-text);
    font-size: 13px;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

#catellix-chat-root .chat-contact-select:focus,
#catellix-chat-root .chat-contact-email:focus,
#catellix-chat-root .chat-contact-msg:focus {
    outline: none;
    border-color: var(--chat-accent);
    box-shadow: 0 0 0 2px var(--chat-accent-dim);
}

#catellix-chat-root .chat-contact-select option {
    background: var(--chat-card);
    color: var(--chat-text);
}

#catellix-chat-root .chat-contact-msg {
    resize: vertical;
    min-height: 60px;
    max-height: 120px;
}

#catellix-chat-root .chat-contact-email::placeholder,
#catellix-chat-root .chat-contact-msg::placeholder {
    color: var(--chat-muted);
}

#catellix-chat-root .chat-contact-prazo {
    font-size: 12px;
    color: var(--chat-muted);
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s, padding 0.3s;
}

#catellix-chat-root .chat-contact-prazo.show {
    max-height: 32px;
    padding: 4px 0;
    color: #22d3ee;
}

#catellix-chat-root .chat-contact-send {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--chat-accent), #0074D4);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    margin-top: 4px;
    transition: filter 0.2s, opacity 0.2s;
}

#catellix-chat-root .chat-contact-send:hover:not(:disabled) {
    filter: brightness(1.1);
}

#catellix-chat-root .chat-contact-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#catellix-chat-root .chat-contact-status {
    font-size: 12px;
    min-height: 0;
    transition: all 0.2s;
}

#catellix-chat-root .chat-contact-status.error {
    color: #f87171;
    padding-top: 4px;
}

/* Sucesso */
#catellix-chat-root .chat-contact-success {
    text-align: center;
    padding: 8px 0;
}

#catellix-chat-root .chat-contact-success-icon {
    font-size: 32px;
    margin: 0 0 4px 0;
}

#catellix-chat-root .chat-contact-success-title {
    font-size: 16px;
    font-weight: 700;
    color: #22d3ee;
    margin: 0 0 6px 0;
}

#catellix-chat-root .chat-contact-success-text {
    font-size: 13px;
    color: var(--chat-text);
    margin: 0 0 8px 0;
    line-height: 1.5;
}

#catellix-chat-root .chat-contact-success-hint {
    font-size: 12px;
    color: var(--chat-muted);
    margin: 0;
}

/* ── Tabela de planos dentro do chat ──────────────────────────────── */
#catellix-chat-root .chat-plans-table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 12px;
    border-radius: 8px;
    overflow: hidden;
}

#catellix-chat-root .chat-plans-table th {
    background: rgba(218, 165, 32, 0.2);
    color: #daa520;
    padding: 6px 8px;
    text-align: left;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid rgba(218, 165, 32, 0.3);
}

#catellix-chat-root .chat-plans-table td {
    padding: 5px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--chat-text);
}

#catellix-chat-root .chat-plans-table tr:hover td {
    background: rgba(255, 255, 255, 0.04);
}

#catellix-chat-root .chat-plans-table .plan-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

#catellix-chat-root .chat-plans-table .badge-free { background: rgba(34, 211, 238, 0.2); color: #22d3ee; }
#catellix-chat-root .chat-plans-table .badge-basic { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
#catellix-chat-root .chat-plans-table .badge-pro { background: rgba(168, 85, 247, 0.2); color: #c084fc; }
#catellix-chat-root .chat-plans-table .badge-adv { background: rgba(249, 115, 22, 0.2); color: #fb923c; }
#catellix-chat-root .chat-plans-table .badge-unl { background: rgba(218, 165, 32, 0.2); color: #daa520; }

#catellix-chat-root .chat-plans-table .plan-price {
    font-weight: 700;
    color: #22d3ee;
}

#catellix-chat-root .chat-plans-table .plan-free {
    font-weight: 700;
    color: #4ade80;
}

#catellix-chat-root .chat-plans-cta {
    display: inline-block;
    margin-top: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #daa520, #b8860b);
    color: #0b1120;
    font-weight: 700;
    font-size: 13px;
    border-radius: 8px;
    text-decoration: none;
    text-align: center;
    transition: opacity 0.2s;
}

#catellix-chat-root .chat-plans-cta:hover {
    opacity: 0.85;
}

/* ── Dica de suporte dentro do chat ──────────────────────────────── */
#catellix-chat-root .chat-support-hint {
    margin-top: 8px;
    padding: 8px 10px;
    background: rgba(218, 165, 32, 0.08);
    border-left: 3px solid #daa520;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--chat-muted);
}

#catellix-chat-root .chat-support-hint strong {
    color: var(--chat-text);
}

/* ── Tabela de planos: scroll horizontal em mobile ── */
@media (max-width: 768px) {
    #catellix-chat-root .chat-plans-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ── Responsividade: chat flutuante em dispositivos móveis (evitar estourar) ── */
@media (max-width: 768px) {
    #catellix-chat-root {
        position: fixed;
        inset: 0;
        pointer-events: none;
        z-index: 9998;
        overflow: hidden;
    }
    #catellix-chat-root * {
        box-sizing: border-box;
    }
    #catellix-chat-root .chat-toggle {
        pointer-events: auto;
        bottom: max(20px, env(safe-area-inset-bottom));
        right: max(16px, env(safe-area-inset-right));
        width: 52px;
        height: 52px;
    }
    #catellix-chat-root .chat-panel {
        pointer-events: auto;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-width: 100vw !important;
        height: min(85vh, 85dvh) !important;
        max-height: min(85vh, 85dvh) !important;
        border-radius: 16px 16px 0 0;
        box-sizing: border-box;
        margin: 0;
        overflow: hidden;
    }
    #catellix-chat-root .chat-header {
        padding: 12px max(16px, env(safe-area-inset-left)) 12px max(16px, env(safe-area-inset-right));
        flex-wrap: wrap;
        gap: 6px;
    }
    #catellix-chat-root .chat-header-left {
        font-size: 13px;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    #catellix-chat-root .chat-header-badge {
        font-size: 10px;
        padding: 3px 6px;
    }
    #catellix-chat-root .chat-messages {
        padding: 10px max(12px, env(safe-area-inset-left)) 10px max(12px, env(safe-area-inset-right));
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    #catellix-chat-root .chat-msg {
        max-width: 92%;
    }
    #catellix-chat-root .chat-form {
        padding: 10px max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-right));
    }
    #catellix-chat-root .chat-input {
        min-height: 40px;
        font-size: 16px; /* evita zoom no iOS ao focar */
    }
    #catellix-chat-root .chat-contact-form,
    #catellix-chat-root .chat-contact-select,
    #catellix-chat-root .chat-contact-email,
    #catellix-chat-root .chat-contact-msg {
        max-width: 100%;
        box-sizing: border-box;
    }
}

@media (max-width: 480px) {
    #catellix-chat-root .chat-panel {
        height: min(90vh, 90dvh) !important;
        max-height: min(90vh, 90dvh) !important;
    }
    #catellix-chat-root .chat-toggle {
        bottom: max(12px, env(safe-area-inset-bottom));
        right: max(12px, env(safe-area-inset-right));
        width: 48px;
        height: 48px;
    }
    #catellix-chat-root .chat-toggle svg {
        width: 24px;
        height: 24px;
    }
}
