/* ============================================
   KonX — Clients Page Styles
   ============================================ */

/* ---- Page Content ---- */
.page-content {
    padding: var(--space-8) var(--space-8);
    display: flex;
    flex-direction: column;
    gap: var(--space-8);
}

/* ---- KPI Row ---- */
.cl-kpi-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-6);
}

.cl-kpi-card {
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    padding: var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    animation: fadeInUp 0.35s ease-out both;
}

.cl-kpi-card:nth-child(1) { animation-delay: 0.05s; }
.cl-kpi-card:nth-child(2) { animation-delay: 0.1s; }
.cl-kpi-card:nth-child(3) { animation-delay: 0.15s; }

.cl-kpi-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.cl-kpi-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cl-kpi-label {
    font-size: var(--font-sm);
    color: var(--neutral-500);
    font-weight: var(--weight-medium);
}

.cl-kpi-number {
    font-size: 2rem;
    font-weight: var(--weight-extrabold);
    color: var(--neutral-900);
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.cl-kpi-number-accent {
    color: var(--primary-700);
}

.cl-kpi-amount {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.cl-kpi-currency {
    font-size: var(--font-md);
    font-weight: var(--weight-bold);
    color: var(--neutral-500);
}

.cl-kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-lg);
    flex-shrink: 0;
}

.cl-kpi-icon-blue  { background: #eff6ff; color: #3b82f6; }
.cl-kpi-icon-green { background: #ecfdf5; color: #059669; }
.cl-kpi-icon-red   { background: #fef2f2; color: var(--primary-700); }

.cl-kpi-bottom {
    display: flex;
    align-items: center;
}

.cl-kpi-trend {
    font-size: var(--font-xs);
    font-weight: var(--weight-medium);
    display: flex;
    align-items: center;
    gap: 4px;
}

.cl-trend-up { color: #059669; }
.cl-trend-up i { font-size: 10px; }
.cl-trend-warn { color: #d97706; }
.cl-trend-warn i { font-size: 10px; }

.cl-kpi-avatars {
    display: flex;
    align-items: center;
}

.cl-kpi-avatars img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--white);
    margin-left: -6px;
}

.cl-kpi-avatars img:first-child {
    margin-left: 0;
}

.cl-kpi-more {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--neutral-200);
    color: var(--neutral-600);
    font-size: 9px;
    font-weight: var(--weight-bold);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: -6px;
    border: 2px solid var(--white);
}

/* ---- Table Section ---- */
.cl-table-section {
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    animation: fadeInUp 0.35s ease-out 0.2s both;
    overflow: hidden;
}

.cl-table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-6) var(--space-6) var(--space-5);
}

.cl-table-title {
    font-size: var(--font-xl);
    font-weight: var(--weight-bold);
    color: var(--neutral-900);
    margin-bottom: 4px;
}

.cl-table-subtitle {
    font-size: var(--font-sm);
    color: var(--neutral-500);
}

.cl-table-actions {
    display: flex;
    gap: var(--space-2);
}

/* ---- Table ---- */
.cl-table {
    width: 100%;
    border-collapse: collapse;
}

.cl-table thead th {
    padding: 14px 24px;
    text-align: left;
    font-size: var(--font-xs);
    font-weight: var(--weight-semibold);
    color: var(--neutral-500);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--neutral-50);
    border-top: 1px solid var(--neutral-200);
    border-bottom: 1px solid var(--neutral-200);
    white-space: nowrap;
}

.cl-table tbody tr {
    transition: background var(--transition-fast);
}

.cl-table tbody tr:hover {
    background: var(--neutral-50);
}

.cl-table tbody td {
    padding: 18px 24px;
    vertical-align: middle;
    border-bottom: 1px solid var(--neutral-100);
}

.cl-row.active-row {
    background: #fef2f2;
}

