/* Captura Contextual de Feedback — balão flutuante global */
/* Cores derivadas do design system (Bootstrap CSS variables) para suporte a tema claro/escuro. */

#cf-widget {
    --cf-primary: var(--bs-primary, #556ee6);
    /* Hover e tinta do launcher seguem a superfície sólida de ação do AI/R: no
       escuro ela clareia e a tinta escurece. Com a cor fixa em #fff o ícone
       sumia sobre o botão claro do modo escuro. */
    --cf-primary-dark: var(--air-accent-solid-hover, #3f56d6);
    --cf-on-primary: var(--air-on-accent, #fff);
    --cf-danger: var(--bs-danger, #f46a6a);
    --cf-text: var(--bs-body-color, #495057);
    --cf-muted: var(--bs-secondary-color, #74788d);
    --cf-border: var(--bs-border-color, #e9ebf0);
    --cf-bg: var(--bs-body-bg, #fff);
    --cf-bg-secondary: var(--bs-secondary-bg, #f8f9fa);
    --cf-backdrop: rgba(18, 38, 63, 0.35);
    --cf-backdrop-strong: rgba(18, 38, 63, 0.55);
    --cf-toast-bg: var(--bs-emphasis-color, #12263f);
    --cf-toast-text: var(--bs-body-bg, #fff);
    --cf-privacy-bg: var(--bs-warning-bg-subtle, #fff3cd);
    --cf-privacy-border: var(--bs-warning-border-subtle, #ffe69c);
    --cf-privacy-text: var(--bs-warning-text-emphasis, #8a6d3b);
    --cf-success-icon: var(--bs-success, #34c38f);
    --cf-redaction-fill: rgba(17, 24, 32, 0.6);
    --cf-redaction-solid: #111820;
}

/* Launcher recolhido */
.cf-launcher {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: var(--cf-primary);
    color: var(--cf-on-primary);
    font-size: 22px;
    line-height: 1;
    box-shadow: var(--air-shadow-md, 0 6px 18px rgba(85, 110, 230, 0.4));
    cursor: pointer;
    z-index: 10600;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, background 0.15s ease;
}

.cf-launcher:hover {
    background: var(--cf-primary-dark);
    transform: translateY(-2px);
}

/* Convite */
.cf-invite {
    position: fixed;
    right: 24px;
    bottom: 88px;
    width: 300px;
    max-width: calc(100vw - 48px);
    background: var(--cf-bg);
    border: 1px solid var(--cf-border);
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(18, 38, 63, 0.18);
    padding: 18px 18px 16px;
    z-index: 10600;
}

.cf-invite-title {
    font-weight: 600;
    color: var(--cf-text);
    margin-bottom: 6px;
    font-size: 15px;
}

.cf-invite-text {
    color: var(--cf-muted);
    font-size: 13px;
    margin-bottom: 14px;
}

.cf-invite .btn {
    width: 100%;
}

.cf-invite-close {
    position: absolute;
    top: 8px;
    right: 10px;
    border: none;
    background: transparent;
    font-size: 20px;
    line-height: 1;
    color: var(--cf-muted);
    cursor: pointer;
}

.cf-mute-link {
    display: block;
    width: 100%;
    margin-top: 10px;
    border: none;
    background: transparent;
    color: var(--cf-muted);
    font-size: 12px;
    text-decoration: underline;
    cursor: pointer;
}

/* Overlay de seleção */
.cf-select-overlay {
    position: fixed;
    inset: 0;
    z-index: 10650;
    cursor: crosshair;
    background: var(--cf-backdrop);
}

.cf-select-bar {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--cf-bg);
    border-radius: 30px;
    padding: 8px 16px;
    box-shadow: 0 6px 18px rgba(18, 38, 63, 0.2);
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13px;
    color: var(--cf-text);
    z-index: 10660;
}

.cf-select-rect {
    position: fixed;
    border: 2px solid var(--cf-primary);
    background: rgba(85, 110, 230, 0.12);
    box-shadow: 0 0 0 100000px var(--cf-backdrop);
    z-index: 10655;
    pointer-events: none;
}

/* Modal de revisão / sucesso */
.cf-modal {
    position: fixed;
    inset: 0;
    z-index: 10700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cf-modal-backdrop {
    position: absolute;
    inset: 0;
    background: var(--cf-backdrop-strong);
}

.cf-modal-dialog {
    position: relative;
    width: 560px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 48px);
    background: var(--cf-bg);
    border-radius: 12px;
    box-shadow: 0 18px 50px rgba(18, 38, 63, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.cf-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: calc(100vh - 48px);
}

.cf-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--cf-border);
}

.cf-panel-title {
    font-weight: 600;
    color: var(--cf-text);
}

.cf-panel-body {
    padding: 16px 18px;
    overflow-y: auto;
}

.cf-panel-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid var(--cf-border);
}

.cf-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--cf-text);
    margin-bottom: 4px;
    margin-top: 10px;
}

.cf-panel-body > .cf-label:first-child {
    margin-top: 0;
}

.cf-icon-btn {
    border: none;
    background: transparent;
    font-size: 22px;
    line-height: 1;
    color: var(--cf-muted);
    cursor: pointer;
}

.cf-error {
    color: var(--cf-danger);
    font-size: 12px;
    margin-top: 4px;
}

.cf-privacy {
    background: var(--cf-privacy-bg);
    border: 1px solid var(--cf-privacy-border);
    color: var(--cf-privacy-text);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12px;
    margin: 8px 0;
}

.cf-redact-hint {
    font-size: 11px;
    color: var(--cf-muted);
    margin-bottom: 6px;
}

.cf-screenshot-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
}

.cf-screenshot-actions {
    display: flex;
    gap: 6px;
}

.cf-canvas-wrap {
    border: 1px solid var(--cf-border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--cf-bg-secondary);
}

#cf-canvas {
    display: block;
    width: 100%;
    height: auto;
    cursor: crosshair;
}

.cf-noshot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--cf-bg-secondary);
    border: 1px dashed var(--cf-border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12px;
    color: var(--cf-muted);
    margin-top: 10px;
}

.cf-context {
    font-size: 12px;
    color: var(--cf-muted);
    margin-top: 12px;
    word-break: break-all;
}

.cf-success-body {
    text-align: center;
    padding: 28px 18px 8px;
}

.cf-success-icon {
    font-size: 46px;
    color: var(--cf-success-icon);
    line-height: 1;
}

.cf-success-title {
    font-weight: 600;
    font-size: 17px;
    color: var(--cf-text);
    margin-top: 6px;
}

.cf-success-number {
    color: var(--cf-muted);
    margin-top: 4px;
    font-size: 14px;
}

.cf-hide {
    display: none !important;
}

/* Toast (mensagem de reativação / estado do balão) */
.cf-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translate(-50%, 20px);
    max-width: min(420px, calc(100vw - 48px));
    background: var(--cf-toast-bg);
    color: var(--cf-toast-text);
    font-size: 13px;
    line-height: 1.4;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 10px 26px rgba(18, 38, 63, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 10800;
}

.cf-toast-show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* Seção de Configurações (barra lateral da engrenagem) */
.cf-settings-hint {
    font-size: 12px;
    margin-bottom: 12px;
}

.cf-settings-shortcut {
    font-size: 12px;
}

.cf-kbd {
    font-size: 11px;
    border-radius: 4px;
}

/* Reserva de espaço no rodapé para o balão flutuante.
   O launcher .cf-launcher tem 52px de largura e fica a 24px da borda direita,
   ocupando o intervalo right:24px..right:76px. O bloco de texto direito do
   rodapé precisa de margem mínima para não ficar por baixo do balão.
   52px (launcher) + 24px (offset) + 16px (buffer) = 92px → arredondado para
   100px. Em telas onde as colunas empilham (col-sm-6 → bloco inteiro), a
   margem não causa problema porque o balão sai da área de sobreposição. */
.footer .text-sm-end {
    margin-right: 100px;
}

@media (max-width: 575.98px) {
    /* Em telas pequenas as colunas empilham e o texto ocupa a largura total.
       O balão ainda pode sobrepor o texto alinhado à direita — reduzir a
       margem para o mínimo que o Bootstrap já aplica (15px gutter da grid)
       mais um pequeno buffer. */
    .footer .text-sm-end {
        margin-right: 80px;
    }
}

@media (min-width: 576px) and (max-width: 991.98px) {
    /* Tablet: margem completa mantém o texto afastado do balão. */
    .footer .text-sm-end {
        margin-right: 100px;
    }
}

/* Painel lateral aberto à direita (offcanvas ou folha AI/R): o balão sai da faixa do painel,
   para a esquerda. A largura vem do painel aberto (--cf-panel-shift, contextual-feedback.init.js). */
body.cf-panel-open .cf-launcher,
body.cf-panel-open .cf-invite {
    transform: translateX(var(--cf-panel-shift, 0px));
    transition: transform 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
    body.cf-panel-open .cf-launcher,
    body.cf-panel-open .cf-invite {
        transition: none;
    }
}
