/* ============================================================
   AutoDeal360 — Centro de Mensajería
   Identidad AD360 estándar: navy #20376A / azul #004B94
   ============================================================ */

body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    padding: 15px;
    box-sizing: border-box;
    background: #f5f7fa;
    font-family: 'Roboto', sans-serif;
}

.module-header {
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}
.module-title {
    font-size: 22px;
    color: #004B94;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.card {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,.05);
    padding: 20px;
}

/* ── FILTROS ── */
.filters {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
    flex-shrink: 0;
}
.search-container { flex: 1; max-width: 420px; position: relative; }
.search-container::before {
    content: '\f002';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    font-size: 14px;
    pointer-events: none;
}
.filter-field {
    width: 100%;
    height: 42px;
    padding: 0 14px 0 35px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}
.filter-field:focus { outline: none; border-color: #004B94; box-shadow: 0 0 0 3px rgba(0,75,148,.12); }

.btn-secondary {
    height: 42px;
    padding: 0 18px;
    background: #fff;
    border: 1px solid #ddd;
    color: #495057;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all .15s;
}
.btn-secondary:hover { background: #f8f9fa; border-color: #004B94; color: #004B94; }
.btn-secondary i { transition: transform .3s; }
.btn-secondary:hover i { transform: rotate(180deg); }

/* ── CONTROLES DE TABLA / PAGINACIÓN ── */
.table-controls { flex-shrink: 0; padding-bottom: 12px; }
.pagination-controls { display: flex; align-items: center; gap: 14px; font-size: 12px; color: #495057; }
.rows-per-page { display: flex; align-items: center; gap: 6px; }
.rows-per-page label { font-weight: 600; }
.rows-per-page select {
    height: 30px;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 0 8px;
    font-size: 12px;
    font-family: inherit;
    background: #fff;
}
.contador-badge {
    background: #004B94;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 9px;
    border-radius: 10px;
}
.pagination-buttons { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.page-btn {
    width: 28px; height: 28px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    color: #495057;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
}
.page-btn:hover:not(:disabled) { background: #eef5fc; border-color: #004B94; color: #004B94; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }
#pageInfo { font-size: 12px; color: #495057; min-width: 95px; text-align: center; }

/* ── TABLA ── */
.table-wrapper {
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #e9ecef;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.table-container { flex: 1; min-height: 0; overflow: auto; }

#colaTable {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
#colaTable thead { display: table; width: 100%; table-layout: fixed; flex-shrink: 0; }
#colaTable thead th {
    background: #004B94;
    color: #fff;
    padding: 12px 14px;
    text-align: left;
    font-weight: 500;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: .4px;
}
#colaTable tbody { display: block; overflow-y: auto; flex: 1; min-height: 0; background: #fafbfc; }
#colaTable tbody tr { display: table; width: 100%; table-layout: fixed; transition: background .12s; }
#colaTable tbody tr:nth-child(even) { background: #f5f7fa; }
#colaTable tbody tr:hover { background: #eef5fc; }
#colaTable tbody tr.fila-cargando:hover { background: transparent; }
#colaTable tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid #f1f3f5;
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #2d3748;
}
#colaTable tbody tr:last-child td { border-bottom: none; }
.fila-vacia td { padding: 30px !important; text-align: center; }

/* Anchos de columna — declarados una vez, aplicados a th Y td por posición,
   para que thead y cada fila (tablas CSS independientes) queden alineados. */
#colaTable th:nth-child(1), #colaTable td:nth-child(1) { width: 90px; font-weight: 600; }
#colaTable th:nth-child(2), #colaTable td:nth-child(2) { width: 100px; }
#colaTable th:nth-child(3), #colaTable td:nth-child(3) { width: 120px; }
#colaTable th:nth-child(4), #colaTable td:nth-child(4) { width: 260px; }
#colaTable th:nth-child(5), #colaTable td:nth-child(5) { width: 110px; }
#colaTable th:nth-child(6), #colaTable td:nth-child(6) { width: 150px; font-size: 12px; }
#colaTable th:nth-child(7), #colaTable td:nth-child(7) { width: 150px; font-size: 12px; }
#colaTable th:nth-child(8), #colaTable td:nth-child(8) { width: auto; text-align: center; white-space: normal; }

/* Badges de tipo (EMAIL / WHATSAPP) */
.badge-tipo {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: #fff;
}
.badge-tipo.email { background: #004B94; }
.badge-tipo.whatsapp { background: #198754; }

/* Badges de estado */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: #fff;
}
.status-badge.PENDIENTE { background: #f59e0b; }
.status-badge.ENVIADO { background: #198754; }
.status-badge.ERROR { background: #dc3545; }

/* Acciones en tabla */
.acciones-cell { display: flex; justify-content: center; align-items: center; gap: 4px; }
.btn-icon {
    background: none;
    border: none;
    width: 28px; height: 28px;
    cursor: pointer;
    border-radius: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
    font-size: 12px;
}
.btn-icon.retry { color: #f59e0b; }
.btn-icon.retry:hover { background: #fff4e0; }
.btn-icon.info { color: #6c757d; }
.btn-icon.info:hover { background: #eef5fc; color: #004B94; }
.icon-ok { color: #198754; font-size: 14px; }

/* ── LOADING ── */
.loading-mini { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 30px; color: #6c757d; font-size: 13px; }
.spinner-mini {
    width: 18px; height: 18px;
    border: 2px solid #e9ecef;
    border-top-color: #004B94;
    border-radius: 50%;
    animation: mensajeria-spin .7s linear infinite;
}
@keyframes mensajeria-spin { to { transform: rotate(360deg); } }

/* ── RESPONSIVE ── */
@media (max-width: 700px) {
    .filters { flex-direction: column; align-items: stretch; }
    .pagination-controls { flex-wrap: wrap; row-gap: 8px; }
    .pagination-buttons { margin-left: 0; }
}