/* ============================================
   CardKeeper — Custom Styles
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    --ck-primary: #2563eb;
    --ck-primary-hover: #1d4ed8;
    --ck-primary-light: #eff6ff;
    --ck-primary-50: rgba(37, 99, 235, 0.08);
    --ck-success: #059669;
    --ck-success-light: #ecfdf5;
    --ck-warning: #d97706;
    --ck-warning-light: #fffbeb;
    --ck-danger: #dc2626;
    --ck-danger-light: #fef2f2;
    --ck-dark: #0f172a;
    --ck-gray-50: #f8fafc;
    --ck-gray-100: #f1f5f9;
    --ck-gray-200: #e2e8f0;
    --ck-gray-300: #cbd5e1;
    --ck-gray-400: #94a3b8;
    --ck-gray-500: #64748b;
    --ck-gray-600: #475569;
    --ck-gray-700: #334155;
    --ck-gray-800: #1e293b;
    --ck-gray-900: #0f172a;
    --ck-sidebar-width: 260px;
    --ck-topbar-height: 64px;
    --ck-radius: 12px;
    --ck-radius-sm: 8px;
    --ck-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --ck-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --ck-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --ck-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --ck-transition: all 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    background: var(--ck-gray-50);
    color: var(--ck-gray-800);
    font-size: 0.9rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ---- Sidebar ---- */
.ck-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--ck-sidebar-width);
    background: var(--ck-dark);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.ck-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ck-sidebar-brand-icon {
    width: 38px;
    height: 38px;
    background: var(--ck-primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #fff;
    flex-shrink: 0;
}

.ck-sidebar-brand h1 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    letter-spacing: -0.3px;
}

.ck-sidebar-brand small {
    font-size: 0.7rem;
    color: var(--ck-gray-400);
    font-weight: 400;
    display: block;
    margin-top: 1px;
}

.ck-sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.ck-sidebar-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--ck-gray-500);
    padding: 12px 12px 6px;
}

.ck-sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--ck-radius-sm);
    color: var(--ck-gray-400);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--ck-transition);
    margin-bottom: 2px;
}

.ck-sidebar-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.ck-sidebar-link.active {
    background: var(--ck-primary);
    color: #fff;
}

.ck-sidebar-link i {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.ck-sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.ck-sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--ck-radius-sm);
    color: var(--ck-gray-300);
    text-decoration: none;
    transition: var(--ck-transition);
}

.ck-sidebar-user:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.ck-sidebar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--ck-gray-700);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--ck-gray-300);
    flex-shrink: 0;
}

.ck-sidebar-user-name {
    font-size: 0.82rem;
    font-weight: 600;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Content Area ---- */
.ck-content {
    margin-left: var(--ck-sidebar-width);
    min-height: 100vh;
}

.ck-topbar {
    height: var(--ck-topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--ck-gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.ck-topbar-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--ck-gray-900);
    letter-spacing: -0.3px;
}

.ck-topbar-breadcrumb {
    font-size: 0.8rem;
    color: var(--ck-gray-400);
}

.ck-topbar-breadcrumb a {
    color: var(--ck-gray-500);
    text-decoration: none;
}

.ck-topbar-breadcrumb a:hover {
    color: var(--ck-primary);
}

.ck-mobile-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--ck-gray-700);
    cursor: pointer;
    padding: 4px;
}

.ck-main {
    padding: 28px 32px;
}

/* ---- Cards ---- */
.ck-card {
    background: #fff;
    border-radius: var(--ck-radius);
    border: 1px solid var(--ck-gray-200);
    box-shadow: var(--ck-shadow-sm);
    transition: var(--ck-transition);
}

.ck-card-hover:hover {
    box-shadow: var(--ck-shadow-md);
    border-color: var(--ck-gray-300);
}

.ck-card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--ck-gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.ck-card-header h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--ck-gray-900);
    margin: 0;
}

.ck-card-body {
    padding: 24px;
}

.ck-card-body-flush {
    padding: 0;
}

/* ---- Stat Cards ---- */
.ck-stat {
    padding: 24px;
}

