@import url('https://fonts.googleapis.com/css2?family=Kaushan+Script&family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg:           #f0f2f5;
    --card:         #ffffff;
    --text:         #2d3748;
    --muted:        #718096;
    --border:       #e2e8f0;
    --green:        #38a169;
    --green-light:  #c6f6d5;
    --red:          #e53e3e;
    --blue:         #3182ce;
    --blue-light:   #bee3f8;
    --orange:       #dd6b20;
    --purple:       #805ad5;
    --purple-light: #e9d8fd;
    --shadow:       0 2px 8px rgba(0,0,0,0.08);
    --shadow-md:    0 4px 16px rgba(0,0,0,0.12);
    --radius:       12px;
    --whatsapp:     #25d366;
    --whatsapp-dark:#128c7e;
    --sent-bg:      #e2e8f0;
    --sent-color:   #a0aec0;
}

[data-theme="dark"] {
    --bg:           #111113;
    --card:         #1a1a1e;
    --text:         #e4e4e7;
    --muted:        #a1a1aa;
    --border:       rgba(255,255,255,0.1);
    --green:        #4ade80;
    --green-light:  rgba(74,222,128,0.18);
    --red:          #f87171;
    --blue:         #60a5fa;
    --blue-light:   rgba(96,165,250,0.18);
    --orange:       #fb923c;
    --purple:       #c084fc;
    --purple-light: rgba(192,132,252,0.18);
    --shadow:       0 2px 8px rgba(0,0,0,0.35);
    --shadow-md:    0 4px 16px rgba(0,0,0,0.5);
    --whatsapp:     #25d366;
    --whatsapp-dark:#128c7e;
    --sent-bg:      rgba(255,255,255,0.07);
    --sent-color:   #71717a;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

/* ── Page Header ─────────────────────────────── */
.page-header {
    background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
    color: white;
    padding: 20px 28px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.header-brand h1 {
    font-family: 'Kaushan Script', cursive;
    font-size: 2rem;
    letter-spacing: 1px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    line-height: 1;
}
.header-brand p {
    font-size: 0.7rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    opacity: 0.55;
    margin-top: 4px;
}
.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.btn-header {
    background: rgba(255,255,255,0.12);
    color: white;
    border: 1px solid rgba(255,255,255,0.25);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
    font-family: inherit;
}
.btn-header:hover { background: rgba(255,255,255,0.22); }

/* ── Main ────────────────────────────────────── */
.main {
    max-width: 1380px;
    margin: 0 auto;
    padding: 16px 16px;
}

/* ── Top bar ─────────────────────────────────── */
.top-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}
.search-wrapper {
    position: relative;
    flex: 1;
    min-width: 220px;
}
.search-wrapper::before {
    content: '🔍';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    pointer-events: none;
}
.search-input {
    width: 100%;
    padding: 10px 14px 10px 38px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--purple); }

.client-count {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 600;
    white-space: nowrap;
}

/* ── Filter bar ──────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}
.filter-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--muted);
    white-space: nowrap;
}

/* ── Botão filtro avançado ── */
.btn-filtro-avancado {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1.5px solid var(--purple);
    background: var(--card);
    color: var(--purple);
    font-size: 0.85rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn-filtro-avancado:hover { background: var(--purple); color: #fff; }
.btn-filtro-avancado.ativo { background: var(--purple); color: #fff; }
.fa-badge {
    position: absolute;
    top: -5px; right: -5px;
    background: var(--red);
    color: #fff;
    border-radius: 50%;
    width: 16px; height: 16px;
    font-size: 10px;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}

/* ── Overlay ── */
.fa-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 900;
    backdrop-filter: blur(2px);
}
.fa-overlay.open { display: block; }

/* ── Modal ── */
.fa-modal {
    display: none;
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(.95);
    width: min(480px, 95vw);
    background: var(--card);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.35);
    z-index: 901;
    transition: transform .2s, opacity .2s;
    opacity: 0;
}
.fa-modal.open {
    display: flex; flex-direction: column;
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}
.fa-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 22px 14px;
    border-bottom: 1px solid var(--border);
    font-weight: 700; font-size: .95rem;
}
.fa-close {
    background: none; border: none; font-size: 1.4rem;
    cursor: pointer; color: var(--muted); line-height: 1;
    padding: 0 4px;
}
.fa-close:hover { color: var(--red); }
.fa-body { padding: 18px 22px; display: flex; flex-direction: column; gap: 18px; }
.fa-group { display: flex; flex-direction: column; gap: 7px; }
.fa-label {
    font-size: .75rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .7px; color: var(--muted);
}
.fa-input {
    padding: 9px 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: .88rem;
    font-family: inherit;
    outline: none;
    transition: border-color .2s;
}
.fa-input:focus { border-color: var(--purple); }
.fa-radio-group { display: flex; flex-wrap: wrap; gap: 8px; }
.fa-radio {
    display: flex; align-items: center; gap: 6px;
    font-size: .85rem; cursor: pointer;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg);
    transition: all .15s;
    user-select: none;
}
.fa-radio:has(input:checked) {
    border-color: var(--purple);
    background: var(--purple-light);
    color: var(--purple);
    font-weight: 600;
}
.fa-radio input { display: none; }

