/* CS9 Pay - design system sóbrio, inspirado em Nubank (roxo/branco/cinza, sem degradê) */

:root {
    --roxo: #820ad1;
    --roxo-escuro: #5f0797;
    --roxo-claro: #f2e6fb;
    --cinza-900: #1a1a2e;
    --cinza-700: #45455c;
    --cinza-500: #6b6b80;
    --cinza-300: #d8d8e2;
    --cinza-100: #f4f4f8;
    --branco: #ffffff;
    --verde: #00a86b;
    --amarelo: #b8860b;
    --vermelho: #c0392b;
    --azul: #2a6fdb;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(26, 26, 46, 0.08), 0 1px 2px rgba(26, 26, 46, 0.06);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--cinza-100);
    color: var(--cinza-900);
    line-height: 1.5;
}

a { color: var(--roxo); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { color: var(--cinza-900); margin-top: 0; }

/* ---------------------------------------------------------------- */
/* Layout                                                            */
/* ---------------------------------------------------------------- */
.topbar {
    background: var(--branco);
    border-bottom: 1px solid var(--cinza-300);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.topbar .logo {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--roxo);
    letter-spacing: -0.02em;
}

.topbar nav a {
    color: var(--cinza-700);
    margin-left: 20px;
    font-weight: 500;
}

.topbar nav a.active { color: var(--roxo); }

.layout {
    display: flex;
    min-height: calc(100vh - 64px);
}

.sidebar {
    width: 220px;
    background: var(--branco);
    border-right: 1px solid var(--cinza-300);
    padding: 20px 12px;
    flex-shrink: 0;
}

.sidebar a {
    display: block;
    padding: 10px 14px;
    border-radius: var(--radius);
    color: var(--cinza-700);
    font-weight: 500;
    margin-bottom: 4px;
}

.sidebar a:hover { background: var(--cinza-100); text-decoration: none; }
.sidebar a.active { background: var(--roxo-claro); color: var(--roxo-escuro); }

.content {
    flex: 1;
    padding: 32px;
    max-width: 1100px;
    margin: 0 auto;
}

/* ---------------------------------------------------------------- */
/* Navegação do cliente: abas de categoria (topo) + barra inferior   */
/* de ícones (Início / OTC / Banco / Perfil) — substitui a sidebar   */
/* lateral só nas páginas do cliente (o admin continua com .sidebar) */
/* ---------------------------------------------------------------- */
.content-wrapper {
    min-height: calc(100vh - 64px);
    padding-bottom: 88px;
}

.category-tabs {
    background: var(--branco);
    border-bottom: 1px solid var(--cinza-300);
    display: flex;
    gap: 4px;
    padding: 0 24px;
    overflow-x: auto;
}

.category-tabs a {
    padding: 14px 16px;
    color: var(--cinza-700);
    font-weight: 500;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}

.category-tabs a:hover { color: var(--roxo); text-decoration: none; }
.category-tabs a.active { color: var(--roxo); border-bottom-color: var(--roxo); font-weight: 700; }

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--roxo);
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px calc(8px + env(safe-area-inset-bottom, 0px));
    z-index: 30;
}

.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: rgba(255, 255, 255, 0.68);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 6px 20px;
    border-radius: var(--radius);
    min-width: 64px;
}

.bottom-nav a svg { display: block; }
.bottom-nav a:hover { background: rgba(255, 255, 255, 0.12); color: var(--branco); text-decoration: none; }
.bottom-nav a.active { color: var(--branco); background: rgba(255, 255, 255, 0.18); }

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

/* ---------------------------------------------------------------- */
/* Componentes                                                        */
/* ---------------------------------------------------------------- */
.card {
    background: var(--branco);
    border: 1px solid var(--cinza-300);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
    margin-bottom: 20px;
}

.card-sm { padding: 18px 20px; }

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--cinza-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 12px;
}

.card-saldo {
    border-top: 4px solid var(--roxo);
    border-top-left-radius: var(--radius);
    border-top-right-radius: var(--radius);
}