.ck-stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-bottom: 16px;
}

.ck-stat-icon.blue { background: var(--ck-primary-light); color: var(--ck-primary); }
.ck-stat-icon.green { background: var(--ck-success-light); color: var(--ck-success); }
.ck-stat-icon.amber { background: var(--ck-warning-light); color: var(--ck-warning); }
.ck-stat-icon.red { background: var(--ck-danger-light); color: var(--ck-danger); }

.ck-stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--ck-gray-900);
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.ck-stat-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--ck-gray-500);
    margin-top: 4px;
}

/* ---- Tables ---- */
.ck-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.ck-table thead th {
    padding: 12px 16px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ck-gray-500);
    background: var(--ck-gray-50);
    border-bottom: 1px solid var(--ck-gray-200);
    white-space: nowrap;
}

.ck-table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--ck-gray-100);
    font-size: 0.85rem;
    vertical-align: middle;
}

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

.ck-table tbody tr:hover {
    background: var(--ck-gray-50);
}

.ck-table .text-end {
    text-align: right;
}

.ck-table .text-center {
    text-align: center;
}

/* ---- Badges ---- */
.ck-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.ck-badge-blue { background: var(--ck-primary-light); color: var(--ck-primary); }
.ck-badge-green { background: var(--ck-success-light); color: var(--ck-success); }
.ck-badge-amber { background: var(--ck-warning-light); color: var(--ck-warning); }
.ck-badge-red { background: var(--ck-danger-light); color: var(--ck-danger); }
.ck-badge-gray { background: var(--ck-gray-100); color: var(--ck-gray-600); }

/* ---- Buttons ---- */
.ck-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--ck-radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: var(--ck-transition);
    white-space: nowrap;
    font-family: inherit;
}

.ck-btn-primary {
    background: var(--ck-primary);
    color: #fff;
}

.ck-btn-primary:hover {
    background: var(--ck-primary-hover);
    color: #fff;
}

.ck-btn-light {
    background: var(--ck-gray-100);
    color: var(--ck-gray-700);
}

.ck-btn-light:hover {
    background: var(--ck-gray-200);
    color: var(--ck-gray-800);
}

.ck-btn-danger {
    background: var(--ck-danger-light);
    color: var(--ck-danger);
}

.ck-btn-danger:hover {
    background: #fecaca;
    color: var(--ck-danger);
}

.ck-btn-success {
    background: var(--ck-success-light);
    color: var(--ck-success);
}

.ck-btn-success:hover {
    background: #d1fae5;
    color: var(--ck-success);
}

.ck-btn-sm {
    padding: 6px 12px;
    font-size: 0.76rem;
}

.ck-btn-icon {
    padding: 8px;
    width: 34px;
    height: 34px;
    justify-content: center;
}

.ck-btn-icon.ck-btn-sm {
    width: 30px;
    height: 30px;
    padding: 5px;
}

/* ---- Forms ---- */
.ck-form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ck-gray-700);
    margin-bottom: 6px;
}

.ck-form-control {
    border: 1px solid var(--ck-gray-300);
    border-radius: var(--ck-radius-sm);
    padding: 10px 14px;
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--ck-gray-800);
    transition: var(--ck-transition);
    width: 100%;
    background: #fff;
}

.ck-form-control:focus {
    border-color: var(--ck-primary);
    box-shadow: 0 0 0 3px var(--ck-primary-50);
    outline: none;
}

.ck-form-control.is-invalid {
    border-color: var(--ck-danger);
}

.ck-form-hint {
    font-size: 0.74rem;
    color: var(--ck-gray-400);
    margin-top: 4px;
}

select.ck-form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ---- Alerts / Toast ---- */
.ck-alert {
    padding: 14px 20px;
    border-radius: var(--ck-radius-sm);
    font-size: 0.84rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    animation: ckSlideDown 0.3s ease;
}

.ck-alert-success {
    background: var(--ck-success-light);
    color: var(--ck-success);
    border: 1px solid #a7f3d0;
}

