/* ============================================================
   DedicaQR — Sprint 22 — Email Templates customizables
   Paleta brand: rojo #C9184A, rosa #FFB3C1, gold #D4A24C, bg #FFF8F5
   Prefijos: .emt-*  (Email Template editor)
             .eq-*   (Email Queue)
   ============================================================ */

/* ============ Lista de templates ============ */

.emt-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin: 16px 0 24px;
}
.emt-stat-card {
    background: #fff;
    border: 1px solid #ffd6dd;
    border-left: 4px solid #C9184A;
    border-radius: 8px;
    padding: 14px 16px;
    box-shadow: 0 1px 3px rgba(201,24,74,0.04);
}
.emt-stat-customized { border-left-color: #D4A24C; }
.emt-stat-email     { border-left-color: #1d4ed8; }
.emt-stat-untested  { border-left-color: #dc2626; }
.emt-stat-lbl {
    display: block;
    font-size: 11px;
    color: #6b6b6b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.emt-stat-num {
    font-size: 26px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.1;
}

/* ============ Badges ============ */

.emt-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 11px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    margin-left: 6px;
    vertical-align: middle;
}
.emt-badge-customized { background: #D4A24C; color: #fff; }
.emt-badge-seed       { background: #e9e9e9; color: #4a4a4a; }
.emt-badge-email-on   { background: #DCFCE7; color: #15803D; }
.emt-badge-email-off  { background: #f3f4f6; color: #6b7280; }
.emt-badge-test       { background: #FEF3C7; color: #92400E; }

/* ============ Tabla templates ============ */

.emt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.emt-table th,
.emt-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #f0e4e7;
}
.emt-table th {
    background: #FFF1EE;
    font-weight: 600;
    color: #5a5a5a;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}
.emt-table tr:hover { background: #fffaf8; }
.emt-table code {
    background: #FFF1EE;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: #C9184A;
}

/* ============ Editor (split: form izq, preview der) ============ */

.emt-edit-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 20px;
    margin-top: 18px;
}

.emt-edit-form fieldset {
    border: 1px solid #ffd6dd;
    border-radius: 8px;
    padding: 16px 18px;
    margin-bottom: 16px;
    background: #fff;
}
.emt-edit-form fieldset legend {
    padding: 0 8px;
    font-weight: 600;
    color: #C9184A;
    font-size: 14px;
}

.emt-edit-form label {
    display: block;
    margin-top: 12px;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 13px;
    color: #4a4a4a;
}
.emt-edit-form input[type="text"],
.emt-edit-form input[type="email"],
.emt-edit-form textarea,
.emt-textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid #e5d3d7;
    border-radius: 6px;
    font-size: 13px;
    font-family: 'Nunito', system-ui, sans-serif;
    background: #fff;
}
.emt-edit-form input:focus,
.emt-edit-form textarea:focus {
    outline: 0;
    border-color: #C9184A;
    box-shadow: 0 0 0 3px rgba(201,24,74,0.12);
}
.emt-edit-form small {
    display: block;
    color: #888;
    font-size: 11px;
    margin-top: 3px;
    line-height: 1.4;
}
.emt-textarea {
    min-height: 140px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12.5px;
    line-height: 1.5;
}

.emt-toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #FFF8F5;
    border-radius: 6px;
    margin: 10px 0;
}
.emt-toggle {
    width: 18px;
    height: 18px;
    accent-color: #C9184A;
    cursor: pointer;
}
.emt-toggle-row label {
    margin: 0 !important;
    font-weight: 600;
    cursor: pointer;
}

/* ============ Placeholders sidebar ============ */

.emt-placeholders {
    background: #FFF8F5;
    border: 1px solid #ffd6dd;
    border-radius: 8px;
    padding: 14px 16px;
    margin-top: 12px;
}
.emt-placeholders h4 {
    margin: 10px 0 6px;
    font-size: 12px;
    text-transform: uppercase;
    color: #C9184A;
    letter-spacing: 0.5px;
}
.emt-ph-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.emt-ph-tag {
    display: inline-block;
    padding: 3px 8px;
    background: #fff;
    border: 1px solid #ffd6dd;
    border-radius: 12px;
    font-family: 'Consolas', monospace;
    font-size: 11px;
    color: #C9184A;
    cursor: pointer;
    transition: all .15s;
}
.emt-ph-tag:hover {
    background: #C9184A;
    color: #fff;
    border-color: #C9184A;
}

/* ============ Preview pane ============ */

.emt-preview-pane {
    position: sticky;
    top: 16px;
    align-self: start;
    background: #fff;
    border: 1px solid #ffd6dd;
    border-radius: 8px;
    padding: 14px;
}
.emt-preview-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #ffd6dd;
}
.emt-preview-head h3 {
    margin: 0;
    font-size: 14px;
    color: #C9184A;
}
.emt-preview-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 10px;
    border-bottom: 1px solid #ffd6dd;
}
.emt-ptab {
    padding: 8px 14px;
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: #888;
}
.emt-ptab.active {
    color: #C9184A;
    border-bottom-color: #C9184A;
}

.emt-preview-subject {
    background: #FFF8F5;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    color: #4a4a4a;
    margin-bottom: 10px;
    word-break: break-word;
}
.emt-preview-subject strong {
    color: #C9184A;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.5px;
    margin-right: 6px;
}

.emt-preview-iframe {
    width: 100%;
    min-height: 500px;
    border: 1px solid #e5d3d7;
    border-radius: 6px;
    background: #fff;
}
.emt-preview-text {
    width: 100%;
    min-height: 500px;
    padding: 14px;
    background: #fafafa;
    border: 1px solid #e5d3d7;
    border-radius: 6px;
    font-family: 'Consolas', monospace;
    font-size: 12px;
    white-space: pre-wrap;
    color: #2a2a2a;
    overflow: auto;
}

.emt-unresolved {
    background: #FEF3C7;
    border-left: 3px solid #D4A24C;
    padding: 8px 12px;
    border-radius: 4px;
    margin-top: 10px;
    font-size: 12px;
    color: #92400E;
}
.emt-unresolved code {
    background: rgba(146,64,14,0.1);
    padding: 1px 4px;
    border-radius: 3px;
    margin: 0 2px;
}

/* ============ Test send box ============ */

.emt-test-send {
    background: #FFF8F5;
    border: 1px solid #ffd6dd;
    border-radius: 8px;
    padding: 14px 16px;
    margin-top: 14px;
}
.emt-test-send h4 {
    margin: 0 0 8px;
    font-size: 13px;
    color: #C9184A;
}
.emt-test-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.emt-test-row input {
    flex: 1;
    padding: 8px 11px;
    border: 1px solid #e5d3d7;
    border-radius: 6px;
    font-size: 13px;
}

/* ============ Form footer ============ */

.emt-form-foot {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid #ffd6dd;
}

/* ============ Revisions mini list (en edit) ============ */

.emt-revisions-mini {
    background: #FFF8F5;
    border-radius: 8px;
    padding: 10px 14px;
    margin-top: 14px;
    font-size: 12px;
}
.emt-revisions-mini h4 {
    margin: 0 0 6px;
    font-size: 12px;
    text-transform: uppercase;
    color: #C9184A;
    letter-spacing: 0.4px;
}
.emt-rev-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

/* ============ Revision view (diff) ============ */

.emt-rev-meta {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 12px 14px;
    background: #FFF8F5;
    border-radius: 8px;
    margin: 14px 0;
    font-size: 13px;
}
.emt-rev-meta strong { color: #C9184A; }

.emt-rev-kind {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 11px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
    vertical-align: middle;
}
.emt-rev-kind-create  { background: #DCFCE7; color: #15803D; }
.emt-rev-kind-edit    { background: #FFE4E6; color: #C9184A; }
.emt-rev-kind-restore { background: #FEF3C7; color: #92400E; }
.emt-rev-kind-seed    { background: #DBEAFE; color: #1d4ed8; }

.emt-diff-section {
    background: #fff;
    border: 1px solid #ffd6dd;
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 14px;
}
.emt-diff-section h3 {
    margin: 0 0 10px;
    font-size: 13px;
    color: #C9184A;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.emt-diff-block {
    background: #fafafa;
    border: 1px solid #e5d3d7;
    border-radius: 6px;
    padding: 8px;
    font-family: 'Consolas', monospace;
    font-size: 12px;
    max-height: 400px;
    overflow-y: auto;
}
.emt-diff-line {
    padding: 2px 8px;
    white-space: pre-wrap;
    border-radius: 2px;
}
.emt-diff-line-same { color: #4a4a4a; }
.emt-diff-line-add  { background: #DCFCE7; color: #15803D; }
.emt-diff-line-del  { background: #FEE2E2; color: #B91C1C; text-decoration: line-through; }
.emt-diff-same      { color: #4a4a4a; }

.emt-restore-action {
    background: linear-gradient(135deg, #FFF8F5 0%, #FFE4E6 100%);
    border: 2px solid #C9184A;
    border-radius: 10px;
    padding: 20px 24px;
    margin-top: 24px;
    text-align: center;
}
.emt-restore-action h3 {
    margin: 0 0 8px;
    color: #C9184A;
}

.emt-rev-pre {
    font-family: 'Consolas', monospace;
    font-size: 12px;
    white-space: pre-wrap;
    background: #fafafa;
    padding: 10px;
    border-radius: 4px;
    margin: 6px 0;
}

/* ============ SMTP test panel ============ */

.emt-smtp-log {
    background: #1a1a1a;
    color: #4ade80;
    padding: 12px 14px;
    border-radius: 6px;
    font-family: 'Consolas', monospace;
    font-size: 11.5px;
    line-height: 1.5;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 10px;
}
.emt-smtp-log .err  { color: #f87171; }
.emt-smtp-log .ok   { color: #4ade80; }
.emt-smtp-log .info { color: #fbbf24; }

/* ============ Tabs (for edit page layout) ============ */

.emt-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #ffd6dd;
    margin: 14px 0;
}
.emt-tab {
    padding: 10px 18px;
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #6b6b6b;
    margin-bottom: -2px;
}
.emt-tab.active {
    color: #C9184A;
    border-bottom-color: #C9184A;
}
.emt-tab-content { display: none; }
.emt-tab-content.active { display: block; }

/* ============================================================
   EMAIL QUEUE (.eq-*)
   ============================================================ */

.eq-stats {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
    margin: 16px 0 24px;
}
.eq-stat {
    background: #fff;
    border: 1px solid #ffd6dd;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}
.eq-stat-lbl {
    display: block;
    font-size: 10px;
    color: #6b6b6b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.eq-stat-num {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.1;
}

/* Status badges */
.eq-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.eq-st-pending   { background: #FEF3C7; color: #92400E; }
.eq-st-sending   { background: #DBEAFE; color: #1d4ed8; }
.eq-st-sent      { background: #DCFCE7; color: #15803D; }
.eq-st-failed    { background: #FEE2E2; color: #B91C1C; }
.eq-st-bounced   { background: #FFE4E6; color: #9F1239; }
.eq-st-cancelled { background: #f3f4f6; color: #6b7280; }

/* ============ Responsive ============ */

@media (max-width: 1100px) {
    .emt-edit-grid {
        grid-template-columns: 1fr;
    }
    .emt-preview-pane {
        position: relative;
        top: auto;
    }
}

@media (max-width: 900px) {
    .emt-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    .eq-stats {
        grid-template-columns: repeat(4, 1fr);
    }
    .emt-rev-meta {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 600px) {
    .emt-stats,
    .eq-stats {
        grid-template-columns: 1fr 1fr;
    }
    .emt-rev-meta {
        grid-template-columns: 1fr;
    }
    .emt-test-row {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ============ Patches sintácticos ============ */

/* Container general de la página edit */
.emt-edit { /* solo container, sin estilos extra */ }

/* Card de preview (alias del wrapper preview-pane) */
.emt-preview-card {
    background: #fff;
    border: 1px solid #ffd6dd;
    border-radius: 8px;
    padding: 14px;
}

/* Aliases para los kind-* usados en revisions.php (sin el prefijo "rev-") */
.emt-kind-create, .emt-kind-edit, .emt-kind-restore, .emt-kind-seed {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 11px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 4px;
    vertical-align: middle;
}
.emt-kind-create  { background: #DCFCE7; color: #15803D; }
.emt-kind-edit    { background: #FFE4E6; color: #C9184A; }
.emt-kind-restore { background: #FEF3C7; color: #92400E; }
.emt-kind-seed    { background: #DBEAFE; color: #1d4ed8; }
