/* email.css — aba de campanhas de email */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    min-height: 100vh;
}

.header {
    background: #1a1a2e;
    color: #fff;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.header h1 { font-size: 1.1rem; font-weight: 600; }
.header a { color: #7ec8e3; font-size: 0.85rem; text-decoration: none; }

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

/* Card do remetente */
.sender-card {
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.sender-icon { font-size: 1.4rem; }
.sender-line { font-size: 0.9rem; color: #1e1b4b; }
.sender-sub { font-size: 0.78rem; color: #6366f1; margin-top: 2px; }

/* Form nova campanha */
.new-campaign-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    padding: 20px;
    margin-bottom: 24px;
}
.new-campaign-card h2 { font-size: 1rem; margin-bottom: 14px; color: #4338ca; }
.new-campaign-card label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    color: #444;
    margin-bottom: 12px;
}
.new-campaign-card input,
.new-campaign-card select,
.new-campaign-card textarea {
    width: 100%;
    margin-top: 4px;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.88rem;
    font-family: inherit;
}
.new-campaign-card textarea { resize: vertical; }
.form-row { display: flex; gap: 12px; }
.form-row label { flex: 1; }

/* ───── Editor de blocos ───── */
.editor-section { margin-bottom: 12px; }
.editor-label { font-size: 0.82rem; font-weight: 500; color: #444; margin-bottom: 8px; }

/* Barra de ações: visualizar + enviar teste */
.action-bar {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    background: #f8f9ff; border: 1px solid #e0e7ff; border-radius: 8px;
    padding: 12px; margin-bottom: 16px;
}
.btn-action {
    border: none; border-radius: 6px; padding: 9px 16px; font-size: 0.85rem;
    font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn-preview { background: #4338ca; color: #fff; }
.btn-preview:hover { background: #3730a3; }
.test-group { display: flex; gap: 8px; flex: 1; min-width: 240px; }
.test-group input {
    flex: 1; padding: 8px 11px; border: 1px solid #c7d2fe; border-radius: 6px;
    font-size: 0.85rem;
}
.btn-test { background: #10b981; color: #fff; }
.btn-test:hover { background: #059669; }

/* Modal de pré-visualização */
.preview-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55);
    z-index: 2000; align-items: center; justify-content: center; padding: 20px;
}
.preview-overlay.show { display: flex; }
.preview-modal {
    background: #fff; border-radius: 12px; width: 100%; max-width: 680px;
    max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
}
.preview-modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid #eef0f5; font-weight: 600; color: #4338ca;
}
.preview-close {
    background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #9ca3af;
    line-height: 1;
}
.preview-close:hover { color: #4f46e5; }
.preview-modal iframe {
    width: 100%; height: 70vh; border: none; background: #f4f4f7;
}

/* Editor estilo Gmail */
.gmail-editor {
    border: 1px solid #d1d5db; border-radius: 8px; overflow: hidden; margin-bottom: 16px;
}
.ge-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
    background: #f6f8fc; border-bottom: 1px solid #e5e7eb; padding: 6px 8px;
}
.ge-toolbar button {
    background: none; border: none; border-radius: 4px; padding: 5px 8px;
    font-size: 0.85rem; color: #444; cursor: pointer; min-width: 30px;
}
.ge-toolbar button:hover { background: #e8eaf0; }
.ge-toolbar select {
    border: 1px solid #d1d5db; border-radius: 4px; padding: 4px 6px;
    font-size: 0.8rem; background: #fff; cursor: pointer;
}
.ge-sep { width: 1px; height: 20px; background: #d1d5db; margin: 0 4px; }
.ge-color {
    display: inline-flex; align-items: center; gap: 2px; font-weight: 700;
    color: #444; cursor: pointer; padding: 3px 6px; border-radius: 4px; position: relative;
}
.ge-color:hover { background: #e8eaf0; }
.ge-color input[type=color] {
    width: 18px; height: 18px; border: none; padding: 0; cursor: pointer; background: none;
}
.ge-area {
    min-height: 260px; padding: 16px 18px; font-family: Arial, sans-serif;
    font-size: 15px; color: #333; line-height: 1.6; outline: none; background: #fff;
}
.ge-area:empty::before {
    content: "Escreva seu email aqui… use {nome} e {empresa} para personalizar.";
    color: #9ca3af;
}
.ge-area img { max-width: 100%; height: auto; border-radius: 6px; }

.blocks-empty { color: #9ca3af; font-size: 0.85rem; text-align: center; padding: 20px; }

.block {
    border: 1px solid #e5e7eb; border-radius: 8px; padding: 10px 12px;
    margin-bottom: 10px; background: #fafafe;
}
.block-head {
    display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.block-type { font-size: 0.75rem; font-weight: 700; color: #6366f1; text-transform: uppercase; flex: 1; }
.block-btn {
    background: none; border: none; cursor: pointer; font-size: 0.95rem;
    color: #9ca3af; padding: 2px 5px; border-radius: 4px;
}
.block-btn:hover { background: #eef0f5; color: #4f46e5; }
.block-btn.del:hover { color: #dc2626; }

.block input, .block textarea, .block select {
    width: 100%; padding: 7px 9px; border: 1px solid #d1d5db; border-radius: 6px;
    font-size: 0.86rem; font-family: inherit; margin-top: 6px;
}
.block textarea { resize: vertical; }
.block .block-row { display: flex; gap: 8px; }
.block .block-row > * { flex: 1; }
.block input[type=color] { padding: 2px; height: 38px; cursor: pointer; }
.block .img-actions { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.block .upload-btn {
    background: #4f46e5; color: #fff; border: none; border-radius: 6px;
    padding: 7px 12px; font-size: 0.8rem; cursor: pointer; white-space: nowrap;
}
.block .upload-status { font-size: 0.78rem; color: #6366f1; }
.block .size-label { font-size: 0.8rem; color: #666; align-self: center; flex: 0 0 auto; }

.preview-label { font-size: 0.8rem; font-weight: 600; color: #4338ca; margin-bottom: 8px; }
#preview-frame {
    width: 100%; height: 480px; border: 1px solid #e5e7eb; border-radius: 8px;
    background: #fff;
}

@media (max-width: 900px) {
    .editor-layout { flex-direction: column; }
    .preview-col { width: 100%; }
}

/* Resumo das campanhas */
.summary-card {
    background: linear-gradient(135deg, #4338ca, #6366f1); color: #fff;
    border-radius: 12px; padding: 18px 20px; margin-bottom: 18px;
}
.summary-title { font-size: 0.95rem; font-weight: 700; margin-bottom: 14px; }
.summary-metrics { display: flex; flex-wrap: wrap; gap: 18px; }
.sm-metric { min-width: 80px; }
.sm-value { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.sm-label { font-size: 0.72rem; opacity: .85; text-transform: uppercase; margin-top: 3px; }
.sm-sub { font-size: 0.72rem; opacity: .8; }
.summary-days {
    margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap;
    border-top: 1px solid rgba(255,255,255,.2); padding-top: 12px;
}
.sm-day {
    background: rgba(255,255,255,.12); border-radius: 8px; padding: 6px 10px;
    font-size: 0.76rem; text-align: center; min-width: 70px;
}
.sm-day b { display: block; font-size: 0.9rem; }

/* Leads quentes */
.leads-card {
    background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px;
    padding: 16px; margin-bottom: 18px;
}
.leads-head { font-weight: 600; color: #92400e; margin-bottom: 10px; }
.lead-item {
    display: flex; align-items: center; gap: 12px; padding: 9px 12px;
    background: #fff; border: 1px solid #fde68a; border-radius: 8px; margin-bottom: 6px;
}
.lead-temp { font-size: 0.8rem; white-space: nowrap; }
.lead-info { flex: 1; min-width: 0; }
.lead-name { font-weight: 600; color: #333; font-size: 0.88rem; }
.lead-meta { font-size: 0.76rem; color: #888; }
.lead-stats { font-size: 0.78rem; color: #b45309; white-space: nowrap; }

/* Emails para corrigir (bounces) */
.correction-card {
    background: #fff7ed; border: 1px solid #fed7aa; border-radius: 10px;
    padding: 16px; margin-bottom: 18px;
}
.correction-head {
    display: flex; align-items: center; justify-content: space-between;
    font-weight: 600; color: #9a3412; margin-bottom: 6px; flex-wrap: wrap; gap: 8px;
}
.correction-hint { font-size: 0.8rem; color: #b45309; margin-bottom: 10px; margin-top: 10px; }
.correction-toggle { cursor: pointer; user-select: none; }
.correction-toggle:hover { opacity: .8; }
#correction-arrow { font-size: 0.7rem; display: inline-block; }
.btn-check { background: #ea580c; color: #fff; }
.btn-download { background: #16a34a; color: #fff; text-decoration: none; display: inline-block; }
.btn-download:hover { background: #15803d; }
.correction-item {
    display: flex; justify-content: space-between; gap: 10px; padding: 7px 10px;
    background: #fff; border: 1px solid #fed7aa; border-radius: 6px; margin-bottom: 6px;
    font-size: 0.84rem;
}
.correction-item .ci-email { font-weight: 600; color: #7c2d12; }
.correction-item .ci-reason { color: #b45309; font-size: 0.76rem; }

/* Modal de envios */
.entries-body { padding: 0; overflow-y: auto; max-height: 70vh; }
.entry-row {
    display: flex; align-items: center; gap: 10px; padding: 9px 16px;
    border-bottom: 1px solid #f0f0f5; font-size: 0.85rem;
}
.entry-row:hover { background: #fafafe; }
.entry-email { flex: 1; color: #333; word-break: break-all; }
.entry-status {
    font-size: 0.72rem; font-weight: 700; padding: 2px 9px; border-radius: 10px;
    white-space: nowrap;
}
.st-sent { background: #d1fae5; color: #065f46; }
.st-failed, .st-bounced { background: #fee2e2; color: #991b1b; }
.st-pending { background: #e5e7eb; color: #374151; }
.entry-time { font-size: 0.72rem; color: #9ca3af; white-space: nowrap; }
.btn-entries { background: #6366f1; color: #fff; }

/* Lista de campanhas */
.campaigns-grid { display: flex; flex-direction: column; gap: 16px; }
.empty-msg { color: #999; text-align: center; padding: 30px; }

.campaign-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    overflow: hidden;
}
.campaign-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #f0f2f5;
    flex-wrap: wrap;
}
.campaign-name { font-weight: 600; font-size: 1rem; flex: 1; }
.campaign-type { font-size: 0.78rem; color: #6366f1; }

.badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-running { background: #d1fae5; color: #065f46; }
.badge-paused  { background: #fef3c7; color: #92400e; }
.badge-done    { background: #dbeafe; color: #1e40af; }
.badge-draft   { background: #e5e7eb; color: #374151; }

/* Métricas */
.metrics-row {
    display: flex;
    gap: 0;
    padding: 14px 16px;
    background: #fafafe;
    flex-wrap: wrap;
}
.metric {
    flex: 1;
    min-width: 90px;
    text-align: center;
    border-right: 1px solid #eef0f5;
    padding: 4px 0;
}
.metric:last-child { border-right: none; }
.metric-value { font-size: 1.3rem; font-weight: 700; color: #1a1a2e; }
.metric-label { font-size: 0.72rem; color: #888; text-transform: uppercase; letter-spacing: .03em; }
.metric-pct { font-size: 0.72rem; color: #6366f1; }

/* Barra de progresso */
.progress-wrap {
    padding: 0 16px 14px;
}
.progress-bar {
    height: 8px;
    background: #eef0f5;
    border-radius: 4px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    transition: width .4s;
}
.progress-text { font-size: 0.74rem; color: #888; margin-top: 4px; }

.campaign-actions { display: flex; gap: 6px; padding: 0 16px 14px; }

.btn {
    padding: 6px 14px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
    transition: opacity .15s;
}
.btn:hover { opacity: .85; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary   { background: #4f46e5; color: #fff; }
.btn-warning   { background: #f59e0b; color: #fff; }
.btn-success   { background: #10b981; color: #fff; }

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1a1a2e;
    color: #fff;
    padding: 12px 22px;
    border-radius: 8px;
    font-size: 0.88rem;
    opacity: 0;
    transition: all .3s;
    z-index: 1000;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error { background: #dc2626; }
