/******************************************************************************
 * File     : css/dashboard.css
 * Project  : CATER PWA - Modern Dashboard Styles
 * Version  : 4.0.0 (FINAL — Sticky Cards Zero-Move, tanpa patch bertumpuk)
 ******************************************************************************/

/* ==========================================================
   1. GLOBAL VARIABLES & BASE
   ========================================================== */
:root {
    --font-primary: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --bg-surface: #fcfcfc;
    --primary-blue: #0284c7;
    --primary-gradient: linear-gradient(180deg, #0284c7 10%,  #0369a1 90%);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;

    /* SATU sumber kebenaran tinggi navbar.
       Row card di-pin tepat di angka ini => delta 0. */
    --navbar-height: 62px;

    /* Celah permanen navbar -> card (ada saat diam MAU pun saat pinned) */
    --cards-gap: 1px;
}

html, body {
    overflow-x: clip;   /* clip (bukan hidden) => tidak mematikan sticky */
}

body.bg-surface {
    background-color: var(--bg-surface) !important;
    font-family: var(--font-primary);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

/* ==========================================================
   2. NAVBAR — tinggi dikunci agar perhitungan sticky presisi
   ========================================================== */
.navbar-modern {
    position: sticky;
    top: 0;
    height: var(--navbar-height);
    /* UBAH: Gunakan gradasi linier yang warna akhirnya (#0284c7) menyambung sempurna */
    background: linear-gradient(180deg, #05497a 0%, #0284c7 100%);
    box-shadow: none;
    z-index: 1030;
    user-select: none;
}
 
/* Efek saat diklik */
#logoPDAM:active {
    transform: scale(0.95);
} 


.logo-wrapper {
    background: rgba(255, 255, 255, 0.22);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 4px 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.4);
}

.brand-text {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.2;
}


.nav-icon-btn {
    width: 30px;   /* Diturunkan dari 38px agar jarak antar-ikon lebih rapat */
    height: 30px;  /* Diturunkan dari 38px */
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
    
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
}

.nav-icon-btn:hover,
.nav-icon-btn:focus {
    background: transparent;
    color: #ffffff;
    transform: translateY(-2px);
    opacity: 0.85;
}

.nav-icon-btn:active { 
    transform: scale(0.85); 
}


/* ==========================================================
   3. INLINE SEARCH OVERLAY
   ========================================================== */
.inline-search-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;            /* Menutupi 100% lebar layar HP */
    margin-left: calc(-50vw + 50%);
    
    background: linear-gradient(180deg, #05497a 0%, #0284c7 100%);
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1040;
}

.search-box-modern {
    background: #ffffff;
    height: 40px;
    width: 97% !important;
    border-radius: 10px !important;  /* Disamakan persis dengan .stat-card (18px) */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    display: flex;
    align-items: center;
    padding: 0 12px;
}

.search-box-modern input {
    font-size: 0.85rem;
    color: var(--text-main);
    font-family: var(--font-primary);
    border: none;
    background: transparent;
    width: 100%;
}

.search-box-modern input:focus {
    outline: none;
    box-shadow: none;
}

.search-box-modern input::placeholder { 
    color: #94a3b8; 
}


/* ==========================================================
   4. MAIN CONTAINER — padding-top WAJIB 0
   (agar posisi flow row == posisi pin => card tidak melompat)
   ========================================================== */
body > .container-fluid {
    padding-top: 0 !important;
}

/* ==========================================================
   5. SUMMARY CARDS — STICKY ZERO-MOVE
   ========================================================== */
.row.g-2.mb-3 {
    position: sticky;
    top: var(--navbar-height);      /* == posisi flow saat scrollY 0 => delta 0 */
    z-index: 100;                   /* di bawah navbar(1030), di atas list(auto) */
    padding-top: var(--cards-gap);  /* celah permanen, identik diam & pinned */
}

/* Shield + gradasi: ANAK dari row sticky => ikut terkunci, tidak pernah bergerak.
   Menutup gutter samping, sela navbar, dan celah ke list => list tak nembus. */
/* Shield + gradasi: ANAK dari row sticky */
.row.g-2.mb-3::before {
    content: "";
    position: absolute;
    left: -16px;                     /* nutup gutter px-3 (16px) => full-bleed */
    right: -16px;
    top: 0;                          /* UBAH: Dari -8px menjadi 0 */
    margin-top: -1px;                /* TAMBAH: Overlap 1px ke bawah navbar */
    bottom: -16px;                   /* nutup margin mb-3 ke list */
    z-index: -1;                     /* di belakang card, di atas list */
    pointer-events: none;
         

    /* UBAH: Dimulai persis dari warna dasar paling bawah navbar (#0284c7) */
    background: linear-gradient(180deg,
        #0284c7 0%,                  /* Warna persis sama dengan bagian bawah navbar */
        #2f92d1 20%,
        #58ace0 38%,
        #8ac6ee 56%,
        #bfe0f7 74%,
        #fcfcfc 88%,
        #fcfcfc 100%);               /* ekor opaque menyatu dengan background body */
}

/* ---------- Kartu stat ---------- */
.stat-card {
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.9) !important;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
    user-select: none;
}

.stat-card .card-body {
    display: flex;
    align-items: center;
    padding: 0.4rem 0.75rem !important;
}

.stat-card:active {
    transform: translateY(1px);
}

/* Glow berwarna per card */
.stat-target {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 60%, #bae6fd 100%);
    box-shadow:
        0 10px 24px -6px rgba(59, 130, 246, 0.40),
        0 4px 10px -2px rgba(59, 130, 246, 0.20),
        inset 0 1px 2px 0 rgba(255, 255, 255, 0.9),
        inset 0 -3px 0 0 rgba(0, 0, 0, 0.04) !important;
}
.stat-selesai {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 60%, #bbf7d0 100%);
    box-shadow:
        0 10px 24px -6px rgba(34, 197, 94, 0.40),
        0 4px 10px -2px rgba(34, 197, 94, 0.20),
        inset 0 1px 2px 0 rgba(255, 255, 255, 0.9),
        inset 0 -3px 0 0 rgba(0, 0, 0, 0.04) !important;
}
.stat-belum {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 60%, #fde68a 100%);
    box-shadow:
        0 10px 24px -6px rgba(245, 158, 11, 0.40),
        0 4px 10px -2px rgba(245, 158, 11, 0.20),
        inset 0 1px 2px 0 rgba(255, 255, 255, 0.9),
        inset 0 -3px 0 0 rgba(0, 0, 0, 0.04) !important;
}
.stat-proses {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 60%, #fecaca 100%);
    box-shadow:
        0 10px 24px -6px rgba(239, 68, 68, 0.40),
        0 4px 10px -2px rgba(239, 68, 68, 0.20),
        inset 0 1px 2px 0 rgba(255, 255, 255, 0.9),
        inset 0 -3px 0 0 rgba(0, 0, 0, 0.04) !important;
}

/* ---------- Icon 3D bola cembung ---------- */
.stat-icon-wrapper {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #ffffff !important;
    box-shadow:
        0 6px 12px -2px rgba(0, 0, 0, 0.18),
        inset 0 2px 3px rgba(255, 255, 255, 0.35),
        inset 0 -2px 3px rgba(0, 0, 0, 0.18) !important;
}

.stat-icon-wrapper i {
    color: #ffffff !important;
    font-size: 1.35rem;
    line-height: 1;
    text-shadow: none !important;
    filter: none !important;
    -webkit-font-smoothing: antialiased;
}

.bg-primary-subtle { background: linear-gradient(145deg, #0284c7 0%, #0369a1 100%) !important; }
.bg-success-subtle { background: linear-gradient(145deg, #16a34a 0%, #15803d 100%) !important; }
.bg-warning-subtle { background: linear-gradient(145deg, #f59e0b 0%, #d97706 100%) !important; }
.bg-danger-subtle  { background: linear-gradient(145deg, #dc2626 0%, #b91c1c 100%) !important; }

.text-warning-dark { color: #b45309 !important; }

/* ---------- Tipografi isi card ---------- */
.stat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-left: 12px;
    min-width: 0;
}

.stat-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: #334155;
    white-space: nowrap;
    line-height: 1.2;
    margin-bottom: 2px;
}

.stat-value {
    min-width: unset;
    text-align: left;
    font-size: 1.3rem;
    font-weight: 800;
    line-height: 1.1;
    white-space: nowrap;
}

/* ==========================================================
   6. CUSTOMER LIST CARD & TABLE
   (scroll normal, lewat DI BAWAH row sticky)
   ========================================================== */
.list-container-card {
    border-radius: 18px;
    background: #ffffff;
    box-shadow:
        0 10px 25px -5px rgba(15, 23, 42, 0.08),
        0 4px 6px -2px rgba(15, 23, 42, 0.04) !important;
}

.avatar-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.table-custom tbody tr {
    transition: background-color 0.15s ease;
    border-bottom: 1px solid var(--border-color);
    touch-action: manipulation;
}

.table-custom tbody tr:last-child { border-bottom: none; }
.table-custom tbody tr:hover { background-color: #f8fafc; }

#customerTable tbody td {
    padding: 10px 14px !important;
    line-height: 1.3 !important;
    font-size: 0.82rem;
}

#customerTable tbody td .fw-bold,
#customerTable tbody td .fw-semibold {
    font-size: 0.85rem !important;
    color: var(--text-main);
}

#customerTable tbody td .small,
#customerTable tbody td div:last-child {
    font-size: 0.74rem !important;
    color: var(--text-main) !important;
}

#customerTable tbody td .bi-geo-alt {
    font-size: 0.72rem !important;
    color: #94a3b8 !important;
}

.text-success { color: #16a34a !important; }
.text-danger  { color: #dc2626 !important; }

/* ==========================================================
   7. FLOATING ACTION BUTTON (GO TOP)
   ========================================================== */
.btn-float {
    position: fixed;
    bottom: 24px;
    right: 20px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    z-index: 1050;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-gradient);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow:
        0 8px 18px rgba(2, 132, 199, 0.4),
        inset 0 2px 2px rgba(255, 255, 255, 0.5);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
}

.btn-float:active { transform: scale(0.9); }



/* Custom Style SweetAlert Modal Mobile-Friendly */
.swal-custom-popup {
    width: 280px !important;            /* Ukuran modal lebih compact */
    max-width: 85vw !important;         /* Maksimal 85% lebar layar mobile */
    border-radius: 16px !important;
    padding: 16px 14px !important;
    background-color: #f8fbff !important;
}

/* Style Judul 'Konfirmasi' */
.swal-custom-title {
    color: #0056b3 !important;
    font-weight: 700 !important;
    font-size: 1.1rem !important;
    margin-top: 6px !important;
    margin-bottom: 2px !important;
    padding: 0 !important;
}

/* Style Teks 'Apakah Anda yakin?' */
.swal-custom-text {
    color: #333333 !important;
    font-size: 0.85rem !important;
    margin-top: 4px !important;
    margin-bottom: 12px !important;
    padding: 0 !important;
}

/* Wrapper Tombol Aksi */
.swal2-actions {
    margin-top: 8px !important;
    gap: 8px !important;
}

/* Tombol 'Ya' (Hijau) */
.swal-custom-btn-yes {
    background-color: #28a745 !important;
    color: #ffffff !important;
    border-radius: 8px !important;
    padding: 6px 0 !important;
    width: 90px !important;
    font-weight: 600 !important;
    font-size: 0.85rem !important;
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
}

/* Tombol 'Tidak' (Merah) */
.swal-custom-btn-no {
    background-color: #dc3545 !important;
    color: #ffffff !important;
    border-radius: 8px !important;
    padding: 6px 0 !important;
    width: 90px !important;
    font-weight: 600 !important;
    font-size: 0.85rem !important;
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
}

/* Koreksi No 4: Border Card Tabel Terkesan Timbul (Elevated 3D Shadow) */
.list-container-card {
    border-radius: 12px !important;
    border: 1px solid rgba(255, 255, 255, 0.8) !important;
    box-shadow: 0 8px 16px -2px rgba(0, 0, 0, 0.12), 0 4px 6px -1px rgba(0, 0, 0, 0.07) !important;
    background-color: #ffffff;
}

/* Koreksi No 1: Menjadikan header tabel sticky agar batas atas terlihat jelas */
#customerTable thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    box-shadow: inset 0 -1px 0 #dee2e6;
}

/* Koreksi No 2: Menghilangkan border pada baris terakhir di customerTable */
#customerTable tbody tr:last-child td {
    border-bottom: none !important;
}

/* Koreksi No 3: Efek Visual Respon Ditekan saat Double Click / Tap */
#customerTable tbody tr {
    transition: transform 0.1s ease, background-color 0.15s ease, box-shadow 0.1s ease;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

#customerTable tbody tr:active,
#customerTable tbody tr.row-pressed {
    background-color: #e0f2fe !important; /* Warna highlight biru muda */
    transform: scale(0.985); /* Efek tombol tertekan */
}
 
/* Style Icon Rumah Murni (Tanpa Lingkaran) */
.btn-view-house {
    background-color: transparent !important;
    border-radius: 0 !important;
    padding: 0 !important;
    width: auto !important;
    height: auto !important;
    color: #0284c7;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, color 0.15s ease;
}

/* Efek saat icon ditekan */
.btn-view-house:active {
    color: #0369a1;
    transform: scale(0.85);
}


/* 1. MENGATUR LEBAR TABEL & PAS DI LAYAR TANPA SCROLL HORISONTAL */
#customerTable {
    width: 100% !important;
    table-layout: fixed; /* Kunci lebar agar teks ter-crop rapi & icon rumah tidak terdorong keluar layar */
}

.table-responsive.style-no-scroll {
    overflow-x: hidden !important; /* Mencegah munculnya scrollbar horisontal */
}

/* 2. CARD TIMBUL 3D (ELEVATED) */
.list-container-card {
    border-radius: 12px !important;
    border: 1px solid rgba(255, 255, 255, 0.8) !important;
    box-shadow: 0 8px 16px -2px rgba(0, 0, 0, 0.12), 0 4px 6px -1px rgba(0, 0, 0, 0.07) !important;
    background-color: #ffffff;
}

/* Hapus garis border paling bawah */
#customerTable tbody tr:last-child td {
    border-bottom: none !important;
}

/* 3. EFEK VISUAL RESPONS DITEKAN SAAT DOUBLE CLICK / TAP */
#customerTable tbody tr {
    transition: transform 0.1s ease, background-color 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

#customerTable tbody tr:active,
#customerTable tbody tr.row-pressed {
    background-color: #e0f2fe !important;
    transform: scale(0.985);
}