.ck-alert-danger {
    background: var(--ck-danger-light);
    color: var(--ck-danger);
    border: 1px solid #fecaca;
}

@keyframes ckSlideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- Empty State ---- */
.ck-empty {
    text-align: center;
    padding: 48px 24px;
}

.ck-empty-icon {
    font-size: 2.5rem;
    color: var(--ck-gray-300);
    margin-bottom: 12px;
}

.ck-empty-text {
    font-size: 0.9rem;
    color: var(--ck-gray-500);
    margin-bottom: 16px;
}

/* ---- Autocomplete ---- */
.ck-autocomplete {
    position: relative;
}

.ck-autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--ck-gray-200);
    border-radius: var(--ck-radius-sm);
    box-shadow: var(--ck-shadow-lg);
    z-index: 1050;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.ck-autocomplete-list.show {
    display: block;
}

.ck-autocomplete-item {
    padding: 10px 14px;
    font-size: 0.84rem;
    cursor: pointer;
    transition: var(--ck-transition);
}

.ck-autocomplete-item:hover,
.ck-autocomplete-item.active {
    background: var(--ck-primary-light);
    color: var(--ck-primary);
}

/* ---- Money ---- */
.ck-money {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.3px;
}

.ck-money-lg {
    font-size: 1.5rem;
}

/* ---- Page Header ---- */
.ck-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 12px;
    flex-wrap: wrap;
}

.ck-page-header h1 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--ck-gray-900);
    letter-spacing: -0.5px;
    margin: 0;
}

.ck-page-header p {
    font-size: 0.84rem;
    color: var(--ck-gray-500);
    margin: 2px 0 0;
}

/* ---- Misc ---- */
.ck-divider {
    height: 1px;
    background: var(--ck-gray-200);
    margin: 20px 0;
}

.ck-text-muted {
    color: var(--ck-gray-500);
}

.ck-truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.ck-debtor-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.82rem;
    flex-shrink: 0;
}

.ck-debtor-colors-0 { background: #dbeafe; color: #1d4ed8; }
.ck-debtor-colors-1 { background: #dcfce7; color: #15803d; }
.ck-debtor-colors-2 { background: #fef3c7; color: #b45309; }
.ck-debtor-colors-3 { background: #fce7f3; color: #be185d; }
.ck-debtor-colors-4 { background: #e0e7ff; color: #4338ca; }
.ck-debtor-colors-5 { background: #f0fdf4; color: #166534; }
.ck-debtor-colors-6 { background: #fef2f2; color: #991b1b; }
.ck-debtor-colors-7 { background: #f0f9ff; color: #075985; }

/* ---- Filter bar ---- */
.ck-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.ck-filters select.ck-form-control {
    width: auto;
    min-width: 180px;
    padding: 8px 36px 8px 12px;
    font-size: 0.8rem;
}

/* ---- Overlay for mobile ---- */
.ck-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1035;
}

/* ---- Responsive ---- */
@media (max-width: 991.98px) {
    .ck-sidebar {
        transform: translateX(-100%);
    }

    .ck-sidebar.open {
        transform: translateX(0);
    }

    .ck-sidebar-overlay.open {
        display: block;
    }

    .ck-content {
        margin-left: 0;
    }

    .ck-mobile-toggle {
        display: block;
    }

    .ck-topbar {
        padding: 0 16px;
    }

    .ck-main {
        padding: 20px 16px;
    }

    .ck-page-header h1 {
        font-size: 1.2rem;
    }

    .ck-stat-value {
        font-size: 1.3rem;
    }

    .ck-table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .ck-truncate {
        max-width: 130px;
    }
}

@media (max-width: 575.98px) {
    .ck-page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .ck-filters {
        width: 100%;
    }

    .ck-filters select.ck-form-control {
        width: 100%;
        min-width: unset;
    }
}

/* ---- Print ---- */
@media print {
    .ck-sidebar, .ck-topbar, .ck-mobile-toggle, .ck-sidebar-overlay {
        display: none !important;
    }
    .ck-content {
        margin-left: 0 !important;
    }
}
