/* =====================================================
       PAGE HEADER
    ===================================================== */

.clustering-page {
    padding-bottom: 1rem;
}

.page-icon-badge {
    width: 54px;
    height: 54px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.5rem;
    background: linear-gradient(135deg, #0F766E 0%, #14B8A6 100%);
    box-shadow: 0 10px 22px rgba(15, 118, 110, .28);
    flex-shrink: 0;
}

.page-title {
    font-weight: 800;
    letter-spacing: -.4px;
    color: var(--text-main, #0f172a);
    font-size: 1.45rem;
}

.page-subtitle {
    color: var(--text-muted, #64748b);
    font-size: .88rem;
    max-width: 720px;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: .55rem 1rem;
    border-radius: 12px;
    background: #ECFDF5;
    color: #0F766E;
    border: 1px solid #BBF7D0;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .3px;
}

.meta-chip i {
    font-size: .95rem;
}

/* =====================================================
       KPI CARD
    ===================================================== */

.kpi-card {
    border: 1px solid rgba(226, 232, 240, .9);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 4px 18px rgba(15, 23, 42, .05);
    transition: all .25s ease;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
}

.kpi-card.accent-success::before {
    background: #16A34A;
}

.kpi-card.accent-primary::before {
    background: #6366F1;
}

.kpi-card.accent-warning::before {
    background: #F59E0B;
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 32px rgba(15, 23, 42, .10);
}

.kpi-label {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .8px;
    text-transform: uppercase;
    color: #94A3B8;
}

.kpi-value {
    font-weight: 800;
    font-size: 1.6rem;
    letter-spacing: -.5px;
    color: #0f172a;
}

.kpi-hint {
    font-size: .74rem;
    color: #94A3B8;
    font-weight: 500;
}

.kpi-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

/* =====================================================
       FORM CARD & SECTION CARD
    ===================================================== */

.form-card,
.section-card {
    border: 1px solid rgba(226, 232, 240, .9);
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 18px rgba(15, 23, 42, .05);
}

.form-card-header,
.section-card-header {
    background: #F8FAFC;
    border-bottom: 1px solid #E2E8F0;
    padding: 1rem 1.25rem;
}

.form-card-header h5,
.section-card-header h5 {
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -.3px;
}

/* =====================================================
       BUTTON
    ===================================================== */

.btn-gradient {
    background: linear-gradient(135deg, #0F766E 0%, #14B8A6 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: .88rem;
    padding: .7rem 1.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    box-shadow: 0 8px 20px rgba(15, 118, 110, .28);
    transition: all .2s ease;
}

.btn-gradient:hover {
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 12px 26px rgba(15, 118, 110, .35);
}

.btn-gradient:disabled {
    opacity: .7;
    transform: none;
}

/* =====================================================
       LEGEND ITEM
    ===================================================== */

.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: .75rem;
    border-radius: 12px;
    transition: all .2s ease;
    border: 1px solid transparent;
}

.legend-item:hover {
    background: #F8FAFC;
    border-color: #E2E8F0;
}

.legend-item .legend-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(15, 23, 42, .15);
}

.legend-item .legend-title {
    font-weight: 700;
    color: #0f172a;
    font-size: .88rem;
    letter-spacing: -.2px;
}

.legend-item .legend-sub {
    font-size: .74rem;
    color: #64748B;
    margin-top: 2px;
}

/* =====================================================
       SUMMARY CARD
    ===================================================== */

.cluster-card {
    border: 1px solid rgba(226, 232, 240, .9);
    border-radius: 14px;
    background: #fff;
    padding: 1.1rem 1.25rem;
    transition: all .25s ease;
    position: relative;
    overflow: hidden;
    height: 100%;
    /* penting: agar semua card sama tinggi per baris */
    display: flex;
    flex-direction: column;
}

.cluster-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    background: var(--cluster-color, #16A34A);
}

.cluster-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 26px rgba(15, 23, 42, .08);
}

.cluster-card .cluster-title {
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: -.3px;
}

.cluster-card .cluster-label {
    font-weight: 600;
    font-size: .88rem;
    color: #334155;
    margin-top: 2px;
}

.cluster-card .cluster-category {
    font-size: .74rem;
    color: #94A3B8;
    text-transform: uppercase;
    letter-spacing: .5px;
    font-weight: 600;
    margin-top: 2px;
}

.cluster-card .cluster-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    height: 34px;
    padding: 0 12px;
    border-radius: 10px;
    font-weight: 800;
    font-size: .92rem;
    color: #fff;
}

