/* ============================================================
   Discarma Campañas — estilos base
   ============================================================ */

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

:root {
    --primary:      #8B1A1A;
    --primary-dark: #6B1414;
    --primary-light:#C0392B;
    --sidebar-bg:   #1a1a2e;
    --sidebar-text: #c8ccd4;
    --sidebar-active: #8B1A1A;
    --bg:           #f4f5f7;
    --white:        #ffffff;
    --border:       #e2e5ea;
    --text:         #1a1a2e;
    --text-muted:   #6b7280;
    --success:      #16a34a;
    --warning:      #d97706;
    --danger:       #dc2626;
    --info:         #2563eb;
    --radius:       8px;
    --shadow:       0 1px 4px rgba(0,0,0,.08);
    --shadow-md:    0 4px 12px rgba(0,0,0,.12);
}

body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* Layout */
.app-layout   { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar          { width: 220px; background: var(--sidebar-bg); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; }
.sidebar-logo     { display: flex; align-items: center; gap: 10px; padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.logo-icon        { font-size: 22px; }
.logo-text        { color: #fff; font-weight: 700; font-size: 15px; }
.sidebar-nav      { flex: 1; padding: 14px 0; }
.nav-item         { display: flex; align-items: center; gap: 10px; padding: 10px 18px; color: var(--sidebar-text); text-decoration: none; font-size: 13.5px; transition: background .15s, color .15s; }
.nav-item:hover   { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active  { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-icon         { font-size: 15px; width: 18px; text-align: center; }
.sidebar-footer   { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-user     { display: block; color: var(--sidebar-text); font-size: 12px; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-link      { font-size: 12px; color: #e87474; text-decoration: none; }
.logout-link:hover{ text-decoration: underline; }

/* Main */
.main-content { margin-left: 220px; flex: 1; display: flex; flex-direction: column; }
.topbar       { background: var(--white); border-bottom: 1px solid var(--border); padding: 16px 28px; }
.page-title   { font-size: 18px; font-weight: 600; color: var(--text); }
.content-body { padding: 24px 28px; }

/* Cards */
.card         { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card-title   { font-size: 13px; color: var(--text-muted); font-weight: 500; margin-bottom: 6px; }
.card-value   { font-size: 28px; font-weight: 700; color: var(--text); }

.stats-grid   { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }

/* Formularios */
.form-section  { margin-bottom: 28px; }
.form-label    { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-label .req { color: var(--primary); margin-left: 2px; }
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 9px 12px; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 13.5px; color: var(--text);
    background: var(--white); transition: border-color .15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none; border-color: var(--primary);
}
.form-textarea { resize: vertical; min-height: 110px; }
.form-hint     { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Campo bloqueado */
.locked-field  { background: #f8f9fa; border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 12px; font-size: 13.5px; color: var(--text-muted); display: flex; justify-content: space-between; align-items: center; }
.lock-icon     { font-size: 12px; color: #9ca3af; }

/* Botones */
.btn           { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: var(--radius); font-size: 13.5px; font-weight: 500; cursor: pointer; border: none; text-decoration: none; transition: background .15s; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-sm        { padding: 5px 12px; font-size: 12.5px; }

/* Badges de estado */
.badge         { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-pendiente  { background: #fef3c7; color: #92400e; }
.badge-activa     { background: #d1fae5; color: #065f46; }
.badge-pausada    { background: #e5e7eb; color: #374151; }
.badge-completada { background: #dbeafe; color: #1e40af; }
.badge-error      { background: #fee2e2; color: #991b1b; }
.badge-enviado    { background: #e0f2fe; color: #0369a1; }
.badge-entregado  { background: #d1fae5; color: #065f46; }
.badge-leido      { background: #ede9fe; color: #5b21b6; }
.badge-fallido    { background: #fee2e2; color: #991b1b; }
.badge-test       { background: #fef3c7; color: #78350f; border: 1px solid #fde68a; }

/* Tablas */
.table-wrap    { overflow-x: auto; }
table          { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th             { text-align: left; padding: 10px 14px; background: #f8f9fa; border-bottom: 2px solid var(--border); font-weight: 600; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
td             { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text); }
tr:last-child td { border-bottom: none; }
tr:hover td    { background: #fafafa; }

/* Upload */
.upload-area   { border: 2px dashed var(--border); border-radius: var(--radius); padding: 28px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.upload-area:hover, .upload-area.drag-over { border-color: var(--primary); background: #fdf2f2; }
.upload-icon   { font-size: 28px; margin-bottom: 8px; }
.upload-text   { font-size: 13px; color: var(--text-muted); }
.upload-preview img { max-width: 100%; max-height: 200px; border-radius: var(--radius); margin-top: 10px; }

/* Alerta de destinatarios */
.destinatarios-box { background: #fff7ed; border: 1px solid #fed7aa; border-radius: var(--radius); padding: 12px 16px; display: flex; align-items: center; gap: 10px; }
.destinatarios-num { font-size: 22px; font-weight: 700; color: var(--primary); }
.destinatarios-label { font-size: 13px; color: var(--text-muted); }

/* Grids */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* Layout creación campaña: form + preview */
.campaign-layout { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
.preview-sticky  { position: sticky; top: 24px; }

/* Preview WhatsApp */
.wa-preview       { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-md); overflow: hidden; }
.wa-preview-header{ background: #1a1a2e; color: #fff; padding: 10px 14px; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.wa-phone-frame   { background: #e5ddd5; padding: 14px 12px; min-height: 280px; }
.wa-contact-bar   { background: #075e54; color: #fff; padding: 8px 12px; display: flex; align-items: center; gap: 10px; border-radius: 6px 6px 0 0; margin-bottom: 12px; }
.wa-avatar        { width: 32px; height: 32px; background: #128c7e; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.wa-contact-name  { font-size: 13px; font-weight: 600; }
.wa-contact-status{ font-size: 11px; color: #9de1db; }
.wa-bubble        { background: #fff; border-radius: 0 8px 8px 8px; padding: 0; max-width: 92%; box-shadow: 0 1px 2px rgba(0,0,0,.12); overflow: hidden; }
.wa-bubble-img-wrap { aspect-ratio: 16/9; overflow: hidden; display: block; }
.wa-bubble-img      { width: 100%; height: 100%; object-fit: cover; display: block; }
.wa-bubble-body   { padding: 8px 10px 4px; }
.wa-greeting      { font-size: 13px; color: #111; font-weight: 500; margin-bottom: 10px; }
.wa-message       { font-size: 13px; color: #333; white-space: pre-wrap; word-break: break-word; margin-bottom: 10px; }
.wa-fixed-text    { font-size: 12.5px; color: #555; }
.wa-separator     { border: none; border-top: 1px solid #e5e5e5; margin: 6px 0; }
.wa-footer        { font-size: 11.5px; color: #9ca3af; font-style: italic; padding: 4px 10px 8px; }
.wa-time          { text-align: right; font-size: 11px; color: #9ca3af; padding: 0 10px 6px; }
.wa-placeholder   { color: #aaa; font-style: italic; font-size: 13px; }
.wa-caption       { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 10px; }

/* Sección de envío de prueba */
.test-send-row { display: flex; gap: 8px; align-items: flex-end; }
.prefix-select { width: 110px; }

/* Login */
.login-wrap   { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card   { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 40px 36px; width: 100%; max-width: 380px; }
.login-logo   { text-align: center; margin-bottom: 28px; }
.login-logo-icon { font-size: 40px; }
.login-logo-text { display: block; font-size: 20px; font-weight: 700; color: var(--text); margin-top: 6px; }
.login-logo-sub  { font-size: 13px; color: var(--text-muted); }
.login-form-title{ font-size: 15px; font-weight: 600; margin-bottom: 18px; }
.btn-block    { width: 100%; justify-content: center; }
.alert        { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 14px; }
.alert-error  { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success{ background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }

/* Tabs de audiencia */
.audiencia-tabs       { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 16px; }
.audiencia-tab        { padding: 8px 18px; cursor: pointer; font-size: 13px; font-weight: 500;
                        color: var(--text-muted); background: none; border: none;
                        border-bottom: 2px solid transparent; margin-bottom: -2px;
                        transition: color .15s, border-color .15s; }
.audiencia-tab:hover  { color: var(--text); }
.audiencia-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* Zona de subida de Excel */
.excel-upload-area      { border: 2px dashed var(--border); border-radius: var(--radius);
                          padding: 28px; text-align: center; cursor: pointer;
                          transition: border-color .15s, background .15s; }
.excel-upload-area:hover,
.excel-upload-area.drag-over { border-color: var(--primary); background: #fdf2f2; }
.excel-upload-area.excel-ok  { border-color: var(--success); background: #f0fdf4; }

/* Modal overlay */
.modal-overlay  { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1000;
                  display: flex; align-items: center; justify-content: center;
                  padding: 16px; }
.modal-box      { background: var(--white); border-radius: var(--radius);
                  box-shadow: var(--shadow-md); width: 100%; max-width: 600px;
                  max-height: 80vh; display: flex; flex-direction: column; }
.modal-header   { padding: 14px 20px; border-bottom: 1px solid var(--border);
                  display: flex; justify-content: space-between; align-items: center; }
.modal-title    { font-size: 15px; font-weight: 600; color: var(--text); }
.modal-close    { background: none; border: none; font-size: 22px; line-height: 1;
                  cursor: pointer; color: var(--text-muted); padding: 0 4px; }
.modal-close:hover { color: var(--text); }
.modal-search   { padding: 10px 16px; border-bottom: 1px solid var(--border); }
.modal-body     { flex: 1; overflow-y: auto; }
.modal-loading  { padding: 32px; text-align: center; color: var(--text-muted); font-size: 13px; }
.modal-footer   { padding: 8px 16px; border-top: 1px solid var(--border);
                  font-size: 12px; color: var(--text-muted); text-align: right; }

/* Responsive básico */
@media (max-width: 900px) {
    .campaign-layout { grid-template-columns: 1fr; }
    .preview-sticky  { position: static; }
    .stats-grid      { grid-template-columns: 1fr 1fr; }
}
