/* ============================================================
   assets/css/pages/ui-polish.css — v1.0 PRODUCTION
   ------------------------------------------------------------
   Changelog v1.0 (2026-10-07):
   • Issue #5 : badges promo DALAM bingkai foto (tidak overlay)
   • Issue #6 : kartu produk 1 kelompok rapat
   • Issue #7 : tab header unification
   • Issue #8 : layout Bln/Thn members vertikal
   • Issue #14: header konsisten dengan index POS
   • Issue #15: satuan auto-display konsisten
   ------------------------------------------------------------
   Load: SETELAH main.css via renderAppHeadAssets().
   Zero inline. Semua selector di-scope untuk hindari konflik.
   ============================================================ */

/* ============================================================
   SECTION A — BADGE PROMO DALAM BINGKAI FOTO (Issue #5)
   ============================================================ */
.product-img-wrap {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 0;
    margin: 0 auto var(--sp-sm);
    border-radius: var(--r-md);
    border: 1px solid var(--c-gray-200);
    background: #fff;
    overflow: hidden;
    line-height: 0;
    flex-shrink: 0;
    max-width: 100%;
}
body.dark .product-img-wrap {
    border-color: var(--c-gray-600);
    background: var(--c-gray-800);
}
.product-img-wrap .product-img {
    width: 84px;
    height: 84px;
    object-fit: cover;
    border: none;
    border-radius: 0;
    background: var(--c-gray-100);
    display: block;
}
body.dark .product-img-wrap .product-img { background: var(--c-gray-700); }

.product-img-wrap .product-badges-wrap {
    position: static;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 100%;
    padding: 3px 3px 2px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-top: 1px solid rgba(0,0,0,0.04);
    pointer-events: none;
    animation: badgePop 0.35s cubic-bezier(0.16,1,0.3,1);
}
body.dark .product-img-wrap .product-badges-wrap {
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    border-top-color: rgba(255,255,255,0.05);
}

.product-img-wrap:not(:has(.product-badges-wrap)) { border: none; }
.product-img-wrap:not(:has(.product-badges-wrap)) .product-img {
    border: 1px solid var(--c-gray-200);
    border-radius: var(--r-md);
}
body.dark .product-img-wrap:not(:has(.product-badges-wrap)) .product-img {
    border-color: var(--c-gray-600);
}

.product-img-wrap .badge-discount,
.product-img-wrap .product-reward-badge {
    position: static !important;
    top: auto !important;
    left: auto !important;
    z-index: auto !important;
    animation: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    max-width: 100%;
}
.product-img-wrap .badge-discount-pct {
    font-size: 9px;
    padding: 2px 6px;
    box-shadow: 0 1px 3px rgba(220,38,38,0.25);
}
.product-img-wrap .badge-discount-qty,
.product-img-wrap .badge-discount-info {
    font-size: 8px;
    padding: 1px 5px;
}
.product-img-wrap .product-reward-badge {
    font-size: 8px;
    padding: 2px 5px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ============================================================
   SECTION B — KARTU PRODUK 1 KELOMPOK RAPAT (Issue #6)
   ============================================================ */
#productGrid .product-item {
    justify-content: flex-start !important;
    gap: 6px !important;
    min-height: auto !important;
    height: 100%;
    padding: var(--sp-md);
    display: flex;
    flex-direction: column;
    align-items: center;
}
#productGrid .product-item .product-name {
    flex: unset !important;
    margin: 0 !important;
    min-height: 2.4em;
    text-align: center;
    line-height: 1.2;
}
#productGrid .product-item .product-price {
    margin: 0 !important;
    text-align: center;
    line-height: 1.2;
}
#productGrid .product-item .product-stock {
    margin: 0 !important;
    text-align: center;
    line-height: 1.2;
}

/* ============================================================
   SECTION C — HEADER UNIFICATION (Issue #7, #14)
   ============================================================ */