/* Client Cell */
.cl-client-cell {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.cl-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-sm);
    font-weight: var(--weight-bold);
    color: var(--white);
    flex-shrink: 0;
}

.cl-avatar-orange { background: #f59e0b; }
.cl-avatar-brown  { background: #92400e; }
.cl-avatar-teal   { background: #0d9488; }
.cl-avatar-purple { background: #7c3aed; }
.cl-avatar-blue   { background: #3b82f6; }
.cl-avatar-red    { background: var(--primary-700); }

.cl-client-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cl-client-info strong {
    font-size: var(--font-md);
    color: var(--neutral-900);
    font-weight: var(--weight-semibold);
}

.cl-client-info span {
    font-size: var(--font-xs);
    color: var(--neutral-500);
}

/* ICE Cell */
.cl-ice-cell {
    font-size: var(--font-sm);
    color: var(--neutral-700);
    font-family: 'SF Mono', 'Fira Code', monospace;
    letter-spacing: 0.02em;
}

/* Badge */
.cl-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border-radius: var(--border-radius-full);
    font-size: var(--font-xs);
    font-weight: var(--weight-semibold);
    white-space: nowrap;
}

.cl-badge i { font-size: 7px; }

.cl-badge-valid      { background: #ecfdf5; color: #059669; }
.cl-badge-unverified { background: #fef3c7; color: #d97706; }
.cl-badge-invalid    { background: #fef2f2; color: #dc2626; }

/* Encours Cell */
.cl-encours-cell {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.cl-encours-cell strong {
    font-size: var(--font-md);
    font-weight: var(--weight-bold);
    color: var(--neutral-900);
}

.cl-encours-cell span {
    font-size: var(--font-xs);
    color: var(--neutral-400);
}

/* Actions Cell */
.cl-actions-cell {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.cl-btn-facturer {
    gap: 6px;
    font-size: var(--font-xs) !important;
    padding: 7px 14px !important;
    white-space: nowrap;
}

.cl-btn-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--neutral-100);
    border: none;
    color: var(--neutral-500);
    font-size: var(--font-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.cl-btn-icon:hover {
    background: var(--neutral-200);
    color: var(--neutral-800);
}

.cl-btn-view:hover {
    background: #dbeafe;
    color: #2563eb;
}

/* ---- Pagination ---- */
.cl-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-top: 1px solid var(--neutral-100);
}

.cl-pagination-info {
    font-size: var(--font-sm);
    color: var(--neutral-500);
}

.cl-pagination-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.cl-page-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-sm);
    font-weight: var(--weight-medium);
    background: none;
    border: 1px solid var(--neutral-200);
    color: var(--neutral-600);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.cl-page-btn:hover:not(:disabled):not(.cl-page-active) {
    background: var(--neutral-50);
    border-color: var(--neutral-300);
}

.cl-page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.cl-page-active {
    background: var(--primary-700) !important;
    color: var(--white) !important;
    border-color: var(--primary-700) !important;
}

.cl-page-dots {
    font-size: var(--font-sm);
    color: var(--neutral-400);
    padding: 0 4px;
}

/* ============================================
   PROFILE PANEL (Right Sidebar)
   ============================================ */
.cl-profile-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    height: 100vh;
    background: var(--white);
    box-shadow: -4px 0 30px rgba(0, 0, 0, 0.12);
    z-index: 900;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.cl-profile-panel.open {
    transform: translateX(0);
}

.cl-profile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--neutral-100);
    flex-shrink: 0;
}

.cl-profile-title {
    font-size: var(--font-lg);
    font-weight: var(--weight-bold);
    color: var(--neutral-900);
}

.cl-profile-close {
    width: 36px;
    height: 36px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--neutral-500);
    font-size: var(--font-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.cl-profile-close:hover {
    background: var(--neutral-100);
    color: var(--neutral-800);
}

.cl-profile-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
}

/* Identity */
.cl-profile-identity {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding-bottom: var(--space-5);
    border-bottom: 1px solid var(--neutral-100);
}

.cl-profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    background: var(--primary-100);
    color: var(--primary-700);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: var(--weight-extrabold);
    margin-bottom: 4px;
}

.cl-profile-name {
    font-size: var(--font-xl);
    font-weight: var(--weight-bold);
    color: var(--neutral-900);
}

.cl-profile-since {
    font-size: var(--font-xs);
    color: var(--neutral-500);
}

.cl-profile-ice-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    background: #ecfdf5;
    color: #059669;
    border-radius: var(--border-radius-full);
    font-size: var(--font-xs);
    font-weight: var(--weight-bold);
    margin-top: 4px;
}

.cl-profile-ice-badge i {
    font-size: var(--font-sm);
}

/* Profile KPIs */
.cl-profile-kpis {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
}

.cl-profile-kpi {
    padding: 16px;
    background: var(--neutral-50);
    border-radius: 12px;
    text-align: center;
    border: 1px solid var(--neutral-200);
}

.cl-profile-kpi-accent {
    background: #fef2f2;
    border-color: #fecaca;
}

.cl-profile-kpi-label {
    display: block;
    font-size: 10px;
    font-weight: var(--weight-semibold);
    color: var(--neutral-500);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}

.cl-profile-kpi-value {
    display: block;
    font-size: var(--font-xl);
    font-weight: var(--weight-extrabold);
    color: var(--neutral-900);
    letter-spacing: -0.02em;
}

.cl-profile-kpi-accent .cl-profile-kpi-value {
    color: var(--primary-700);
}

.cl-profile-kpi-unit {
    display: block;
    font-size: var(--font-xs);
    color: var(--neutral-500);
    font-weight: var(--weight-medium);
    margin-top: 3px;
}

/* Profile Sections */
.cl-profile-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.cl-profile-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cl-profile-section-title {
    font-size: var(--font-xs);
    font-weight: var(--weight-extrabold);
    color: var(--neutral-500);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.cl-profile-see-all {
    font-size: var(--font-xs);
    color: var(--primary-600);
    font-weight: var(--weight-semibold);
    text-decoration: none;
}

.cl-profile-see-all:hover {
    text-decoration: underline;
}

.cl-profile-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--neutral-100);
    font-size: var(--font-sm);
}

.cl-profile-info-row:last-child {
    border-bottom: none;
}

.cl-profile-info-row span {
    color: var(--neutral-500);
}

.cl-profile-info-row strong {
    color: var(--neutral-900);
    font-weight: var(--weight-semibold);
    text-align: right;
    max-width: 180px;
}

/* History Items */
.cl-history-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 14px;
    background: var(--neutral-50);
    border-radius: 12px;
}

.cl-history-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-sm);
}

