/* ===== CLIENTES.CSS ===== */
:root {
    --cl-primary: var(--wk-primary);
    --cl-surface: rgba(255,255,255,0.88);
    --cl-border: rgba(255,255,255,0.55);
    --cl-text: #1a1a1a;
    --cl-text-2: #46443d;
    --cl-text-3: #6b6f85; /* ~5:1 sobre blanco (AA) */
    /* backward compat */
    --dash-text: #1a1a1a;
    --dash-text-soft: #6b6f85;
    --dash-card: rgba(255,255,255,0.88);
    --dash-border: rgba(255,255,255,0.4);
    --dash-bg: rgba(250,249,244,0.5);
}
.dark {
    --cl-primary: var(--wk-primary);
    --cl-surface: rgba(28,28,28,0.94);
    --cl-border: rgba(255,255,255,0.10);
    --cl-text: #ededed;
    --cl-text-2: #cfcdc7;
    --cl-text-3: #868aa3; /* ~5:1 sobre superficie oscura (AA) */
    --dash-text: #ededed;
    --dash-text-soft: #868aa3;
    --dash-card: rgba(28,28,28,0.94);
    --dash-border: rgba(255,255,255,0.08);
    --dash-bg: rgba(16,16,16,0.4);
}

.cl-container { max-width: 1400px; margin: 0 auto; padding: 4px 0 24px; }

/* Header */
.cl-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.cl-title {
    font-size: 28px; font-weight: 900; color: var(--cl-text);
    letter-spacing: -.02em; margin: 0 0 4px; font-family: 'Manrope', sans-serif;
}
.cl-subtitle { font-size: 13px; color: var(--cl-text-3); margin: 0; }

/* KPIs */
.cl-kpi-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; margin-bottom: 18px; }
.cl-kpi {
    background: var(--cl-surface);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--cl-border);
    border-radius: 1.5rem; padding: 18px 20px;
    box-shadow: 0 4px 24px rgba(var(--wk-primary-rgb),0.05);
}
.cl-kpi-label {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .08em; color: var(--cl-text-3); margin-bottom: 8px;
}
.cl-kpi-value {
    font-size: 28px; font-weight: 900; color: var(--cl-text);
    font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1;
    font-family: 'Manrope', sans-serif;
}
.cl-kpi-blue { color: var(--wk-text); }
.dark .cl-kpi-blue { color: var(--wk-text); }

