/* =============================================
   CRM Lead Manager — Frontend CSS v2
   Clean, modern, Flatsome compatible
   ============================================= */

.clm-frontend { font-family: inherit; color: inherit; }

/* ── Alerts ── */
.clm-alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 20px; font-weight: 500; }
.clm-alert-success { background: #ecfdf5; border: 1px solid #6ee7b7; color: #065f46; }
.clm-notice { padding: 12px 16px; background: #f3f4f6; border-radius: 6px; }
.clm-notice.clm-error { background: #fee2e2; color: #b91c1c; }

/* ── Stats Bar ── */
.clm-fe-stats {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.clm-fe-stat {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 18px;
    min-width: 110px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
    flex: 1;
}
.clm-fe-stat-total { border-left: 3px solid #3b82f6; }
.clm-fe-stat-num {
    font-size: 24px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.1;
}
.clm-fe-stat-lbl {
    font-size: 11px;
    color: #64748b;
    margin-top: 3px;
    white-space: nowrap;
}

/* ── Filter Bar ── */
.clm-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
    padding: 12px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}
.clm-fe-select,
.clm-fe-input {
    height: 36px;
    padding: 0 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    color: #374151;
    background: #fff;
    min-width: 140px;
}
.clm-fe-input { min-width: 180px; }

/* ── Buttons ── */
.clm-btn {
    display: inline-block;
    padding: 9px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none !important;
    transition: background 0.15s, box-shadow 0.15s;
    line-height: 1;
    white-space: nowrap;
}
.clm-btn-primary { background: #2563eb; color: #fff !important; }
.clm-btn-primary:hover { background: #1d4ed8; color: #fff !important; }
.clm-btn-outline { background: #fff; color: #374151 !important; border: 1px solid #d1d5db; }
.clm-btn-outline:hover { background: #f3f4f6; }
.clm-btn-filter { background: #1e293b; color: #fff !important; }
.clm-btn-filter:hover { background: #0f172a; }
.clm-btn-sm { padding: 7px 14px; font-size: 16px;margin: 0; }
.clm-btn-add { background: #2563eb; color: #fff !important; margin-left: auto; }
.clm-btn-add:hover { background: #1d4ed8; }
.clm-btn-edit { background: #f0fdf4; color: #166534 !important; border: 1px solid #86efac; }
.clm-btn-edit:hover { background: #dcfce7; }

/* ── Table ── */
.clm-table-wrap { overflow-x: auto; border-radius: 8px; border: 1px solid #e2e8f0; }
.clm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.clm-table thead tr {
    background: #f1f5f9;
}
.clm-table th {
    padding: 11px 14px;
    text-align: center;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: .5px;
    color: white;
    white-space: nowrap;
    border-bottom: 2px solid #e2e8f0;
    background: #BC3922;
    border-right: 2px solid;
}
.clm-table td {
    padding: 10px 14px;
    border-bottom: 4px solid #f0f4f8;
    vertical-align: middle;
    text-align: center;
    color: black;
    border-right: 1px solid;
    font-size: 13px;
}
.clm-table tbody tr:last-child td { border-bottom: none; }
.clm-table tbody tr.clm-row:hover td { filter: brightness(0.97); }

/* Warning row override */
.clm-table tbody tr.clm-row-warn td { background: #fff7ed !important; }

/* Sales name badge (color synced with admin) */
.clm-sales-tag {
    display: inline-block;
    padding: 4px 10px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    background: white;
}

/* ── Status badges ── */
.clm-status {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 100;
    white-space: nowrap;
    width: 130px;
}
.clm-st-consulting {
    background: green;
    color: white;
    font-weight: 100;
}
.clm-st-not_poten {
    background: #9f0808;
    color: white;
    font-weight: 100;
}
.clm-st-cancelled {
    background: black;
    color: white;
}
.clm-st-quoting {
    background: blue;
    color: white;
}

/* ── Source badges ── */
.clm-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.clm-src-fb    { background: #1877f2; color: #fff; }
.clm-src-zalo  { background: #0068ff; color: #fff; }
.clm-src-other { background: #6b7280; color: #fff; }

/* ── Cells ── */
.clm-td-need { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clm-td-phone { white-space: nowrap; font-family: monospace; font-size: 13px; }
.clm-td-date  { white-space: nowrap; color: #475569; }
.clm-empty    { text-align: center; color: #9ca3af; padding: 32px !important; }
.clm-ok       { color: #cbd5e1; }
.clm-warn-badge   { color: #d97706; font-size: 11px; font-weight: 700; }
.clm-expl-text    { color: #374151; font-style: italic; }
.clm-expl-missing { color: #d97706; }

/* ── Pagination ── */
.clm-pagination { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 16px; }
.clm-page-btn {
    display: inline-block; padding: 6px 12px; border: 1px solid #d1d5db;
    border-radius: 5px; font-size: 13px; color: #374151 !important;
    text-decoration: none; background: #fff;
}
.clm-page-btn:hover { background: #f3f4f6; }
.clm-page-btn.active { background: #2563eb; color: #fff !important; border-color: #2563eb; font-weight: 700; }

/* ── Footer ── */
.clm-list-footer { margin-top: 12px; font-size: 13px; color: #6b7280; }

/* ── Form ── */
.clm-form-wrap {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 28px 32px;
    max-width: 800px;
}
.clm-form-title {
    font-size: 20px; font-weight: 700; margin: 0 0 24px;
    padding-bottom: 12px; border-bottom: 2px solid #f3f4f6;
}
.clm-field-group { margin-bottom: 18px; flex: 1; }
.clm-field-row { display: flex; gap: 20px; }
.clm-field-row .clm-field-group { flex: 1; }
.clm-label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: #374151; }
.clm-req { color: #ef4444; }
.clm-input, .clm-select, .clm-textarea {
    width: 100%; padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 6px;
    font-size: 14px; font-family: inherit; color: #111827; background: #fff;
    box-sizing: border-box; transition: border-color 0.15s;
}
.clm-input:focus, .clm-select:focus, .clm-textarea:focus {
    outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}
.clm-textarea { resize: vertical; }
.clm-explanation-box {
    background: #fff7ed; border: 1px solid #fbbf24; border-radius: 8px;
    padding: 16px; margin-top: 4px;
}
.clm-hint-warning { color: #d97706; font-size: 12px; margin: 6px 0 0; }
.clm-submit-row {
    display: flex; gap: 12px; align-items: center; margin-top: 24px;
    padding-top: 16px; border-top: 1px solid #f3f4f6;
}

/* ── Login gate ── */
.clm-login-gate {
    padding: 32px; text-align: center; background: #f9fafb;
    border: 1px dashed #d1d5db; border-radius: 8px; color: #6b7280; font-size: 15px;
}
.clm-login-gate a { color: #2563eb; font-weight: 600; }

/* ── Mobile ── */
@media (max-width: 640px) {
    .clm-field-row { flex-direction: column; gap: 0; }
    .clm-form-wrap { padding: 16px; }
    .clm-filter { flex-direction: column; align-items: stretch; }
    .clm-btn-add { margin-left: 0; }
    .clm-fe-stats { gap: 8px; }
    .clm-fe-stat { min-width: 80px; padding: 10px 12px; }
    .clm-fe-stat-num { font-size: 20px; }
}