.app-header-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 16px;
    position: relative;
    z-index: var(--z-header, 50);
}
.app-header-bar .nav-header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1 1 auto;
    text-decoration: none;
    color: inherit;
}
.app-header-bar .nav-header-brand .logo-box {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: #e0e7ff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}
body.dark .app-header-bar .nav-header-brand .logo-box { background: #312e81; }
.app-header-bar .nav-header-brand:hover .logo-box { transform: scale(1.05); }
.app-header-bar .nav-header-brand .logo-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.app-header-bar .nav-header-brand .brand-text { min-width: 0; }
.app-header-bar .nav-header-brand h1 {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.15;
    color: var(--c-black);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.app-header-bar .nav-header-brand p {
    font-size: 0.75rem;
    color: var(--c-gray-500);
    margin: 0;
    letter-spacing: 0.05em;
}
body.dark .app-header-bar .nav-header-brand h1 { color: #f1f5f9; }
body.dark .app-header-bar .nav-header-brand p  { color: #94a3b8; }

.app-header-bar .nav-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.app-header-bar .nav-header-tabs {
    width: 100%;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 12px;
    border-top: 1px solid var(--c-gray-200);
}
body.dark .app-header-bar .nav-header-tabs { border-top-color: var(--c-gray-700); }
.app-header-bar .nav-header-tabs .btn { white-space: nowrap; }

/* ============================================================
   SECTION D — STATS BLN/THN VERTIKAL (Issue #8)
   ============================================================ */
.member-stats-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 5px 7px;
    border-radius: 6px;
    background: rgba(241,245,249,0.7);
    min-width: 0;
}
body.dark .member-stats-group { background: rgba(30,41,59,0.5); }
.member-stats-group .member-stats-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--c-gray-600);
    line-height: 1;
}
body.dark .member-stats-group .member-stats-label { color: var(--c-gray-400); }
.member-stats-group .member-stats-lines {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.member-stats-group .member-stat-line {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 10px;
    line-height: 1.3;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.member-stats-group .member-stat-line.stat-tx {
    background: rgba(79,70,229,0.08);
    color: #4338ca;
}
.member-stats-group .member-stat-line.stat-loan {
    background: rgba(239,68,68,0.08);
    color: #b91c1c;
}
body.dark .member-stats-group .member-stat-line.stat-tx {
    background: rgba(129,140,248,0.15);
    color: #a5b4fc;
}
body.dark .member-stats-group .member-stat-line.stat-loan {
    background: rgba(248,113,113,0.15);
    color: #fca5a5;
}

/* ============================================================
   SECTION E — QTY WITH UNITS (Issue #15)
   ============================================================ */
.qty-with-units {
    display: inline-flex;
    align-items: baseline;
    gap: 3px;
    white-space: nowrap;
}
.qty-with-units .qty-value {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.qty-with-units .qty-unit-primary {
    font-size: 0.95em;
    font-weight: 600;
    color: var(--c-gray-700);
}
body.dark .qty-with-units .qty-unit-primary { color: var(--c-gray-200); }
.qty-with-units .qty-detail {
    font-size: 0.82em;
    color: var(--c-gray-500);
    font-weight: 500;
}
body.dark .qty-with-units .qty-detail { color: var(--c-gray-400); }
.qty-with-units.is-unlimited .qty-unit-primary {
    color: #059669;
    font-weight: 700;
}
body.dark .qty-with-units.is-unlimited .qty-unit-primary { color: #34d399; }

/* ============================================================
   SECTION F — NESTED MODAL AUTO-RAISE (Issue #4 fallback)
   ------------------------------------------------------------
   Modal.js v5.2 sudah handle z-index nested via inline style.
   Rule ini hanya sebagai safety net CSS untuk modal dinamis
   (#qrPreviewModal, #memberQrPreviewModal) yang dibuat oleh
   events.js tanpa set style.zIndex awal.
   ============================================================ */
.modal-overlay[data-dynamic-modal="1"] {
    z-index: 9999;
}
.modal-overlay[data-dynamic-modal="1"] .modal-box {
    box-shadow: 0 30px 60px rgba(0,0,0,0.35), 0 0 0 1px rgba(79,70,229,0.15);
}

/* ============================================================
   SECTION G — DRIVER TASK NEW PULSE (v3.2)
   ------------------------------------------------------------
   Highlight visual untuk task driver yang baru di-claim
   (< 3 menit). Border kuning berdenyut + badge "BARU".
   ============================================================ */
.driver-task-new {
    position: relative;
    animation: driverTaskPulse 2s ease-in-out infinite;
}
.driver-task-new::after {
    content: "BARU";
    position: absolute;
    top: -8px; right: 8px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 9999px;
    box-shadow: 0 2px 8px rgba(245,158,11,0.5);
    animation: badgePop 0.4s cubic-bezier(0.16,1,0.3,1);
}
@keyframes driverTaskPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.5),
                    0 20px 35px -12px rgba(0,0,0,0.15);
        border-color: rgba(245, 158, 11, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(245, 158, 11, 0),
                    0 20px 35px -12px rgba(0,0,0,0.15);
        border-color: rgba(245, 158, 11, 0.9);
    }
}
body.dark .driver-task-new {
    animation: driverTaskPulseDark 2s ease-in-out infinite;
}
@keyframes driverTaskPulseDark {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6),
                    0 20px 35px -12px rgba(0,0,0,0.5);
        border-color: rgba(245, 158, 11, 0.5);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(245, 158, 11, 0),
                    0 20px 35px -12px rgba(0,0,0,0.5);
        border-color: rgba(245, 158, 11, 1);
    }
}

/* ============================================================
   SECTION H — STORE BANNER (v3.2)
   ------------------------------------------------------------
   Banner titik jemput / toko di dashboard driver & assign page.
   ============================================================ */
.store-banner {
    border-left: 4px solid #10b981;
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.06) 0%, transparent 60%);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.store-banner:hover {
    box-shadow: 0 8px 20px -8px rgba(16, 185, 129, 0.35);
    transform: translateY(-1px);
}
.store-banner a {
    transition: all 0.15s ease;
}
.store-banner a:active {
    transform: scale(0.96);
}
body.dark .store-banner {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.12) 0%, transparent 60%);
}