/* ── Faixa de idade ── */
.fa-idade-wrap {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.fa-idade-field {
    display: flex; align-items: center; gap: 6px;
}
.fa-idade-label {
    font-size: .82rem; color: var(--muted); white-space: nowrap;
}
.fa-idade-input {
    width: 68px; padding: 8px 10px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: var(--bg); color: var(--text);
    font-size: .9rem; font-weight: 600;
    font-family: inherit; text-align: center;
    outline: none; transition: border-color .2s;
    -moz-appearance: textfield;
}
.fa-idade-input::-webkit-inner-spin-button,
.fa-idade-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.fa-idade-input:focus { border-color: var(--purple); }
.fa-idade-sep { font-size: .82rem; color: var(--muted); }
.fa-idade-preview {
    font-size: .78rem; color: var(--purple);
    font-weight: 600; margin-top: 4px;
}
.fa-resultado {
    font-size: .82rem; color: var(--muted);
    background: var(--bg);
    border-radius: 8px; padding: 8px 12px;
    text-align: center; font-weight: 600;
}
.fa-footer {
    display: flex; gap: 10px; padding: 14px 22px 18px;
    border-top: 1px solid var(--border);
}
.fa-btn-limpar {
    flex: 1; padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px; background: var(--bg);
    color: var(--muted); font-size: .85rem;
    font-weight: 600; cursor: pointer; font-family: inherit;
    transition: all .2s;
}
.fa-btn-limpar:hover { border-color: var(--red); color: var(--red); }
.fa-btn-aplicar {
    flex: 2; padding: 10px;
    border: none; border-radius: 8px;
    background: var(--purple); color: #fff;
    font-size: .85rem; font-weight: 700;
    cursor: pointer; font-family: inherit;
    transition: opacity .2s;
}
.fa-btn-aplicar:hover { opacity: .88; }
.filter-btn {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}
.filter-btn:hover { border-color: var(--purple); color: var(--purple); }
.filter-btn.active {
    color: white;
    border-color: transparent;
}
.filter-btn .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.7;
}

/* ── Client List ─────────────────────────────── */
.client-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.client-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card);
    border-radius: var(--radius);
    padding: 12px 16px;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s, transform 0.15s;
}
.client-row:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.client-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--purple-light);
    color: var(--purple);
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-transform: uppercase;
}

