/* ============================================================
   CRM FRONTEND LIST — Stylesheet
   Scope: #crm_frontend_list_wrap và các thành phần con
   ============================================================ */

/* ---------- 1. WRAPPER ---------- */
#crm_frontend_list_wrap {
    background: #f4f6f9;
    padding: 0;
    border-radius: 12px;
    border: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    color: #2d3748;
}

/* ---------- 2. HEADER ---------- */
.crm-list-header {
    background: #fff;
    padding: 18px 24px;
    border-radius: 12px 12px 0 0;
    border-bottom: 1px solid #e8ecf1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.crm-list-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #1a202c;
    letter-spacing: -0.3px;
}

.crm-list-header h2 span {
    color: #2271b1;
}

.crm-header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.crm-header-actions a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none !important;
    transition: all 0.18s ease;
    background: #2271b1;
    color: #fff !important;
    border: 1.5px solid transparent;
}

.crm-header-actions a:hover {
    background: #135e96;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34,113,177,0.25);
}

.crm-header-actions a .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* ---------- 3. MINI STATS ---------- */
.crm-mini-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 16px 24px;
    background: #fff;
    border-bottom: 1px solid #e8ecf1;
}

.crm-stat-card {
    background: #f8fafc;
    border-radius: 10px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid #e8ecf1;
    transition: box-shadow 0.18s;
}

.crm-stat-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.07);
}