/* ============================================================
   SECTION I — DRIVER STATE COLORS (v3.4)
   ------------------------------------------------------------
   Tombol online/offline dengan warna state:
     • Online (free)      : HIJAU terang
     • Sedang Bekerja     : ORANGE
     • Offline            : MERAH
   ============================================================ */

/* ---- Online / Free ---- */
.driver-status-btn.driver-status-online {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(34, 197, 94, 0.4) !important;
    border: none !important;
}
.driver-status-btn.driver-status-online:hover {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%) !important;
    box-shadow: 0 6px 18px rgba(34, 197, 94, 0.55) !important;
}

/* ---- Sedang Bekerja (busy) ---- */
.driver-status-btn.driver-status-busy {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(249, 115, 22, 0.45) !important;
    border: none !important;
    animation: driverBusyPulse 2s ease-in-out infinite;
}
.driver-status-btn.driver-status-busy:hover {
    background: linear-gradient(135deg, #ea580c 0%, #c2410c 100%) !important;
    box-shadow: 0 6px 18px rgba(249, 115, 22, 0.6) !important;
}
@keyframes driverBusyPulse {
    0%, 100% {
        box-shadow: 0 4px 14px rgba(249, 115, 22, 0.45),
                    0 0 0 0 rgba(249, 115, 22, 0.5);
    }
    50% {
        box-shadow: 0 4px 14px rgba(249, 115, 22, 0.45),
                    0 0 0 8px rgba(249, 115, 22, 0);
    }
}
@media (prefers-reduced-motion: reduce) {
    .driver-status-btn.driver-status-busy { animation: none; }
}

/* ---- Offline ---- */
.driver-status-btn.driver-status-offline {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35) !important;
    border: none !important;
}
.driver-status-btn.driver-status-offline:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%) !important;
    box-shadow: 0 6px 18px rgba(239, 68, 68, 0.55) !important;
}

/* ---- Filter badge count ---- */
.driver-filter-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9999px;
    background: rgba(0,0,0,0.08);
    font-size: 10px;
    font-weight: 800;
    margin-left: 4px;
}
.order-filter-active .driver-filter-badge {
    background: rgba(255,255,255,0.25);
    color: #fff;
}

