/* Redirecionador de Links — CSS próprio, sem dependências externas. */

:root {
    --color-bg: #f4f6f8;
    --color-surface: #ffffff;
    --color-border: #e1e5ea;
    --color-text: #1f2933;
    --color-text-muted: #667085;
    --color-primary: #1f9d55;
    --color-primary-dark: #167a41;
    --color-danger: #d64545;
    --color-danger-bg: #fdecec;
    --color-success-bg: #e9f9ef;
    --color-warning-bg: #fff8e6;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.06);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
}

a {
    color: var(--color-primary-dark);
}

h1, h2, h3 {
    margin: 0 0 0.5em;
    line-height: 1.25;
}

/* ---------- Layout genérico ---------- */

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

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
}

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
}

.card + .card {
    margin-top: 20px;
}

.card-narrow {
    width: 100%;
    max-width: 420px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 20px;
}

.brand .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-primary);
}

/* ---------- Topbar / navegação do admin ---------- */

.topbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar nav {
    display: flex;
    gap: 18px;
    align-items: center;
}

.topbar nav a {
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.95rem;
}

.topbar nav a:hover {
    color: var(--color-text);
}

.topbar .user {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* ---------- Formulários ---------- */

.form-group {
    margin-bottom: 16px;
}

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

.hint {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 4px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"],
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    background: var(--color-surface);
    color: var(--color-text);
}

input:focus, select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(31, 157, 85, 0.15);
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row > * {
    flex: 1;
}

/* ---------- Campo de senha com botão de mostrar/ocultar ---------- */

.password-wrapper {
    position: relative;
}

.password-wrapper input {
    padding-right: 40px;
}

.toggle-password-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
}

.toggle-password-btn:hover {
    color: var(--color-text);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-row input {
    width: auto;
}

/* ---------- Botões ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--color-primary-dark);
}

.btn-secondary {
    background: var(--color-surface);
    border-color: var(--color-border);
    color: var(--color-text);
}

.btn-secondary:hover {
    border-color: var(--color-text-muted);
}

.btn-danger {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.btn-danger:hover {
    background: #f9d3d3;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.82rem;
}

/* ---------- Alertas ---------- */

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

.alert-error {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.alert-success {
    background: var(--color-success-bg);
    color: var(--color-primary-dark);
}

.alert ul {
    margin: 4px 0 0;
    padding-left: 20px;
}

/* ---------- Tabelas ---------- */

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.92rem;
}

th {
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

tr:last-child td {
    border-bottom: none;
}

.table-actions {
    display: flex;
    gap: 8px;
}

td code {
    margin-right: 8px;
}

/* ---------- Badges ---------- */

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

.badge-success {
    background: var(--color-success-bg);
    color: var(--color-primary-dark);
}

.badge-muted {
    background: var(--color-bg);
    color: var(--color-text-muted);
}

/* ---------- Barras de porcentagem (relatórios) ---------- */

.bar-row {
    display: grid;
    grid-template-columns: 1fr 2fr auto;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
}

.bar-row:last-child {
    border-bottom: none;
}

.bar-track {
    background: var(--color-bg);
    border-radius: 999px;
    height: 10px;
    overflow: hidden;
    position: relative;
}

.bar-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 999px;
}

.bar-fill.bar-fill-secondary {
    background: #9fd6b6;
}

.bar-meta {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    text-align: right;
}

.daily-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 120px;
    margin-top: 12px;
}

.daily-chart .col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
}

.daily-chart .col .bar {
    width: 100%;
    background: var(--color-primary);
    border-radius: 3px 3px 0 0;
    min-height: 2px;
}

.daily-chart .col .label {
    font-size: 0.65rem;
    color: var(--color-text-muted);
    margin-top: 4px;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

/* ---------- Cabeçalho de página ---------- */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-header h1 {
    font-size: 1.4rem;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px 18px;
}

.stat-card .value {
    font-size: 1.6rem;
    font-weight: 700;
}

.stat-card .label {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

/* ---------- Destinos da campanha (WhatsApp ou link, form repetível) ---------- */

.target-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    margin-bottom: 10px;
    padding: 12px;
    background: var(--color-bg);
    border-radius: var(--radius);
}

.target-row > div {
    flex: 1 1 160px;
}

.target-row .field-percentage {
    flex: 0 1 80px;
}

.target-row .remove-target {
    flex: 0 0 auto;
}

/* O tipo escolhido (data-type no data attribute da linha) decide quais campos aparecem. */
.target-row .target-field-whatsapp,
.target-row .target-field-link {
    display: none;
}

.target-row[data-type="whatsapp"] .target-field-whatsapp,
.target-row[data-type="link"] .target-field-link {
    display: block;
}

.percentage-total {
    margin-top: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.percentage-total.ok {
    color: var(--color-primary-dark);
}

.percentage-total.warn {
    color: var(--color-danger);
}

/* ---------- Página pública de erro ---------- */

.error-page {
    text-align: center;
}

.error-page .code {
    font-size: 3rem;
    font-weight: 800;
    color: var(--color-text-muted);
}

/* ---------- Instalador ---------- */

.steps {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.steps .step.active {
    color: var(--color-primary-dark);
    font-weight: 700;
}

@media (max-width: 640px) {
    .target-row > div {
        flex-basis: 100%;
    }
    .bar-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }
}
