/* ==========================================
   DESIGN SYSTEM - DASHBOARD & METRICS WIDGETS
   ========================================== */

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-24);
    margin-bottom: var(--space-24);
}

.metric-card {
    position: relative;
    border-radius: var(--radius-16);
    overflow: hidden;
    background: var(--ui-card-bg);
    border: 1px solid var(--ui-border);
    box-shadow: var(--shadow-soft);
    transition: var(--transition-200);
}

.metric-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.metric-card .card-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-24);
}

.metric-label {
    font-size: clamp(0.72rem, 0.7rem + 0.1vw, 0.8rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ui-text);
    margin-bottom: var(--space-8);
}

.metric-value {
    font-size: clamp(1.6rem, 2.2vw, 2.2rem);
    font-weight: 800;
    color: var(--ui-heading);
    margin: 0;
    letter-spacing: -0.03em;
}

.metric-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-14);
    display: grid;
    place-items: center;
    font-size: 1.35rem;
    flex-shrink: 0;
    transition: var(--transition-200);
}

.metric-card:hover .metric-icon {
    transform: scale(1.08);
}

.metric-card-primary .metric-icon { background: var(--ui-primary-light); color: var(--ui-primary); }
.metric-card-success .metric-icon { background: rgba(52, 217, 90, 0.12); color: #1CCF8A; }
.metric-card-danger .metric-icon { background: rgba(239, 68, 68, 0.1); color: #EF4444; }
.metric-card-info .metric-icon { background: rgba(6, 182, 212, 0.1); color: #06B6D4; }
.metric-card-warning .metric-icon { background: rgba(245, 158, 11, 0.12); color: #D97706; }

/* ==========================================
   SALES-STYLE CONTENT SYSTEM
   Bahasa visual ala referensi Sales Dashboard:
   kartu KPI putih + tile ikon warna, panel putih
   berkepala judul + tabel bersih. (Konten saja;
   shell aplikasi tidak diubah.)
   ========================================== */

.dash-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: var(--space-24);
}
.dash-title {
    font-size: clamp(1.25rem, 1.05rem + 0.9vw, 1.5rem);
    font-weight: 800;
    color: var(--ui-heading);
    letter-spacing: -0.02em;
    margin: 0 0 4px 0;
}
.dash-sub {
    color: var(--ui-text);
    font-size: clamp(0.8125rem, 0.78rem + 0.16vw, 0.9rem);
    margin: 0;
}
.dash-greet {
    font-size: clamp(0.95rem, 0.87rem + 0.4vw, 1.1rem);
    margin: 0;
}
.dash-meta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--ui-card-bg);
    border: 1px solid var(--ui-border);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-soft);
    padding: 8px 16px;
    font-size: clamp(0.72rem, 0.7rem + 0.1vw, 0.8rem);
    font-weight: 700;
    color: var(--ui-text);
}
.dash-meta i { color: var(--ui-primary); }