/* 4. PENATAAN KOLOM KIRI & KOLOM ICON RUMAH */
.col-info-pelanggan {
    width: auto;
    overflow: hidden;
}

.col-action-rumah {
    width: 48px !important;
    text-align: right;
    vertical-align: middle;
}

.btn-view-house {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #f1f5f9;
    color: #0284c7;
    transition: all 0.2s ease;
}

.btn-view-house:active {
    background-color: #0284c7;
    color: #ffffff;
}

.stat-content {
    width: 100%;
    text-align: right;
}

.stat-label, 
.stat-value {
    display: block;
    text-align: right;
}


/* Styling Efek Card Terpilih (Border Ring & Terangkat) */
.stat-card {
    transition: all 0.2s ease-in-out;
    border: 2px solid transparent !important; /* Mencegah card melompat saat border muncul */
}

/* Kapan Card Dianggap Aktif/Terpilih */
.stat-card.active {
    border-color: #0d6efd !important; /* Warna border utama (Bootstrap primary) */
    background-color: #fff !important;
    box-shadow: 0 0.5rem 1rem rgba(13, 110, 253, 0.2) !important; /* Bayangan halus kebiruan */
    transform: translateY(-4px); /* Card terangkat 4px ke atas */
}

/* 1. Atur Otomatis Tinggi Baris & Padding Tabel */
#customerListBody tr td {
    height: auto !important;         /* Tinggi baris menyesuaikan isi konten (auto height) */
    vertical-align: middle;          /* Memastikan teks tetap rata tengah secara vertikal */
    padding-top: 3px !important;     /* Atur jarak atas/bawah untuk mengontrol tinggi minimal row */
    padding-bottom: 3px !important;
}