.cluster-card .sample-title {
    margin-top: auto;
    /* dorong ke bawah dalam flex column */
    padding-top: 1rem;
}

.cluster-card .sample-list {
    flex-grow: 1;
}

.cluster-progress {
    height: 8px;
    border-radius: 999px;
    background: #E2E8F0;
    overflow: hidden;
    margin-top: .75rem;
}

.cluster-progress .progress-bar {
    border-radius: 999px;
}

.cluster-share {
    font-size: .74rem;
    color: #94A3B8;
    margin-top: .35rem;
    font-weight: 500;
}

/* =====================================================
    CLUSTER SUMMARY GRID (3 COLUMNS)
    ===================================================== */

#clusterSummary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

/* Tablet */
@media (max-width: 1199.98px) {
    #clusterSummary {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile */
@media (max-width: 767.98px) {
    #clusterSummary {
        grid-template-columns: 1fr;
    }
}

.sample-title {
    font-size: .74rem;
    font-weight: 700;
    color: #64748B;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin: 1rem 0 .55rem;
}

.sample-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sample-list li {
    position: relative;
    padding: .35rem 0 .35rem 1.25rem;
    font-size: .82rem;
    color: #475569;
    line-height: 1.45;
}

.sample-list li::before {
    content: "";
    position: absolute;
    left: .35rem;
    top: .85rem;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #94A3B8;
}

/* =====================================================
       DARK MODE
    ===================================================== */

body.dark-mode .kpi-card,
body.dark-mode .form-card,
body.dark-mode .section-card,
body.dark-mode .cluster-card {
    background: #1E293B;
    border-color: #334155;
}

body.dark-mode .kpi-value,
body.dark-mode .page-title,
body.dark-mode .form-card-header h5,
body.dark-mode .section-card-header h5,
body.dark-mode .legend-item .legend-title,
body.dark-mode .cluster-card .cluster-title {
    color: #F1F5F9;
}

body.dark-mode .form-card-header,
body.dark-mode .section-card-header {
    background: #0F172A;
    border-bottom-color: #334155;
}

body.dark-mode .legend-item:hover {
    background: #0F172A;
    border-color: #334155;
}

body.dark-mode .legend-item .legend-sub,
body.dark-mode .cluster-card .cluster-label,
body.dark-mode .sample-list li {
    color: #CBD5E1;
}

body.dark-mode .cluster-card .cluster-category,
body.dark-mode .cluster-share,
body.dark-mode .sample-title {
    color: #94A3B8;
}

body.dark-mode .cluster-progress {
    background: #334155;
}

body.dark-mode .form-control,
body.dark-mode .form-select {
    background: #0F172A;
    border-color: #334155;
    color: #F1F5F9;
}

body.dark-mode .form-control:focus,
body.dark-mode .form-select:focus {
    background: #0F172A;
    border-color: #14B8A6;
    color: #F1F5F9;
    box-shadow: 0 0 0 .2rem rgba(20, 184, 166, .25);
}

body.dark-mode .meta-chip {
    background: #052E2B;
    color: #2DD4BF;
    border-color: #0F766E;
}

/* =====================================================
       RESPONSIVE
    ===================================================== */

@media (max-width: 991.98px) {
    #clusterScatter {
        height: 420px !important;
    }
}

@media (max-width: 575.98px) {
    .page-icon-badge {
        width: 46px;
        height: 46px;
        font-size: 1.25rem;
    }

    .page-title {
        font-size: 1.15rem;
    }

    .kpi-value {
        font-size: 1.3rem;
    }

    .btn-gradient {
        width: 100%;
    }

    #clusterScatter {
        height: 340px !important;
    }
}