/* Search */
.cl-search-bar { position: relative; margin-bottom: 14px; }
.cl-search-icon {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: var(--cl-text-3); pointer-events: none; font-size: 20px;
    font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 24;
}
.cl-search-input {
    width: 100%; padding: 11px 46px 11px 44px;
    border-radius: 14px; border: 1px solid var(--cl-border);
    background: var(--cl-surface); backdrop-filter: blur(16px);
    font-size: 13.5px; color: var(--cl-text); font-family: inherit;
    outline: none; transition: border-color .15s, box-shadow .15s;
    box-shadow: 0 2px 8px rgba(var(--wk-primary-rgb),0.04);
}
.cl-search-input::placeholder { color: var(--cl-text-3); }
.cl-search-input:focus { border-color: var(--wk-text); box-shadow: 0 0 0 3px rgba(var(--wk-primary-rgb),0.1); }
/* oculta la X nativa del type=search para usar la nuestra */
.cl-search-input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.cl-search-clear {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    width: 40px; height: 40px; border-radius: 10px;
    background: none; border: none; color: var(--cl-text-3); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: color .15s, background .15s; touch-action: manipulation;
}
.cl-search-clear:hover { color: #ba1a1a; background: rgba(186,26,26,0.08); }
.cl-search-clear .material-symbols-outlined { font-size: 18px; font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 24; }

/* Table card */
.cl-table-card {
    background: var(--cl-surface);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--cl-border);
    border-radius: 1.5rem;
    box-shadow: 0 4px 24px rgba(var(--wk-primary-rgb),0.05);
    overflow: hidden;
}
.cl-table-info {
    font-size: 12px; color: var(--cl-text-3); padding: 11px 20px;
    border-bottom: 1px solid rgba(70,68,61,0.07);
}
.dark .cl-table-info { border-bottom-color: rgba(255,255,255,0.05); }
.cl-table-info strong { color: var(--cl-text); }
.cl-table-wrap { overflow-x: auto; }
.cl-table { width: 100%; border-collapse: collapse; }
.cl-table thead { border-bottom: 1px solid rgba(70,68,61,0.07); }
.dark .cl-table thead { border-bottom-color: rgba(255,255,255,0.05); }
.cl-table th {
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
    color: var(--cl-text-3); padding: 11px 16px; text-align: left; white-space: nowrap;
}
.cl-table td {
    padding: 12px 16px; border-bottom: 1px solid rgba(70,68,61,0.05);
    font-size: 13px; color: var(--cl-text); vertical-align: middle;
}
.dark .cl-table td { border-bottom-color: rgba(255,255,255,0.04); }
.cl-table tr:last-child td { border-bottom: none; }
.cl-table tbody tr:hover td { background: rgba(var(--wk-primary-rgb),0.025); }
.dark .cl-table tbody tr:hover td { background: rgba(255,255,255,0.03); }
.cl-td-nombre { font-weight: 600; }
.cl-td-doc { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.cl-td-mono { font-family: 'Courier New', monospace; font-size: 12px; color: var(--cl-text-3); }
.cl-td-email { font-size: 12px; color: var(--cl-text-3); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl-td-actions { width: 96px; white-space: nowrap; text-align: right; }

/* Doc type badges */
.cl-tipo-badge {
    display: inline-flex; align-items: center; font-size: 10px; font-weight: 700;
    padding: 2px 8px; border-radius: 20px; flex-shrink: 0;
}
.cl-badge-nit { background: rgba(124,58,237,0.08); color: #7c3aed; border: 1px solid rgba(124,58,237,0.15); }
.cl-badge-dui { background: rgba(var(--wk-primary-rgb),0.08); color: var(--wk-text); border: 1px solid rgba(var(--wk-primary-rgb),0.15); }
.cl-badge-otro { background: rgba(70,68,61,0.07); color: var(--cl-text-3); border: 1px solid rgba(70,68,61,0.10); }
.dark .cl-badge-nit { background: rgba(167,139,250,0.12); color: #a78bfa; border-color: rgba(167,139,250,0.2); }
.dark .cl-badge-dui { background: rgba(var(--wk-primary-rgb),0.12); color: var(--wk-text); border-color: rgba(var(--wk-primary-rgb),0.2); }
.dark .cl-badge-otro { background: rgba(255,255,255,0.06); color: var(--cl-text-3); border-color: rgba(255,255,255,0.08); }

/* Icon buttons */
.cl-btn-icon {
    width: 40px; height: 40px; border: none; border-radius: 10px; cursor: pointer;
    background: transparent; display: inline-flex; align-items: center; justify-content: center;
    transition: background .14s, color .14s; touch-action: manipulation;
}
.cl-btn-icon .material-symbols-outlined { font-size: 19px; font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 24; }
.cl-btn-icon.edit { color: var(--cl-text-3); }
.cl-btn-icon.edit:hover { background: rgba(var(--wk-primary-rgb),0.08); color: var(--wk-text); }
.cl-btn-icon.delete { color: var(--cl-text-3); }
.cl-btn-icon.delete:hover { background: rgba(186,26,26,0.08); color: #ba1a1a; }
.dark .cl-btn-icon.edit:hover { background: rgba(var(--wk-primary-rgb),0.12); color: var(--wk-text); }
.dark .cl-btn-icon.delete:hover { background: rgba(255,180,171,0.12); color: #ffb4ab; }

/* Empty */
.cl-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 56px 20px; color: var(--cl-text-3); }
.cl-empty-icon .material-symbols-outlined { font-size: 44px; font-variation-settings: 'FILL' 0, 'wght' 200, 'GRAD' 0, 'opsz' 48; opacity: .5; }
.cl-empty-text { font-size: 15px; font-weight: 700; color: var(--cl-text-2); }
.cl-empty-sub { font-size: 13px; opacity: .75; }

/* Spinner */
.cl-spinner { width: 32px; height: 32px; border-radius: 50%; border: 2.5px solid rgba(var(--wk-primary-rgb),0.12); border-top-color: var(--wk-text); animation: cl-spin .75s linear infinite; }
@keyframes cl-spin { to { transform: rotate(360deg); } }

/* Modal */
.cl-modal {
    background: var(--cl-surface); backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--cl-border); border-radius: 1.5rem;
    width: 100%; max-width: 560px; max-height: 90vh;
    display: flex; flex-direction: column;
    box-shadow: 0 24px 64px rgba(0,0,0,0.18);
    animation: cl-popIn .2s cubic-bezier(.34,1.56,.64,1);
}
@keyframes cl-popIn { from { transform: scale(.93) translateY(14px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
.cl-modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px 24px 16px; border-bottom: 1px solid rgba(70,68,61,0.07); flex-shrink: 0;
}
.dark .cl-modal-header { border-bottom-color: rgba(255,255,255,0.06); }
.cl-modal-title {
    display: flex; align-items: center; gap: 8px;
    font-size: 16px; font-weight: 800; color: var(--cl-text); font-family: 'Manrope', sans-serif;
}
.cl-modal-title .material-symbols-outlined { font-size: 20px; color: var(--wk-text); font-variation-settings: 'FILL' 1, 'wght' 300, 'GRAD' 0, 'opsz' 24; }
.cl-modal-close {
    width: 40px; height: 40px; border: none; border-radius: 10px; background: transparent;
    cursor: pointer; color: var(--cl-text-3); display: flex; align-items: center; justify-content: center;
    transition: background .14s; touch-action: manipulation;
}
.cl-modal-close .material-symbols-outlined { font-size: 20px; font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 24; }
.cl-modal-close:hover { background: rgba(186,26,26,0.08); color: #ba1a1a; }
.cl-modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 12px; }
.cl-modal-footer { display: flex; gap: 8px; padding: 16px 24px 20px; border-top: 1px solid rgba(70,68,61,0.07); flex-shrink: 0; }
.dark .cl-modal-footer { border-top-color: rgba(255,255,255,0.06); }

/* Error box */
.cl-error-box {
    display: flex; align-items: flex-start; gap: 8px;
    background: rgba(186,26,26,0.06); border: 1px solid rgba(186,26,26,0.15);
    border-radius: 11px; padding: 10px 14px; font-size: 13px; color: #ba1a1a; font-weight: 500; line-height: 1.5;
}
.cl-error-box .material-symbols-outlined { font-size: 16px; font-variation-settings: 'FILL' 1, 'wght' 300, 'GRAD' 0, 'opsz' 24; flex-shrink: 0; }
.dark .cl-error-box { background: rgba(147,0,10,0.2); border-color: rgba(255,180,171,0.2); color: #ffb4ab; }

/* Buttons */
.cl-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 40px; padding: 10px 20px; border-radius: 14px; font-size: 13.5px; font-weight: 700;
    cursor: pointer; border: none; font-family: inherit; transition: all .15s; white-space: nowrap;
    touch-action: manipulation;
}
.cl-btn:disabled { opacity: .5; cursor: not-allowed; }
.cl-btn:active:not(:disabled) { transform: scale(.97); }
.cl-btn.primary {
    background: linear-gradient(135deg,var(--wk-primary),var(--wk-primary-strong)); color: var(--wk-on-primary);
    box-shadow: 0 4px 14px rgba(var(--wk-primary-rgb),0.25);
}
.cl-btn.primary:hover:not(:disabled) { box-shadow: 0 6px 20px rgba(var(--wk-primary-rgb),0.35); filter: brightness(1.05); }
.dark .cl-btn.primary { background: linear-gradient(135deg,var(--wk-primary-strong),var(--wk-primary-strong)); box-shadow: 0 4px 14px rgba(var(--wk-primary-rgb),0.35); }
.cl-btn.danger { background: #ba1a1a; color: #fff; box-shadow: 0 4px 12px rgba(186,26,26,0.25); }
.cl-btn.danger:hover { background: #a31515; }
.cl-btn.light {
    background: transparent; color: var(--cl-text-2);
    border: 1px solid var(--cl-border);
}
.cl-btn.light:hover:not(:disabled) { border-color: var(--wk-text); color: var(--wk-text); background: rgba(var(--wk-primary-rgb),0.04); }
.dark .cl-btn.light { border-color: rgba(255,255,255,0.12); }
.dark .cl-btn.light:hover:not(:disabled) { background: rgba(var(--wk-primary-rgb),0.08); border-color: rgba(var(--wk-primary-rgb),0.3); color: var(--wk-text); }
.cl-btn-spinner { width: 13px; height: 13px; border-radius: 50%; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; animation: cl-spin .7s linear infinite; flex-shrink: 0; }

/* Delete confirm text */
.cl-del-text { font-size: 13px; color: var(--cl-text-3); margin-bottom: 20px; line-height: 1.55; }
.cl-del-text strong { color: var(--cl-text); }

/* Focus visible (keyboard nav) — no afecta el clic con mouse */
.cl-btn:focus-visible,
.cl-btn-icon:focus-visible,
.cl-modal-close:focus-visible,
.cl-search-clear:focus-visible {
    outline: 2px solid var(--cl-primary);
    outline-offset: 2px;
}
.cl-table tbody tr:focus-within td { background: rgba(var(--wk-primary-rgb),0.04); }
.dark .cl-table tbody tr:focus-within td { background: rgba(255,255,255,0.04); }

/* Respeta reduce-motion */
@media (prefers-reduced-motion: reduce) {
    .cl-modal { animation: none; }
    .cl-btn:active:not(:disabled) { transform: none; }
    .cl-btn-spinner, .cl-spinner { animation-duration: 1.5s; }
    * { scroll-behavior: auto !important; }
}

/* Responsive */
@media (max-width: 768px) {
    .cl-kpi-grid { grid-template-columns: 1fr 1fr 1fr; }
    .cl-table th:nth-child(5), .cl-table td:nth-child(5),
    .cl-table th:nth-child(6), .cl-table td:nth-child(6) { display: none; }
}
@media (max-width: 520px) {
    .cl-kpi-grid { grid-template-columns: 1fr 1fr; }
    .cl-header { flex-direction: column; align-items: flex-start; }
    .cl-table th:nth-child(3), .cl-table td:nth-child(3),
    .cl-table th:nth-child(4), .cl-table td:nth-child(4) { display: none; }
}