/* 2. Otomatis Wrap Alamat Pelanggan */
.col-info-pelanggan .text-truncate {
    overflow: visible !important;    /* Matikan pemotongan teks dengan titik (...) */
    white-space: normal !important;  /* Izinkan teks turun/wrap ke baris baru */
    word-break: break-word;          /* Memutus kata yang terlalu panjang agar tidak merusak layout */
    line-height: 1.3;                /* Mengatur kerapatan baris teks alamat */
}

/* Tambahkan di file CSS Anda */
tr {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}


#btnGoTop {
    position: fixed;
    left: 20px;
    bottom: 20px;
    right: auto;
}

.spin-animation {
    display: inline-block;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ==========================================================
   OPTIMASI TOUCH RESPONSE — FIX DOUBLE-TAP LAMBAT
   ========================================================== */

/* touch-action: manipulation menghilangkan delay 300ms
   yang biasa dipasang Chrome untuk deteksi double-tap zoom.
   Wajib dipasang di ancestor chain (tbody → tr → td) */
#customerTable tbody,
#customerTable tbody tr,
#customerTable tbody td {
    touch-action: manipulation;
}

/* Optimasi rendering row — beri hint ke browser
   supaya siap handle perubahan background saat tap */
#customerTable tbody tr {
    will-change: background-color;
}