/* PsiAgent — base + auth modal + dashboard. Paleta: roxo (#5b3a8a). */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; color: #1a1a1a; background: #fafaf8; }

.hidden { display: none !important; }

/* ─── Header ─── */
.header {
    background: linear-gradient(135deg, #5b3a8a 0%, #7d5fb3 100%);
    color: #fff; padding: 14px 0; box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.header-inner {
    max-width: 1140px; margin: 0 auto; padding: 0 20px;
    display: flex; justify-content: space-between; align-items: center;
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.logo-icon { font-size: 26px; }
.logo-text { font-size: 22px; }
.header-right { display: flex; align-items: center; gap: 14px; }
.header-trial { background: rgba(255,255,255,0.18); padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.header-nome { font-weight: 600; }

.btn-primary {
    background: #5b3a8a; color: #fff; border: 0; padding: 14px 28px; border-radius: 8px;
    font-size: 16px; font-weight: 600; cursor: pointer; font-family: inherit;
    transition: background 0.2s;
}
.btn-primary:hover { background: #4a2e72; }
.btn-secondary {
    background: rgba(255,255,255,0.2); color: #fff; border: 0;
    padding: 8px 16px; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; font-family: inherit;
}
.btn-secondary:hover { background: rgba(255,255,255,0.3); }

/* ─── Hero ─── */
.hero {
    background: #fff; padding: 80px 20px 60px;
    border-bottom: 1px solid #ecebe6;
}
.hero-content { max-width: 720px; margin: 0 auto; text-align: center; }
.hero-content h1 {
    font-size: 44px; font-weight: 800; color: #1a1a1a; margin: 0 0 16px;
    line-height: 1.15;
}
.highlight { color: #5b3a8a; }
.hero-sub { font-size: 18px; color: #555; line-height: 1.5; margin: 0 0 32px; }
.hero-foot { font-size: 13px; color: #888; margin: 12px 0 0; }

/* ─── Features ─── */
.features { padding: 60px 20px; max-width: 1140px; margin: 0 auto; }
.features-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
}
.feature-card {
    background: #fff; padding: 28px 24px; border-radius: 12px;
    border: 1px solid #ecebe6;
}
.feature-icon { font-size: 36px; margin-bottom: 12px; }
.feature-card h3 { font-size: 18px; margin: 0 0 8px; color: #1a1a1a; }
.feature-card p { font-size: 14px; color: #666; line-height: 1.5; margin: 0; }

/* ─── Footer ─── */
.footer {
    background: #1a1a1a; color: #aaa; padding: 32px 20px; text-align: center;
}
.footer p { margin: 4px 0; font-size: 13px; }
.footer-sub { color: #777; font-size: 12px; }

/* ─── Dashboard ─── */
.dash-main { max-width: 1140px; margin: 40px auto; padding: 0 20px; }
.dash-main h1 { font-size: 32px; margin: 0 0 4px; }
.dash-sub { color: #666; margin: 0 0 32px; }
.dash-cards {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
}
.dash-card {
    background: #fff; padding: 24px; border-radius: 12px; border: 1px solid #ecebe6;
    text-decoration: none; color: inherit; display: block; transition: all 0.2s;
}
.dash-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(91, 58, 138, 0.12); }
.dash-card.disabled { opacity: 0.5; pointer-events: none; }
.dash-card-icon { font-size: 36px; margin-bottom: 10px; }
.dash-card h3 { font-size: 18px; margin: 0 0 6px; }
.dash-card p { font-size: 14px; color: #666; line-height: 1.4; margin: 0 0 12px; }
.dash-card-cta { color: #5b3a8a; font-weight: 600; font-size: 14px; }

/* ─── Auth modal ─── */
.auth-modal {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(8, 12, 24, 0.92); backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.auth-card {
    background: #fff; border-radius: 16px;
    width: 100%; max-width: 440px; padding: 28px 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    max-height: 92vh; overflow-y: auto; position: relative;
}
.auth-close {
    position: absolute; top: 12px; right: 14px; background: transparent;
    border: 0; font-size: 20px; cursor: pointer; color: #888;
}
.auth-close:hover { color: #1a1a1a; }
.auth-logo { font-size: 24px; font-weight: 800; color: #5b3a8a; text-align: center; margin-bottom: 18px; }
.auth-step h3 { margin: 0 0 8px; font-size: 20px; }
.auth-step.hidden { display: none; }
.auth-help { color: #555; font-size: 14px; margin: 0 0 16px; }
.auth-field { display: block; margin-bottom: 12px; }
.auth-field span { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.auth-field span .opt { font-weight: 400; color: #888; }
.auth-field input {
    width: 100%; padding: 11px 12px; border: 1.5px solid #d8dcd6;
    border-radius: 8px; font-size: 15px; font-family: inherit; box-sizing: border-box;
}
.auth-field input:focus { outline: none; border-color: #5b3a8a; box-shadow: 0 0 0 3px rgba(91,58,138,0.15); }
.auth-otp-input {
    width: 100%; padding: 14px; text-align: center;
    font-size: 24px; letter-spacing: 8px; font-weight: 700;
    border: 1.5px solid #d8dcd6; border-radius: 8px; margin-bottom: 12px; box-sizing: border-box;
}
.auth-otp-input:focus { outline: none; border-color: #5b3a8a; box-shadow: 0 0 0 3px rgba(91,58,138,0.15); }
.auth-err { color: #c0392b; font-size: 13px; min-height: 18px; margin-bottom: 8px; }
.auth-btn {
    display: block; width: 100%; padding: 12px; margin-bottom: 8px;
    border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer;
    font-family: inherit; box-sizing: border-box; border: 0;
}
.auth-btn.primary { background: #5b3a8a; color: #fff; }
.auth-btn.primary:hover { background: #4a2e72; }
.auth-btn.ghost { background: #fff; color: #5b3a8a; border: 1.5px solid #5b3a8a; }
.auth-btn.ghost:hover { background: #f6f2fc; }
.auth-btn.link { background: transparent; color: #555; font-weight: 500; padding: 8px; }
.auth-btn.link:hover { color: #5b3a8a; }
.auth-foot { font-size: 11px; color: #888; text-align: center; margin: 16px 0 0; }

@media (max-width: 640px) {
    .hero { padding: 50px 20px 40px; }
    .hero-content h1 { font-size: 32px; }
}

/* ─── Config page ─── */
.config-header { margin-bottom: 32px; }
.config-back { color: #5b3a8a; text-decoration: none; font-size: 14px; font-weight: 500; }
.config-back:hover { text-decoration: underline; }
.config-form { max-width: 760px; }
.config-section {
    background: #fff; border: 1px solid #ecebe6; border-radius: 12px;
    padding: 24px; margin-bottom: 18px;
}
.config-section h2 { margin: 0 0 16px; font-size: 18px; }
.config-sub { font-size: 15px; margin: 18px 0 8px; color: #444; }
.config-row { display: flex; gap: 16px; flex-wrap: wrap; }
.config-row .config-field { flex: 1; min-width: 200px; }
.config-field { display: block; margin-bottom: 14px; }
.config-field span { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; color: #2c2230; }
.config-field input, .config-field select, .config-field textarea {
    width: 100%; padding: 10px 12px; border: 1.5px solid #d8dcd6;
    border-radius: 8px; font-size: 14px; font-family: inherit; box-sizing: border-box;
}
.config-field input:focus, .config-field select:focus, .config-field textarea:focus {
    outline: none; border-color: #5b3a8a; box-shadow: 0 0 0 3px rgba(91,58,138,0.15);
}
.config-field textarea { resize: vertical; min-height: 60px; }
.config-hint { display: block; font-size: 12px; color: #888; margin-top: 4px; line-height: 1.4; }

.horarios-grid { display: grid; gap: 10px; }
.horario-row { display: grid; grid-template-columns: 100px 1fr; align-items: center; gap: 12px; }
.horario-label { font-weight: 600; font-size: 13px; color: #444; }
.horario-input {
    padding: 8px 10px; border: 1.5px solid #d8dcd6; border-radius: 6px;
    font-size: 14px; font-family: inherit;
}
.horario-input:focus { outline: none; border-color: #5b3a8a; }

.config-actions {
    display: flex; justify-content: space-between; align-items: center;
    background: #fff; border: 1px solid #ecebe6; border-radius: 12px;
    padding: 18px 24px; position: sticky; bottom: 16px;
}
.config-status { font-size: 13px; color: #666; }
.config-status.ok { color: #0a7e35; font-weight: 600; }
.config-status.err { color: #c0392b; font-weight: 600; }

/* ─── WhatsApp connect page ─── */
.wa-card {
    background: #fff; border: 1px solid #ecebe6; border-radius: 12px;
    padding: 24px; margin: 18px 0; text-align: center;
}
.wa-state-icon { font-size: 48px; margin-bottom: 8px; }
.wa-state-label { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.wa-state-help { font-size: 14px; color: #666; }
.wa-actions { display: flex; gap: 12px; margin: 18px 0; }
.wa-actions button { flex: 1; }
.wa-qr {
    background: #fff; border: 1px solid #ecebe6; border-radius: 12px;
    padding: 24px; text-align: center; max-width: 480px; margin: 0 auto;
}
.wa-qr h3 { margin: 0 0 12px; }
.wa-steps { text-align: left; max-width: 320px; margin: 0 auto 18px; color: #444; font-size: 14px; }
.wa-steps li { margin-bottom: 4px; }
.wa-qr img { max-width: 280px; width: 100%; height: auto; border: 1px solid #ddd; padding: 8px; background: #fff; }
.wa-qr-info { font-size: 12px; color: #888; margin: 12px 0 0; }

/* ─── KPI cards ─── */
.kpi-row {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px; margin-bottom: 24px;
}
.kpi-card {
    background: #fff; border: 1px solid #ecebe6; border-radius: 12px;
    padding: 18px 20px; min-height: 96px;
}
.kpi-card.kpi-financeiro { background: linear-gradient(135deg, #f9f6ff 0%, #fff 100%); border-color: #d8c8ec; }
.kpi-card.kpi-pendente { background: #fff8e8; border-color: #f0d089; }
.kpi-card.kpi-pendente .kpi-value { color: #b87b00; }
.kpi-label { font-size: 12px; color: #777; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; margin-bottom: 6px; }
.kpi-value { font-size: 28px; font-weight: 800; color: #1a1a1a; line-height: 1.1; }
.kpi-sub { font-size: 12px; color: #777; margin-top: 4px; }
.kpi-cta { display: inline-block; margin-top: 8px; color: #b87b00; font-size: 13px; font-weight: 600; text-decoration: none; }

/* ─── Próximas sessões ─── */
.sessoes-prox-list { list-style: none; padding: 0; margin: 0; }
.sessoes-prox-list li {
    display: grid; grid-template-columns: 160px 1fr auto; gap: 14px; align-items: center;
    padding: 10px 0; border-bottom: 1px solid #f0eee8;
}
.sessoes-prox-list li:last-child { border-bottom: 0; }
.sessoes-prox-data { color: #5b3a8a; font-weight: 600; font-size: 14px; }
.sessoes-prox-nome { font-weight: 500; }
.badge-ok, .badge-pending {
    padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge-ok { background: #e8f5ee; color: #0a7e35; }
.badge-pending { background: #fff3d6; color: #b87b00; }
.badge-inativo { background: #f0eee8; color: #888; padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; }

/* ─── Toolbar + tabela pacientes ─── */
.page-toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-toolbar h1 { margin: 0; flex: 1; }
.search-bar { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.search-bar input {
    flex: 1; padding: 10px 14px; border: 1.5px solid #d8dcd6;
    border-radius: 8px; font-size: 14px; font-family: inherit;
}
.checkbox-inline {
    display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #444;
    cursor: pointer;
}
.pacientes-tbl {
    width: 100%; background: #fff; border: 1px solid #ecebe6; border-radius: 12px;
    border-collapse: separate; border-spacing: 0; overflow: hidden;
}
.pacientes-tbl th, .pacientes-tbl td {
    text-align: left; padding: 12px 16px; border-bottom: 1px solid #f0eee8;
}
.pacientes-tbl th { background: #fafaf8; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: #777; }
.pacientes-tbl tr { cursor: pointer; transition: background 0.15s; }
.pacientes-tbl tr:hover { background: #faf7ff; }
.pacientes-tbl tr.row-inativo { opacity: 0.6; }
.pacientes-tbl tr:last-child td { border-bottom: 0; }
.pacientes-tbl .empty-state { text-align: center; padding: 32px; color: #888; }
.empty-state { padding: 18px; color: #888; text-align: center; }
.muted { color: #aaa; }

@media (max-width: 720px) {
    .sessoes-prox-list li { grid-template-columns: 1fr; gap: 4px; }
    .pacientes-tbl th:nth-child(4), .pacientes-tbl td:nth-child(4),
    .pacientes-tbl th:nth-child(5), .pacientes-tbl td:nth-child(5) { display: none; }
}

/* ─── Step header (etapas em integrações) ─── */
.step-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.step-header h2 { margin: 0; flex: 1; }
.step-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 50%;
    background: #ecebe6; color: #888; font-weight: 700;
}
.step-num.done { background: #0a7e35; color: #fff; }
.step-status { font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.step-status.ok { background: #e8f5ee; color: #0a7e35; }
.step-status.pending { background: #fff3d6; color: #b87b00; }

.disabled-section { opacity: 0.55; pointer-events: none; }
.disabled-section button { cursor: not-allowed; }

/* ─── Instructions box (collapsible) ─── */
.instr-box {
    background: #f9f8fc; border: 1px solid #e7e2f0; border-radius: 8px;
    padding: 12px 18px; margin-bottom: 14px;
}
.instr-summary {
    cursor: pointer; font-weight: 600; color: #5b3a8a; padding: 4px 0;
    display: flex; align-items: center; justify-content: space-between;
    list-style: none;
}
.instr-summary::-webkit-details-marker { display: none; }
.instr-arrow { transition: transform 0.2s; }
details[open] .instr-arrow { transform: rotate(180deg); }
.instr-content { padding-top: 14px; color: #333; font-size: 14px; line-height: 1.6; }
.instr-content code {
    background: #fff; padding: 2px 6px; border-radius: 4px; border: 1px solid #e0dcec;
    font-size: 12px; font-family: 'SF Mono', Consolas, monospace;
}
.instr-steps { padding-left: 20px; }
.instr-steps > li { margin-bottom: 12px; }
.instr-steps ul { padding-left: 20px; margin: 6px 0; }
.instr-warn { background: #fff3d6; border-left: 3px solid #b87b00; padding: 10px 14px; border-radius: 4px; color: #6b4a00; font-size: 13px; margin-top: 12px; }

.copy-box {
    display: inline-flex; align-items: center; gap: 10px;
    background: #fff; border: 1px solid #d8dcd6; border-radius: 6px;
    padding: 8px 12px; margin: 6px 0; cursor: pointer; transition: all 0.15s;
    font-family: 'SF Mono', Consolas, monospace; font-size: 12px;
}
.copy-box:hover { border-color: #5b3a8a; background: #faf7ff; }
.copy-box code { background: transparent; border: 0; padding: 0; }
.copy-hint { color: #5b3a8a; font-weight: 600; font-size: 11px; }

/* ─── Conversa box ─── */
.conversa-box {
    background: #f9f8fc; border: 1px solid #ecebe6; border-radius: 8px;
    padding: 16px; min-height: 200px; max-height: 480px; overflow-y: auto;
}
.msg { margin-bottom: 12px; max-width: 80%; }
.msg-in { margin-right: auto; }
.msg-out { margin-left: auto; }
.msg-meta { font-size: 11px; color: #888; margin-bottom: 2px; font-weight: 600; }
.msg-out .msg-meta { text-align: right; }
.msg-body {
    padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.4;
    white-space: pre-wrap; word-wrap: break-word;
}
.msg-in .msg-body { background: #fff; border: 1px solid #e0dcec; }
.msg-out .msg-body { background: #5b3a8a; color: #fff; }

/* ─── Fila ─── */
.fila-item { padding: 8px 10px; border-bottom: 1px solid #f0eee8; font-size: 13px; }
.fila-item:last-child { border-bottom: 0; }
.fila-head { display: flex; gap: 6px; align-items: center; }
.fila-erro { color: #c0392b; font-size: 12px; margin-top: 4px; padding-left: 22px; }

/* ─── Financeiro: pendentes de aprovação ─── */
.pendente-card {
    background: #fff8e8; border: 1.5px solid #f0d089; border-radius: 12px;
    padding: 16px; margin-bottom: 12px;
}
.pendente-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.pendente-valor { font-size: 22px; font-weight: 800; color: #b87b00; }
.pendente-info { font-size: 14px; color: #444; line-height: 1.6; margin-bottom: 12px; }
.pendente-msg-paciente {
    margin: 8px 0; padding: 8px 12px; background: #fff; border-left: 3px solid #f0d089;
    border-radius: 4px; font-style: italic; font-size: 13px;
}
.pendente-acoes { display: flex; gap: 10px; }
.pendente-acoes button { flex: 1; padding: 10px; }

.config-field-inline {
    padding: 8px 12px; border: 1.5px solid #d8dcd6; border-radius: 8px;
    font-size: 14px; font-family: inherit; background: #fff;
}

/* ─── Agenda ─── */
.agenda-day {
    margin: 24px 0 8px; padding-bottom: 6px; border-bottom: 1px solid #ecebe6;
    font-size: 14px; color: #5b3a8a; text-transform: capitalize; font-weight: 700;
}
.agenda-card {
    display: grid; grid-template-columns: 80px 1fr; gap: 16px;
    background: #fff; border: 1px solid #ecebe6; border-radius: 12px;
    padding: 14px 18px; margin-bottom: 10px;
}
.ag-hora { font-size: 20px; font-weight: 700; color: #5b3a8a; }
.ag-info { font-size: 14px; }
.ag-nome { margin-bottom: 4px; }
.ag-tel { font-size: 12px; margin-bottom: 6px; }
.ag-cobranca { margin-top: 6px; font-size: 13px; }
.ag-meet {
    display: inline-block; margin-top: 6px; padding: 4px 10px;
    background: #f6f2fc; color: #5b3a8a; border-radius: 6px;
    text-decoration: none; font-size: 12px; font-weight: 600;
}
.ag-acoes { display: flex; gap: 6px; margin-top: 10px; }
.ag-btn {
    padding: 6px 10px; font-size: 12px; border-radius: 6px;
    background: #f9f8fc; color: #5b3a8a; border: 1px solid #d8c8ec;
    cursor: pointer; font-family: inherit; font-weight: 600;
}
.ag-btn:hover { background: #f0e8fa; }
.ag-btn-danger { color: #c0392b; border-color: #f0c0b8; background: #fdf6f5; }
.ag-btn-danger:hover { background: #fae6e2; }