.client-info {
    flex: 1;
    min-width: 0;
}
.client-name {
    font-weight: 700;
    font-size: 0.93rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.client-sub {
    font-size: 0.73rem;
    color: var(--muted);
    margin-top: 2px;
}

/* ── Dispatch buttons area ───────────────────── */
.dispatch-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* WhatsApp */
.btn-wa {
    background: var(--whatsapp);
    color: white;
    border: none;
    border-radius: 9px;
    padding: 8px 14px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: background 0.2s, transform 0.1s;
    font-family: inherit;
    white-space: nowrap;
    text-decoration: none;
}
.btn-wa:hover { background: var(--whatsapp-dark); transform: scale(1.03); }

/* Promo buttons */
.btn-dispatch {
    border: none;
    border-radius: 9px;
    padding: 8px 12px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: opacity 0.2s, transform 0.1s, background 0.3s, color 0.3s;
    font-family: inherit;
    white-space: nowrap;
    color: white;
    position: relative;
}
.btn-dispatch:hover { opacity: 0.85; transform: scale(1.03); }
.btn-dispatch:active { transform: scale(0.97); }

/* Sent states */
.btn-dispatch.sent-temp,
.btn-dispatch.sent-perm {
    background: var(--sent-bg) !important;
    color: var(--sent-color) !important;
    cursor: pointer; /* still clickable */
}
.btn-dispatch.sent-temp::after,
.btn-dispatch.sent-perm::after {
    content: attr(data-sent-label);
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    white-space: nowrap;
    color: var(--muted);
    font-weight: 600;
    pointer-events: none;
}

/* Ficha button */
.btn-ficha {
    background: var(--orange);
    color: white;
    border: none;
    border-radius: 9px;
    padding: 8px 12px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: opacity 0.2s, transform 0.1s, background 0.3s, color 0.3s;
    font-family: inherit;
    white-space: nowrap;
    position: relative;
}
.btn-ficha:hover { opacity: 0.85; transform: scale(1.03); }
.btn-ficha.sent-perm {
    background: var(--sent-bg) !important;
    color: var(--sent-color) !important;
}
.btn-ficha.sent-perm::after {
    content: attr(data-sent-label);
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    white-space: nowrap;
    color: var(--muted);
    font-weight: 600;
    pointer-events: none;
}

/* ── Empty state ─────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state-text { font-size: 0.95rem; }

/* ── Modal base ──────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: var(--card);
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.45);
    width: min(560px, 100%);
    max-height: 92vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.modal-header {
    background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: 1rem;
    border-radius: 16px 16px 0 0;
    flex-shrink: 0;
}
.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    opacity: 0.7;
    padding: 0 4px;
}
.modal-close:hover { opacity: 1; }

/* ── Config modal ────────────────────────────── */
.config-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    flex: 1;
}
.config-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.promo-config-card {
    background: var(--bg);
    border-radius: 10px;
    padding: 14px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.promo-config-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 2px;
}
.promo-color-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--border);
    cursor: pointer;
    flex-shrink: 0;
}
.promo-num {
    font-weight: 700;
    font-size: 0.85rem;
}
.form-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--muted);
    display: block;
    margin-bottom: 4px;
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    color: var(--text);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--purple); }
.form-textarea { resize: vertical; min-height: 72px; }

.form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.form-group { flex: 1; min-width: 140px; }

.hint {
    font-size: 0.72rem;
    color: var(--muted);
    margin-top: 3px;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-shrink: 0;
}
.btn-cancel {
    background: none;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 20px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
}
.btn-cancel:hover { background: var(--bg); }
.btn-save {
    background: var(--purple);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 10px 22px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.2s;
}
.btn-save:hover { opacity: 0.88; }

/* ── Ficha config section ─────────────────────── */
.ficha-config-card {
    background: var(--bg);
    border-radius: 10px;
    padding: 14px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-header-inline {
    background: var(--purple);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 9px 16px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: opacity 0.2s;
}
.btn-header-inline:hover { opacity: 0.88; }

/* ── Theme toggle ────────────────────────────── */
.btn-theme-r {
    position: fixed;
    bottom: 22px;
    right: 22px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--card);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    z-index: 999;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}
.btn-theme-r:hover { transform: scale(1.1); }
.btn-theme-r::after { content: '🌓'; }

/* ── Responsive ──────────────────────────────── */
@media (max-width: 768px) {
    .page-header { padding: 10px 12px; }
    .main { padding: 16px 12px; }
    .header-brand h1 { font-size: 1.3rem; }
    .client-row { padding: 10px 10px; gap: 8px; flex-wrap: wrap; }
    .dispatch-actions { width: 100%; justify-content: flex-end; margin-top: 4px; }
    .btn-wa span { display: none; }
}
@media (max-width: 480px) {
    .page-header { padding: 8px 10px; }
    .header-brand h1 { font-size: 1.1rem; }
    .header-brand p { display: none; }
    .top-bar { flex-direction: column; }
    .search-wrapper { min-width: 100%; }
}