.card-saldo-header {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--cinza-700);
    font-weight: 700;
    margin-bottom: 20px;
}

.card-saldo-header svg { color: var(--roxo); flex-shrink: 0; }

.card-saldo-label {
    color: var(--cinza-500);
    margin: 0 0 4px;
}

.card-saldo-valor {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--cinza-900);
    margin-bottom: 16px;
}

.grid {
    display: grid;
    gap: 20px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 720px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .layout { flex-direction: column; }

    .sidebar {
        width: auto;
        display: flex;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        padding: 10px 12px;
        gap: 6px;
        border-right: none;
        border-bottom: 1px solid var(--cinza-300);
    }

    .sidebar a {
        flex-shrink: 0;
        white-space: nowrap;
        margin-bottom: 0;
        font-size: 0.85rem;
        padding: 8px 14px;
    }

    .content { padding: 20px 16px; }
}

label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--cinza-700);
    margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="tel"],
select,
textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--cinza-300);
    border-radius: var(--radius);
    background: var(--branco);
    color: var(--cinza-900);
    font-size: 0.95rem;
    font-family: var(--font);
    margin-bottom: 16px;
}

input[type="file"] {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 1px dashed var(--cinza-300);
    border-radius: var(--radius);
    background: var(--cinza-100);
    color: var(--cinza-700);
    font-size: 0.85rem;
    font-family: var(--font);
    margin-bottom: 20px;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--roxo);
    box-shadow: 0 0 0 3px var(--roxo-claro);
}

/* Positivo por padrão (seguro em qualquer contexto). Onde o texto precisa
   ficar colado logo abaixo de um campo específico, use
   style="margin-top:-12px" naquele ponto de uso — não como padrão global,
   que já causou sobreposição em botões e inputs sem margem própria. */
.field-hint { font-size: 0.8rem; color: var(--cinza-500); margin-top: 6px; margin-bottom: 16px; }

.btn {
    display: inline-block;
    padding: 12px 22px;
    border-radius: var(--radius);
    border: none;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    font-family: var(--font);
    text-align: center;
}

.btn-primary { background: var(--roxo); color: var(--branco); }
.btn-primary:hover { background: var(--roxo-escuro); text-decoration: none; }
.btn-secondary { background: var(--cinza-100); color: var(--cinza-900); border: 1px solid var(--cinza-300); }
.btn-secondary:hover { background: var(--cinza-300); text-decoration: none; }
.btn-danger { background: var(--vermelho); color: var(--branco); }
.btn-block { display: block; width: 100%; }

.alert {
    padding: 14px 16px;
    border-radius: var(--radius);
    margin-bottom: 18px;
    font-size: 0.9rem;
}