/* ---- Claim button disabled state (busy) ---- */
.driver-task-item.is-busy-locked .order-action-verify,
.driver-task-item.is-busy-locked .driver-claim-btn {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

/* ============================================================
   SECTION J — UI PROFESSIONAL POLISH (v1.1)
   ------------------------------------------------------------
   Meningkatkan feel profesional + modern:
     • Running text modern (CSS animation, no <marquee>)
     • Card hover lift yang smooth
     • Button ripple + focus ring
     • Modal backdrop blur lebih halus
     • Form field focus animation
     • Table row hover smooth
     • Toast modern shadow
   ============================================================ */

/* ---------- J.1 — RUNNING TEXT MODERN ---------- */
.running-text-container {
    overflow: hidden;
    position: relative;
    padding: 0.65rem 1rem;
    border-radius: 0.75rem;
    background: linear-gradient(90deg, #fef3c7 0%, #fde68a 50%, #fef3c7 100%);
    border: 1px solid rgba(245, 158, 11, 0.35);
    box-shadow: 0 1px 3px rgba(245, 158, 11, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
body.dark .running-text-container {
    background: linear-gradient(90deg, #78350f 0%, #92400e 50%, #78350f 100%);
    border-color: rgba(217, 119, 6, 0.5);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.running-text-track {
    display: flex;
    gap: 3rem;
    white-space: nowrap;
    animation: runningTextScroll 32s linear infinite;
    will-change: transform;
    font-weight: 500;
    font-size: 0.9rem;
    letter-spacing: 0.015em;
    color: #92400e;
}
body.dark .running-text-track { color: #fde68a; }

.running-text-track:hover { animation-play-state: paused; }
.running-text-track > span { display: inline-flex; align-items: center; gap: 0.5rem; }

@keyframes runningTextScroll {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
    .running-text-track { animation: none; overflow-x: auto; }
}

/* ---------- J.2 — CARD HOVER LIFT ---------- */
.app-card {
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.22s cubic-bezier(0.16, 1, 0.3, 1),
                border-color 0.22s ease;
}
.app-card:hover {
    box-shadow: 0 20px 40px -16px rgba(79, 70, 229, 0.14),
                0 10px 24px -12px rgba(0, 0, 0, 0.08);
}

.stat-card {
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 32px -12px rgba(79, 70, 229, 0.2);
}

/* ---------- J.3 — BUTTON MODERN ---------- */
.btn {
    position: relative;
    overflow: hidden;
    transition: transform 0.15s ease,
                box-shadow 0.2s ease,
                background-color 0.2s ease,
                border-color 0.2s ease;
    letter-spacing: 0.01em;
}
.btn::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%),
        rgba(255, 255, 255, 0.28) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}
.btn:active::after { opacity: 1; transition: none; }

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.35),
                0 2px 8px rgba(79, 70, 229, 0.15);
}

/* ---------- J.4 — MODAL BACKDROP & BOX ---------- */
.modal-overlay {
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px) saturate(140%);
    -webkit-backdrop-filter: blur(6px) saturate(140%);
    animation: modalFadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-box {
    box-shadow:
        0 32px 64px -16px rgba(0, 0, 0, 0.28),
        0 12px 28px -12px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(255, 255, 255, 0.06) inset;
    animation: modalPopModern 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}
body.dark .modal-box {
    box-shadow:
        0 32px 64px -16px rgba(0, 0, 0, 0.65),
        0 12px 28px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}

@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalPopModern {
    from { opacity: 0; transform: scale(0.94) translateY(14px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ---------- J.5 — FORM FIELD FOCUS ---------- */
.input-base,
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select,
textarea {
    transition: border-color 0.18s ease,
                box-shadow 0.18s ease,
                background-color 0.18s ease;
}
.input-base:focus,
select:focus,
textarea:focus {
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.18),
                0 1px 3px rgba(79, 70, 229, 0.1);
    border-color: #6366f1;
}
body.dark .input-base:focus,
body.dark select:focus,
body.dark textarea:focus {
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.25),
                0 1px 3px rgba(0, 0, 0, 0.3);
    border-color: #818cf8;
}

/* ---------- J.6 — TABLE ROW HOVER ---------- */
.data-table tbody tr { transition: background-color 0.15s ease; }
.data-table tbody tr:hover {
    background-color: rgba(79, 70, 229, 0.035);
}
body.dark .data-table tbody tr:hover {
    background-color: rgba(129, 140, 248, 0.08);
}

/* ---------- J.7 — HEADER BRAND HOVER ---------- */
.app-header-bar .nav-header-brand {
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.app-header-bar .nav-header-brand:hover { transform: translateY(-1px); }
.app-header-bar .nav-header-brand .logo-box {
    box-shadow: 0 4px 12px -4px rgba(79, 70, 229, 0.25);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.app-header-bar .nav-header-brand:hover .logo-box {
    box-shadow: 0 8px 20px -6px rgba(79, 70, 229, 0.35);
}

/* ---------- J.8 — TOAST MODERN ---------- */
.toast-notify {
    border-left-width: 4px;
    border-radius: 0.85rem;
    box-shadow: 0 20px 40px -16px rgba(0, 0, 0, 0.22),
                0 8px 20px -8px rgba(0, 0, 0, 0.14),
                0 0 0 1px rgba(0, 0, 0, 0.03);
    font-weight: 500;
    letter-spacing: 0.005em;
}
body.dark .toast-notify {
    box-shadow: 0 20px 40px -16px rgba(0, 0, 0, 0.6),
                0 8px 20px -8px rgba(0, 0, 0, 0.4),
                0 0 0 1px rgba(255, 255, 255, 0.05);
}

/* ---------- J.9 — RESPONSIVE POLISH ---------- */
@media (max-width: 640px) {
    .app-card:hover { transform: none; box-shadow: var(--shadow-xl); }
    .stat-card:hover { transform: none; }
}