.crm-stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.crm-stat-icon.blue  { background: #dbeafe; }
.crm-stat-icon.red   { background: #fee2e2; }
.crm-stat-icon.green { background: #dcfce7; }

.crm-stat-body {}

.crm-stat-label {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.crm-stat-number {
    font-size: 26px;
    font-weight: 800;
    line-height: 1;
}

.crm-stat-number.blue  { color: #2271b1; }
.crm-stat-number.red   { color: #dc2626; }
.crm-stat-number.green { color: #16a34a; }

/* ---------- 4. REMINDER TABS ---------- */
.crm-reminder-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 12px 24px;
    background: #fff;
    border-bottom: 1px solid #e8ecf1;
}

.crm-reminder-tabs a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 13px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none !important;
    border: 1.5px solid #e35b5b;
    color: #e35b5b;
    background: #fff;
    transition: all 0.15s;
}

.crm-reminder-tabs a:hover,
.crm-reminder-tabs a.active {
    background: #e35b5b;
    color: #fff !important;
}

.crm-reminder-tabs a.clear-filter {
    border-color: #d1d5db;
    color: #6b7280;
}

.crm-reminder-tabs a.clear-filter:hover {
    background: #f3f4f6;
    color: #374151 !important;
}

/* ---------- 5. FILTER FORM ---------- */
.crm-filter-form {
    background: #fff;
    padding: 12px 20px;
    border-bottom: 1px solid #e8ecf1;
    display: grid;
    /* Hàng 1: Tìm tên/SĐT(rộng) | Tuổi con | Cán bộ TS | Chương trình | Nhóm ĐT
       Hàng 2: Kênh | Khối học | Từ→Đến | Trạng thái | [Lọc + Xóa] */
    grid-template-columns: 2fr 1fr 1.5fr 1.5fr 1.5fr;
    gap: 8px;
    align-items: center;
}

/* Base style cho tất cả input/select trong form */
.crm-filter-form input[type="text"],
.crm-filter-form input[type="date"],
.crm-filter-form select {
    width: 100%;
    padding: 7px 9px;
    border: 1.5px solid #d1d5db;
    border-radius: 7px;
    font-size: 12.5px;
    color: #374151;
    background: #fafafa;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}

.crm-filter-form input:focus,
.crm-filter-form select:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 3px rgba(34,113,177,0.10);
    background: #fff;
}

/* Ô Từ→Đến gộp chung */
.crm-filter-date-range {
    display: flex;
    align-items: center;
    gap: 3px;
    min-width: 0;
}

.crm-date-sep {
    font-size: 11px;
    color: #9ca3af;
    flex-shrink: 0;
}

.crm-filter-date-range input[type="date"] {
    flex: 1;
    min-width: 0;
    padding: 7px 4px;
    font-size: 11px;
}

/* Nút lọc + xóa — nằm ngang cùng hàng, nhỏ gọn */
.crm-filter-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
}

.crm-btn-filter {
    background: #2271b1;
    color: #fff !important;
    border: none;
    padding: 7px 14px;
    border-radius: 7px;
    cursor: pointer;
    font-weight: 700;
    font-size: 12.5px;
    white-space: nowrap;
    transition: background 0.15s;
    line-height: 1;
}

.crm-btn-filter:hover {
    background: #135e96;
}

.crm-btn-clear {
    font-size: 11.5px;
    color: #9ca3af;
    text-decoration: none !important;
    font-weight: 500;
    white-space: nowrap;
    transition: color 0.15s;
}

.crm-btn-clear:hover {
    color: #dc2626;
}

/* ---------- 6. TABLE ---------- */
.crm-table-wrap {
    background: #fff;
    overflow-x: auto;
    border-radius: 0 0 12px 12px;
}

.crm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.crm-table thead tr {
    background: #f8fafc;
    border-bottom: 2px solid #e8ecf1;
}

.crm-table thead th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 700;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #4b5563;
    white-space: nowrap;
}

.crm-table tbody tr {
    border-bottom: 1px solid #f0f4f8;
    transition: background 0.12s;
}

.crm-table tbody tr:hover {
    background: #f8fbff;
}

.crm-table tbody tr:last-child {
    border-bottom: none;
}

.crm-table td {
    padding: 9px 12px;
    vertical-align: middle;
}

/* Cột checkbox bulk assign */
.crm-table th:first-child,
.crm-table td:first-child {
    width: 32px;
    min-width: 32px;
    text-align: center;
    padding-left: 8px;
    padding-right: 4px;
}

.crm-row-check,
#crm-check-all {
    width: 15px;
    height: 15px;
    accent-color: #2271b1;
}

/* Cột ngày */
.crm-col-date {
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
}

/* Cột tên khách hàng */
.crm-col-name {
    font-weight: 700;
    color: #2271b1;
    font-size: 13.5px;
}

/* Cột SĐT */
.crm-col-phone {
    font-weight: 600;
    color: #1a202c;
    white-space: nowrap;
    font-size: 13px;
}

/* Cột nhân viên */
.crm-col-staff {
    font-size: 12.5px;
    color: #374151;
}

/* Cột MKT */
.crm-col-mkt {
    font-size: 11.5px;
    font-weight: 600;
    color: #c0392b;
}

/* Cột kênh */
.crm-col-source {
    font-size: 12px;
    color: #4b5563;
}

/* Cột chăm cuối */
.last-care-box {
    font-size: 12px;
    color: #6b7280;
}

.last-care-active {
    color: #059669;
    font-weight: 600;
}

/* Cột trạng thái */
.crm-status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
}

/* ---------- 7. ACTION BUTTONS ---------- */
.crm-actions {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    text-decoration: none !important;
    color: #fff !important;
    font-size: 12px;
    font-weight: bold;
    line-height: 1;
    border: none;
    cursor: pointer;
    transition: all 0.18s ease;
    font-family: Arial, sans-serif;
}

.btn-zalo   { background: #0068ff; }
.btn-view   { background: #2271b1; }
.btn-edit   { background: #f59e0b; }
.btn-delete { background: #ef4444; }

.btn-action:hover {
    opacity: 0.88;
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.18);
    color: #fff !important;
}

/* ---------- 8. PAGINATION ---------- */
.crm-pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 14px 20px;
    background: #fff;
    border-top: 1px solid #e8ecf1;
    flex-wrap: wrap;
}

.crm-pagination a,
.crm-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1.5px solid #d1d5db;
    border-radius: 7px;
    text-decoration: none !important;
    color: #374151;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.15s;
    background: #fff;
}

.crm-pagination a:hover {
    border-color: #2271b1;
    color: #2271b1;
    background: #f0f7ff;
}

.crm-pagination .current,
.crm-pagination span.current {
    background: #2271b1;
    color: #fff !important;
    border-color: #2271b1;
    font-weight: 700;
}

/* ---------- 9. MODAL ---------- */
.crm-modal-overlay {
    display: none;
    position: fixed;
    z-index: 99999;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
}

.crm-modal-content {
    background: #fff;
    width: 660px;
    max-width: 95%;
    margin: 36px auto;
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.18);
    animation: crmSlideDown 0.25s ease-out;
    overflow: hidden;
}

@keyframes crmSlideDown {
    from { opacity: 0; transform: translateY(-16px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.crm-modal-header {
    background: #fff;
    padding: 16px 22px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.crm-modal-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: #1a202c;
    display: flex;
    align-items: center;
    gap: 8px;
}

.crm-modal-close {
    font-size: 26px;
    color: #9ca3af;
    cursor: pointer;
    line-height: 1;
    transition: color 0.15s;
}

.crm-modal-close:hover { color: #ef4444; }

.crm-modal-body {
    padding: 16px 20px;
    max-height: 72vh;
    overflow-y: auto;
    display: block;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db #f9fafb;
}

.crm-modal-body label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    color: #374151;
    font-size: 12.5px;
}

.crm-modal-body input,
.crm-modal-body select {
    width: 100%;
    padding: 9px 11px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    color: #1a202c;
    background: #fafafa;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}

.crm-modal-body input:focus,
.crm-modal-body select:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 3px rgba(34,113,177,0.12);
    background: #fff;
    outline: none;
}

.crm-modal-footer {
    padding: 14px 22px;
    border-top: 1px solid #f0f0f0;
    background: #fafafa;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-cancel {
    background: #fff;
    border: 1.5px solid #d1d5db;
    padding: 9px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    color: #374151;
    transition: all 0.15s;
}

.btn-cancel:hover {
    border-color: #9ca3af;
    background: #f9fafb;
}

.btn-save-now {
    background: #2271b1;
    color: #fff;
    border: none;
    padding: 9px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
}

.btn-save-now:hover {
    background: #135e96;
    box-shadow: 0 4px 10px rgba(34,113,177,0.3);
}

.crm-loading {
    grid-column: span 2;
    text-align: center;
    padding: 36px;
    color: #6b7280;
    font-size: 14px;
}

/* ---------- 10. EMPTY ROW ---------- */
.crm-empty-row td {
    padding: 40px 20px;
    text-align: center;
    color: #9ca3af;
    font-size: 14px;
}

/* ---------- 11. RESPONSIVE ---------- */
@media (max-width: 900px) {
    .crm-filter-form        { grid-template-columns: repeat(2, 1fr); }
    .crm-filter-actions     { grid-row: auto; flex-direction: row; justify-content: flex-end; grid-column: span 2; }
    .crm-btn-filter         { height: auto; padding: 8px 18px; }
}

@media (max-width: 768px) {
    .crm-mini-stats         { grid-template-columns: 1fr; }
    .crm-filter-form        { grid-template-columns: 1fr 1fr; }
    .crm-list-header        { flex-direction: column; align-items: flex-start; }
    .crm-modal-body         { grid-template-columns: 1fr; }
    .crm-modal-body > div:first-child { grid-column: span 1; }
    .crm-modal-content      { margin: 12px auto; }
    .crm-filter-date-range  { flex-direction: column; gap: 3px; }
}