.alert-error { background: #fbeaea; color: var(--vermelho); border: 1px solid #f1c3c0; }
.alert-success { background: #e6f6ee; color: var(--verde); border: 1px solid #b7e6cd; }
.alert-info { background: var(--roxo-claro); color: var(--roxo-escuro); border: 1px solid #e0c3f5; }

.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--cinza-300); font-size: 0.9rem; }
th { color: var(--cinza-500); font-weight: 600; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.04em; }
tr:hover td { background: var(--cinza-100); }

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-pendente, .badge-aguardando_pagamento, .badge-processando { background: #fdf2df; color: var(--amarelo); }
.badge-em_analise, .badge-em_processamento, .badge-pagamento_confirmado { background: #e6f0fb; color: var(--azul); }
.badge-aprovado, .badge-concluido { background: #e6f6ee; color: var(--verde); }
.badge-reprovado, .badge-cancelado, .badge-bloqueado { background: #fbeaea; color: var(--vermelho); }

.steps { display: flex; gap: 8px; margin-bottom: 28px; }
.steps .step {
    flex: 1;
    text-align: center;
    padding: 10px;
    border-radius: var(--radius);
    background: var(--cinza-100);
    color: var(--cinza-500);
    font-size: 0.8rem;
    font-weight: 600;
}
.steps .step.active { background: var(--roxo); color: var(--branco); }
.steps .step.done { background: var(--roxo-claro); color: var(--roxo-escuro); }

.summary-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px dashed var(--cinza-300); font-size: 0.95rem; }
.summary-row:last-child { border-bottom: none; font-weight: 700; font-size: 1.1rem; color: var(--roxo); }

.qr-box { text-align: center; padding: 24px; background: var(--branco); border: 1px solid var(--cinza-300); border-radius: var(--radius); }
.pix-copia-cola {
    background: var(--cinza-100);
    border: 1px solid var(--cinza-300);
    border-radius: var(--radius);
    padding: 12px;
    font-family: monospace;
    font-size: 0.8rem;
    word-break: break-all;
    margin: 16px 0;
}

.text-muted { color: var(--cinza-500); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

video, canvas.liveness-canvas {
    width: 100%;
    max-width: 420px;
    border-radius: var(--radius);
    background: var(--cinza-900);
}

.cs9-face-scan {
    position: relative;
    width: 260px;
    height: 260px;
    margin: 0 auto 8px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--cinza-900);
}

.cs9-face-scan video {
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    display: block;
    transform: scaleX(-1); /* espelha, como uma câmera frontal normal */
}

.cs9-scan-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
    pointer-events: none;
}

.cs9-scan-track {
    fill: none;
    stroke: var(--cinza-300);
    stroke-width: 5;
    stroke-dasharray: 6 6;
}

/* Anel de progresso: preenche conforme as etapas do desafio (frente,
   direita, esquerda, cima, baixo) são confirmadas. O JS ajusta
   stroke-dashoffset (circunferência = 2*pi*92 ≈ 578) via variável CSS. */
.cs9-scan-progress {
    fill: none;
    stroke: var(--roxo);
    stroke-width: 5;
    stroke-linecap: round;
    stroke-dasharray: 578;
    stroke-dashoffset: var(--cs9-progress-offset, 578);
    transition: stroke-dashoffset 0.5s ease, stroke 0.3s ease;
}

.cs9-face-scan.success .cs9-scan-progress {
    stroke: var(--verde);
}

.cs9-face-scan.error .cs9-scan-progress {
    stroke: var(--vermelho);
}

/* Logo CS9 — o SVG usa fill="currentColor", a cor é definida por quem o envolve */
.cs9-logo-svg {
    height: 28px;
    width: auto;
    display: inline-block;
    vertical-align: middle;
}

.cs9-logo-purple { color: var(--roxo); }
.cs9-logo-white { color: var(--branco); }
.cs9-logo-svg--lg { height: 42px; }

.cs9-lang-dropdown { position: relative; margin-right: 16px; display: inline-block; }

.cs9-lang-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px solid var(--cinza-300);
    border-radius: 20px;
    padding: 4px 10px;
    cursor: pointer;
    color: var(--cinza-700);
}
.cs9-lang-toggle:hover { border-color: var(--roxo); }
.cs9-lang-toggle svg.cs9-lang-caret { transition: transform 0.15s ease; }
.cs9-lang-dropdown.open .cs9-lang-toggle svg.cs9-lang-caret { transform: rotate(180deg); }

.cs9-lang-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--branco);
    border: 1px solid var(--cinza-300);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 150px;
    padding: 6px;
    z-index: 20;
}
.cs9-lang-dropdown.open .cs9-lang-menu { display: block; }

.cs9-lang-menu a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--cinza-700);
    font-weight: 500;
    font-size: 0.9rem;
}
.cs9-lang-menu a:hover { background: var(--cinza-100); text-decoration: none; }
.cs9-lang-menu a.active { color: var(--roxo); font-weight: 700; }

.cs9-link-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--roxo-claro);
    color: var(--roxo);
    font-weight: 700;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid transparent;
}
.cs9-link-chip:hover {
    background: var(--roxo);
    color: var(--branco);
    text-decoration: none;
}
.cs9-link-chip svg { flex-shrink: 0; }