/* --- Kartu KPI (gradien profesional, teks putih) --- */
.kpi-card {
    border: 0;
    border-radius: clamp(14px, 1.1vw, 20px);
    box-shadow: var(--shadow-soft);
    padding: 1rem 1.15rem;
    position: relative;
    overflow: hidden;
    container-type: inline-size;
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.kpi-card::after {
    content: '';
    position: absolute;
    right: -46px;
    top: -46px;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    pointer-events: none;
}
.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}
.kpi-blue { background: linear-gradient(135deg, #1E7CFF 0%, #09C8E8 100%); }
.kpi-indigo { background: linear-gradient(135deg, #8B5CF6 0%, #C084FC 100%); }
.kpi-cyan { background: linear-gradient(135deg, #09C8E8 0%, #22D3EE 100%); }
.kpi-green { background: linear-gradient(135deg, #34D95A 0%, #1CCF8A 100%); }
.kpi-amber { background: linear-gradient(135deg, #F59E0B 0%, #FBBF24 100%); }
.kpi-red { background: linear-gradient(135deg, #dc3545 0%, #ff6b81 100%); }
.kpi-slate { background: linear-gradient(135deg, #334155 0%, #64748B 100%); }
.kpi-pink { background: linear-gradient(135deg, #EC4899 0%, #F472B6 100%); }
.kpi-orange { background: linear-gradient(135deg, #F97316 0%, #FB923C 100%); }
.kpi-orange-dark { background: linear-gradient(135deg, #EF4444 0%, #F97316 100%); }
.kpi-red-dark { background: linear-gradient(135deg, #B91C1C 0%, #7F1D1D 100%); }
.kpi-top {
    display: contents;
}
.kpi-main {
    display: flex;
    align-items: center;
    gap: clamp(8px, 5cqi, 17px);
    position: relative;
    z-index: 1;
}
.kpi-text {
    flex: 1;
    min-width: 0;
}
.kpi-ico {
    width: clamp(34px, 18cqi, 56px);
    height: clamp(34px, 18cqi, 56px);
    border-radius: clamp(10px, 5.5cqi, 18px);
    display: grid;
    place-items: center;
    font-size: clamp(1rem, 0.9rem + 0.7vw, 1.8rem);
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}
.kpi-blue .kpi-ico, .kpi-indigo .kpi-ico, .kpi-cyan .kpi-ico,
.kpi-green .kpi-ico, .kpi-amber .kpi-ico, .kpi-red .kpi-ico,
.kpi-slate .kpi-ico, .kpi-pink .kpi-ico, .kpi-orange .kpi-ico {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}
.kpi-chip {
    position: absolute;
    top: clamp(8px, 5.5cqi, 16px);
    right: clamp(8px, 5.5cqi, 16px);
    z-index: 2;
    font-size: clamp(0.65rem, 0.6rem + 0.25vw, 0.85rem);
    font-weight: 700;
    padding: clamp(4px, 2.5cqi, 7px) clamp(8px, 5.5cqi, 15px);
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    white-space: nowrap;
}
.kpi-value {
    font-size: clamp(1.75rem, 1.5rem + 1vw, 2.35rem);
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.03em;
    line-height: 1.05;
    margin: 0 0 2px 0;
    padding-right: clamp(64px, 38cqi, 104px);
    white-space: nowrap;
    position: relative;
    z-index: 1;
}
.kpi-label {
    font-size: clamp(0.8rem, 0.75rem + 0.25vw, 0.92rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.15;
    color: rgba(255, 255, 255, 0.95);
    margin: 0;
    position: relative;
    z-index: 1;
}
.kpi-sub {
    font-size: clamp(0.88rem, 0.83rem + 0.25vw, 1rem);
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    margin: auto 0 0 0;
    padding-top: 0.65rem;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
    z-index: 1;
}

/* KPI ringkas di layar HP: 2 kolom, padding rapat, tipografi kecil. */
@media (max-width: 575.98px) {
    .kpi-card {
        padding: 0.6rem 0.75rem;
        gap: 0.35rem;
        border-radius: 12px;
    }
    .kpi-main {
        gap: 0.5rem;
    }
    .kpi-ico {
        width: 28px;
        height: 28px;
        border-radius: 8px;
        font-size: 0.95rem;
    }
    .kpi-value {
        font-size: 1.15rem;
        padding-right: 0;
    }
    .kpi-label {
        font-size: 0.6rem;
    }
    .kpi-sub {
        font-size: 0.65rem;
        padding-top: 0.35rem;
    }
    .kpi-chip {
        font-size: 0.55rem;
        top: 0.4rem;
        right: 0.4rem;
        padding: 2px 7px;
    }
}

/* --- Panel (kartu grafik / tabel / daftar) --- */
.panel-card {
    background: var(--ui-card-bg);
    border: 1px solid var(--ui-border);
    border-radius: clamp(12px, 5cqi, 16px);
    box-shadow: var(--shadow-soft);
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    container-type: inline-size;
}
.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
        gap: clamp(8px, 4cqi, 12px);
        padding: clamp(14px, 6cqi, 18px) clamp(14px, 7.5cqi, 22px) 0;
    }
.panel-title {
    font-size: clamp(0.9rem, 4.6cqi, 1.3rem);
    font-weight: 800;
    color: var(--ui-heading);
    margin: 0;
    display: flex;
    align-items: center;
    gap: clamp(6px, 3cqi, 8px);
}
.panel-title i { color: var(--ui-primary); font-size: clamp(0.85rem, 4cqi, 1.05rem); }
.panel-sub {
    font-size: clamp(0.72rem, 3.7cqi, 0.85rem);
    color: #94A3B8;
    margin: 2px 0 0 0;
}
.panel-action {
    font-size: clamp(0.7rem, 3.4cqi, 0.78rem);
    font-weight: 700;
    color: var(--ui-primary);
    text-decoration: none;
    white-space: nowrap;
    padding-top: 2px;
}
.panel-action:hover { color: var(--ui-primary-hover); text-decoration: underline; }
.panel-body { padding: clamp(12px, 5.5cqi, 16px) clamp(14px, 7.5cqi, 22px) clamp(14px, 7.5cqi, 22px); flex: 1; }
.panel-body-flush { padding: clamp(6px, 3cqi, 8px) 0 0 0; flex: 1; display: flex; flex-direction: column; }
/* Baris terakhir tabel menyatu flush dengan garis bawah panel. */
.panel-body-flush > .table-responsive { flex: 1 0 auto; min-width: 0; display: flex; flex-direction: column; margin-bottom: 0 !important; }
.panel-body-flush .sales-table { flex: 1 0 auto; margin-bottom: 0 !important; }
.panel-body-flush .sales-table tbody tr:last-child td { border-bottom: 0; }

/* --- Tabel bersih ala sales --- */
.panel-card .table-responsive { container-type: inline-size; }
.sales-table { width: 100%; margin: 0; font-size: clamp(0.66rem, 3.2cqi, 0.85rem); }
.sales-table th, .sales-table td { width: auto !important; white-space: nowrap; }
.sales-table thead th {
    background: #F8FAFC;
    border: 0;
    font-size: clamp(0.6rem, 2.9cqi, 0.7rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: clamp(0, 0.6cqi, 0.05em);
    color: #94A3B8;
    padding: clamp(8px, 3cqi, 10px) clamp(6px, 2.4cqi, 12px);
}
.sales-table thead th:first-child { padding-left: clamp(10px, 3.5cqi, 22px); }
.sales-table thead th:last-child { padding-right: clamp(10px, 3.5cqi, 22px); }
.sales-table tbody td {
    padding: clamp(8px, 3cqi, 12px);
    border-top: 1px solid #F1F5F9;
    vertical-align: middle;
    color: #334155;
    overflow-wrap: break-word;
}
.sales-table tbody td:first-child { padding-left: clamp(10px, 3.5cqi, 22px); }
.sales-table tbody td:last-child { padding-right: clamp(10px, 3.5cqi, 22px); }
.sales-table tbody tr:hover td { background: #F8FAFC; }
.rank-badge {
    display: inline-grid;
    place-items: center;
    width: 2.2em;
    height: 2.2em;
    border-radius: 0.5em;
    background: #F1F5F9;
    color: var(--ui-text);
    font-size: 0.95em;
    font-weight: 800;
    line-height: 1;
}
.rank-1 { background: rgba(245, 158, 11, 0.16); color: #B45309; }
.rank-2 { background: rgba(30, 124, 255, 0.12); color: #1D4ED8; }
.rank-3 { background: rgba(34, 197, 94, 0.14); color: #15803D; }
.rank-4 { background: rgba(139, 92, 246, 0.14); color: #6D28D9; }
.rank-5 { background: rgba(220, 53, 69, 0.14); color: #DC3545; }

/* Tabel ringkas dashboard: cell-wrap tanpa min-width lebar agar 5–6 kolom muat di panel. */
.panel-body-flush .sales-table td.cell-wrap,
.panel-body-flush .sales-table td.col-wrap {
    min-width: 0;
    max-width: none;
}

/* Tabel list dashboard: isi sel rata atas (bukan tengah). */
.sales-table.sales-top tbody td {
    vertical-align: top;
}
.sales-table.sales-top thead th {
    vertical-align: bottom;
}

/* --- Daftar profil (pengganti tabel bordered) --- */
.stat-lbl { font-size: 0.8rem; line-height: 1.2; }
.stat-ico > .fa-mars { font-size: 1.714rem !important; }
.profile-list { margin: 0; }
.profile-row {
    display: flex;
    gap: clamp(8px, 4cqi, 12px);
    padding: clamp(8px, 3.5cqi, 10px) 0;
    border-top: 1px solid #F1F5F9;
    font-size: clamp(0.78rem, 4cqi, 0.87rem);
}
.profile-row:first-child { border-top: 0; padding-top: 0; }
.profile-row:last-child { padding-bottom: 0; }
.profile-key { width: clamp(96px, 55cqi, 160px); flex-shrink: 0; color: #94A3B8; font-weight: 600; }
.profile-val { color: var(--ui-heading); font-weight: 600; }

/* --- Daftar panggilan orang tua (kartu profesional) --- */
.panggil-list { display: flex; flex-direction: column; }
.panggil-item {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 14px 22px;
    border-top: 1px solid #F1F5F9;
}
.panggil-item:first-child { border-top: 0; }
.panggil-item:hover { background: #F8FAFC; }
.panggil-ico {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-size: 1.2rem;
    flex-shrink: 0;
    background: rgba(239, 68, 68, 0.1);
    color: #EF4444;
}
.panggil-body { flex: 1; min-width: 0; }
.panggil-name { font-size: clamp(0.92rem, 0.88rem + 0.2vw, 1rem); font-weight: 800; color: var(--ui-heading); margin: 0; }
.panggil-meta { font-size: clamp(0.76rem, 0.73rem + 0.14vw, 0.82rem); color: var(--ui-text); margin: 2px 0 0 0; }
.panggil-last {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 6px 0 0 0;
    font-size: clamp(0.74rem, 0.71rem + 0.14vw, 0.8rem);
    font-weight: 600;
    color: var(--ui-text);
}
.panggil-last i { font-size: 0.75rem; color: var(--ui-primary); }
.panggil-note {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 8px 0 0 0;
    font-size: clamp(0.74rem, 0.71rem + 0.14vw, 0.8rem);
    font-weight: 700;
    color: #B45309;
    background: rgba(245, 158, 11, 0.12);
    border-radius: 8px;
    padding: 6px 10px;
}
.panggil-note i { font-size: 0.75rem; }
.panggil-side { text-align: right; flex-shrink: 0; }
.panggil-poin { font-size: clamp(1.25rem, 1.1rem + 0.7vw, 1.5rem); font-weight: 800; color: #EF4444; line-height: 1.1; }
.panggil-poin small { display: block; font-size: clamp(0.64rem, 0.62rem + 0.08vw, 0.68rem); font-weight: 700; color: #94A3B8; text-transform: uppercase; letter-spacing: 0.05em; }
.feed-list { display: flex; flex-direction: column; }
.feed-item {
    display: flex;
    gap: clamp(8px, 4cqi, 12px);
    align-items: flex-start;
    padding: clamp(9px, 4cqi, 12px) clamp(14px, 7.5cqi, 22px);
    border-top: 1px solid #F1F5F9;
}
.feed-item:first-child { border-top: 0; }
.feed-ico {
    width: clamp(32px, 13cqi, 38px);
    height: clamp(32px, 13cqi, 38px);
    border-radius: clamp(9px, 4cqi, 12px);
    display: grid;
    place-items: center;
    font-size: clamp(0.82rem, 3.6cqi, 0.95rem);
    flex-shrink: 0;
}
.feed-ico.red { background: rgba(239, 68, 68, 0.1); color: #EF4444; }
.feed-ico.green { background: rgba(34, 197, 94, 0.12); color: #16A34A; }
.feed-ico.amber { background: rgba(245, 158, 11, 0.14); color: #D97706; }
.feed-ico.blue { background: rgba(30, 124, 255, 0.12); color: #1E7CFF; }
.feed-body { flex: 1; min-width: 0; }
.feed-title { font-size: clamp(0.78rem, 4cqi, 0.85rem); font-weight: 700; color: var(--ui-heading); margin: 0; }
.feed-desc { font-size: clamp(0.71rem, 3.6cqi, 0.78rem); color: var(--ui-text); margin: 2px 0 0 0; }
.feed-date { font-size: clamp(0.66rem, 3.3cqi, 0.72rem); color: #94A3B8; white-space: nowrap; }
.feed-scroll { max-height: 380px; overflow-y: auto; }

/* --- Samakan tinggi panel dalam sebaris --- */
.row-panels > [class*="col-"] { display: flex; flex-direction: column; }
.row-panels > [class*="col-"] > .panel-card { flex: 1 1 auto; height: auto; }

/* --- Scroll tabel (samakan tinggi panel bersebelahan) --- */
.table-scroll { max-height: 380px; overflow-y: auto; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* --- Wadah chart (Chart.js butuh induk berukuran) --- */
.chart-box { position: relative; height: clamp(200px, 95cqi, 280px); }
.chart-box-sm { position: relative; height: clamp(180px, 75cqi, 220px); }

@media (max-width: 767.98px) {
    .profile-key { width: 120px; }
    .chart-box { height: 240px; }
}