.cl-history-icon-green  { background: #ecfdf5; color: #059669; }
.cl-history-icon-orange { background: #fef3c7; color: #d97706; }

.cl-history-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.cl-history-info strong {
    font-size: var(--font-sm);
    color: var(--neutral-900);
    font-weight: var(--weight-semibold);
}

.cl-history-status {
    font-size: var(--font-xs);
    font-weight: var(--weight-medium);
    display: flex;
    align-items: center;
    gap: 5px;
}

.cl-history-status i { font-size: 6px; }
.cl-status-paid    { color: #059669; }
.cl-status-pending { color: #d97706; }

.cl-history-amount {
    font-size: var(--font-sm);
    font-weight: var(--weight-bold);
    color: var(--neutral-900);
    white-space: nowrap;
}

/* Profile Footer */
.cl-profile-footer {
    padding: var(--space-5) var(--space-6);
    border-top: 1px solid var(--neutral-100);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    flex-shrink: 0;
}

.cl-btn-profile-invoice {
    width: 100%;
    padding: 14px;
    background: var(--primary-700);
    color: var(--white);
    font-size: var(--font-md);
    font-weight: var(--weight-semibold);
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    box-shadow: 0 2px 8px rgba(90, 10, 10, 0.25);
    transition: all var(--transition-fast);
}

.cl-btn-profile-invoice:hover {
    background: var(--primary-800);
    box-shadow: 0 4px 12px rgba(90, 10, 10, 0.35);
    transform: translateY(-1px);
}

.cl-btn-profile-releve {
    width: 100%;
    padding: 12px;
    background: var(--white);
    color: var(--neutral-700);
    font-size: var(--font-md);
    font-weight: var(--weight-semibold);
    border-radius: var(--border-radius-md);
    border: 1px solid var(--neutral-300);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    transition: all var(--transition-fast);
}

.cl-btn-profile-releve:hover {
    background: var(--neutral-50);
    border-color: var(--neutral-400);
}

/* ---- Profile Overlay ---- */
.cl-profile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(2px);
    z-index: 899;
    display: none;
    animation: fadeIn 0.2s ease-out;
}

.cl-profile-overlay.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1200px) {
    .cl-kpi-row {
        gap: var(--space-4);
    }
}

@media (max-width: 1024px) {
    .cl-profile-panel {
        width: 340px;
    }
}

@media (max-width: 768px) {
    .cl-kpi-row {
        grid-template-columns: 1fr;
    }

    .cl-table-header {
        flex-direction: column;
        gap: var(--space-3);
        align-items: flex-start;
    }

    .cl-table {
        display: block;
        overflow-x: auto;
    }

    .cl-pagination {
        flex-direction: column;
        gap: var(--space-3);
    }

    .cl-profile-panel {
        width: 100%;
    }
}

/* ── KPI Cards Hover ─────────────────── */
.cl-kpi-card {
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.cl-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.cl-kpi-card:active {
    transform: scale(0.98);
}

/* ── Client Name Clickable ───────────── */
.cl-client-info {
    cursor: pointer;
}

.cl-client-info:hover strong {
    color: #dc2626;
    transition: color 0.2s;
}

/* ── Sidebar Backdrop ────────────────── */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(2px);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.sidebar-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

/* ---- RTL ---- */
html[dir="rtl"] .cl-table thead th,
html[dir="rtl"] .cl-table tbody td {
    text-align: right !important;
}

html[dir="rtl"] .cl-client-cell,
html[dir="rtl"] .cl-actions-cell,
html[dir="rtl"] .cl-history-item,
html[dir="rtl"] .cl-profile-ice-badge,
html[dir="rtl"] .cl-kpi-trend {
    flex-direction: row-reverse;
}

html[dir="rtl"] .cl-client-cell {
    flex-direction: row;
    direction: rtl;
    justify-content: flex-start;
}

html[dir="rtl"] .cl-client-info {
    text-align: right;
}

html[dir="rtl"] .cl-profile-info-row strong {
    text-align: left;
}

/* RTL pagination arrows */
html[dir="rtl"] .cl-page-prev i,
html[dir="rtl"] .cl-page-next i {
    transform: rotate(180deg);
}

/* RTL profile panel position */
html[dir="rtl"] .cl-profile-panel {
    right: auto;
    left: 0;
    transform: translateX(-100%);
    box-shadow: 4px 0 30px rgba(0, 0, 0, 0.12);
}

html[dir="rtl"] .cl-profile-panel.open {
    transform: translateX(0);
}

/* RTL KPI avatars margin */
html[dir="rtl"] .cl-kpi-avatars img {
    margin-left: 0;
    margin-right: -6px;
}

html[dir="rtl"] .cl-kpi-avatars img:first-child {
    margin-right: 0;
}

html[dir="rtl"] .cl-kpi-more {
    margin-left: 0;
    margin-right: -6px;
}

/* RTL dropdown position */
html[dir="rtl"] .cl-action-dropdown {
    right: auto;
    left: 0;
}
