/* ==========================================================
   assets/css/app.css
   Sebelumnya CSS ini nempel sebagai <style> inline di dalam
   partials/header.php, sehingga dikirim ulang & di-parse ulang
   oleh browser di SETIAP perpindahan halaman (karena tiap
   halaman = reload penuh dari server). Dengan dipindah ke file
   eksternal ini, browser akan meng-cache file-nya sekali lalu
   memakainya lagi tanpa download ulang di halaman berikutnya.
   ========================================================== */

:root {
    /* Typography */
    --font-main: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --line-tight: 1.25;
    --line-normal: 1.5;

    /* Brand */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --primary-rgb: 79, 70, 229;
    --accent: #06b6d4;
    --brand-gradient: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);

    /* Surfaces */
    --bg-main: #f4f4f5;
    --bg-body: #f4f4f5;
    --surface: #ffffff;

    /* Text */
    --text-dark: #09090b;
    --text-heading: #09090b;
    --text-body: #52525b;
    --text-muted: #a1a1aa;
    --text-main: #0f172a;

    /* Borders */
    --border-color: #e4e4e7;
    --border-subtle: rgba(15, 23, 42, 0.06);
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(0, 0, 0, 0.08);

    /* Semantic */
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --info: #0ea5e9;
    --info-bg: #f0f9ff;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 24px -8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 20px 40px -12px rgba(0, 0, 0, 0.12);
    --shadow-glass: 0 8px 32px 0 rgba(31, 38, 135, 0.05);

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-pill: 999px;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;

    /* Motion */
    --page-fade-ms: 160ms;
    --ease-out: cubic-bezier(0.4, 0, 0.2, 1);

    /* Mobile */
    --touch-min: 44px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-main);
    color: var(--text-dark);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    /* Gradient dijadikan flat + non "fixed" di mobile (lihat media query di bawah)
       karena background-attachment: fixed memaksa repaint penuh saat scroll di banyak HP. */
    background-image:
        radial-gradient(circle at 15% 50%, rgba(67, 56, 202, 0.03), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(14, 165, 233, 0.03), transparent 25%);
    background-attachment: scroll;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-dark);
}

/* ===== NAVBAR GLASSMORPHISM =====
   Blur diturunkan dari 20px -> 10px. Efek blur backdrop-filter dihitung ulang
   oleh GPU tiap frame saat elemennya sticky/fixed dan halaman di-scroll;
   makin besar radius blur-nya, makin berat, terutama di HP kelas menengah-bawah.
   Ini salah satu penyebab utama terasa "berat"/tidak smooth saat scroll. */
.navbar-glass {
    background: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-glass);
    padding: 0.8rem 0;
    transition: box-shadow 0.2s ease;
}

.brand-logo-img {
    height: 38px;
    max-height: 38px;
    width: auto;
    max-width: 140px;
    object-fit: contain;
    display: block;
    transition: transform 0.25s ease;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.05));
}

@media (max-width: 576px) {
    .brand-logo-img {
        height: 30px;
        max-height: 30px;
        max-width: 110px;
    }
}

.navbar-brand:hover .brand-logo-img {
    transform: scale(1.05);
}

.link-reset {
    background: none; border: 0; padding: 0; margin: 0;
    font: inherit; color: inherit; text-align: inherit;
    cursor: pointer; outline: none;
}

/* ===== USER PILLS (WALLET & PROFILE) ===== */
.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.wallet-pill {
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    padding: 0.4rem 1rem 0.4rem 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    text-decoration: none;
}
.wallet-pill:hover {
    border-color: rgba(67, 56, 202, 0.2);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.wallet-icon {
    background: var(--primary-light);
    color: var(--primary);
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem;
}
.wallet-amount {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-dark);
}

.profile-pill {
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    padding: 0.25rem 1rem 0.25rem 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s ease;
    text-decoration: none;
}
.profile-pill:hover {
    background: var(--surface);
    border-color: var(--border-subtle);
    box-shadow: var(--shadow-sm);
}
.profile-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--surface);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.profile-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark);
}

.btn-logout {
    width: 38px; height: 38px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: #fee2e2;
    color: #ef4444;
    border: none;
    transition: background 0.2s ease, transform 0.2s ease;
    text-decoration: none;
}
.btn-logout:hover {
    background: #ef4444;
    color: white;
    transform: scale(1.05);
}

/* ===== AUTH BUTTONS (GUEST) ===== */
.btn-auth-login {
    color: var(--primary);
    font-weight: 600;
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-pill);
    transition: background 0.2s ease;
    text-decoration: none;
}
.btn-auth-login:hover {
    background: var(--primary-light);
}
.btn-auth-register {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    font-weight: 600;
    padding: 0.5rem 1.5rem;
    border-radius: var(--radius-pill);
    box-shadow: 0 4px 12px rgba(67, 56, 202, 0.3);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    text-decoration: none;
    border: none;
}
.btn-auth-register:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(67, 56, 202, 0.4);
    color: white;
}

/* ===== BOTTOM NAVIGATION (APP LIKE) ===== */
body.has-bottom-nav main {
    padding-bottom: 90px;
}
.bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 1030;
    display: flex;
    justify-content: space-around;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-subtle);
    padding-bottom: env(safe-area-inset-bottom, 12px);
    padding-top: 8px;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.04);
}
.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 600;
    transition: color 0.2s ease;
    padding: 4px;
}
.bottom-nav-item i {
    font-size: 1.35rem;
    transition: transform 0.2s ease;
}
.bottom-nav-item:hover, .bottom-nav-item.active {
    color: var(--primary);
}
.bottom-nav-item.active i {
    transform: translateY(-2px);
    text-shadow: 0 4px 12px rgba(67, 56, 202, 0.3);
}

/* ===== ALERTS (TOAST STYLE) ===== */
.alert-custom {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-md);
    background: var(--surface);
    animation: slideDown 0.35s ease;
    padding: 1rem 1.25rem;
}
.alert-custom .icon-box {
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.alert-custom.alert-success .icon-box { background: #dcfce7; color: #16a34a; }
.alert-custom.alert-danger .icon-box { background: #fee2e2; color: #ef4444; }

@keyframes slideDown {
    0% { opacity: 0; transform: translateY(-20px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* ==========================================================
   PAGE TRANSITION (dipakai bareng assets/js/page-transition.js)
   Website ini multi-halaman (tiap klik = reload penuh dari
   server), bukan single-page app. Efek "smooth" antar halaman
   didapat dengan:
   1) meta tag view-transition (native, Chrome/Edge terbaru)
      -> lihat partials/header.php
   2) fallback fade in/out via CSS + JS untuk browser lain
   ========================================================== */
html {
    view-transition-name: none;
}

body {
    animation: pageFadeIn var(--page-fade-ms) ease both;
}

@keyframes pageFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

body.is-leaving {
    opacity: 0;
    transition: opacity var(--page-fade-ms) ease;
}

/* Progress bar tipis di atas halaman saat pindah halaman */
#page-progress {
    position: fixed;
    top: 0; left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--primary));
    z-index: 99999;
    transition: width 0.3s ease, opacity 0.2s ease;
    opacity: 0;
    pointer-events: none;
}
#page-progress.is-active {
    opacity: 1;
}

/* Native browser View Transition (Chrome/Edge) untuk navigasi dokumen */
@supports (view-transition-name: none) {
    ::view-transition-old(root) {
        animation: pageFadeOutVT var(--page-fade-ms) ease both;
    }
    ::view-transition-new(root) {
        animation: pageFadeInVT var(--page-fade-ms) ease both;
    }
}
@keyframes pageFadeOutVT { to { opacity: 0; } }
@keyframes pageFadeInVT { from { opacity: 0; } }

/* Hormati preferensi user yang minta animasi dikurangi (aksesibilitas + baterai HP) */
@media (prefers-reduced-motion: reduce) {
    body, .alert-custom, #page-progress {
        animation: none !important;
        transition: none !important;
    }
}

/* Di layar kecil, background-attachment:fixed & blur berat dimatikan/dikurangi
   lagi karena repaint-nya jauh lebih mahal di GPU mobile murah */
@media (max-width: 768px) {
    body {
        background-attachment: scroll;
    }
    .navbar-glass,
    .bottom-nav {
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
    }
}


/* ===== Design-system utilities + mobile UX (P2) ===== */
.btn-primary-ds {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: var(--touch-min);
    padding: 0.65rem 1.25rem;
    border: none;
    border-radius: var(--radius-md);
    background: var(--primary);
    color: #fff !important;
    font-weight: 600;
    font-size: var(--font-size-sm);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.25);
    transition: background 0.15s var(--ease-out), transform 0.15s var(--ease-out);
    cursor: pointer;
}
.btn-primary-ds:hover { background: var(--primary-hover); color: #fff !important; }
.btn-primary-ds:active { transform: scale(0.98); }

.btn-ghost-ds {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: var(--touch-min);
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-heading);
    font-weight: 600;
    font-size: var(--font-size-sm);
    cursor: pointer;
}
.btn-ghost-ds:hover { background: var(--primary-light); }

.card-ds {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-5);
}

.input-ds {
    width: 100%;
    min-height: var(--touch-min);
    padding: 0.65rem 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-heading);
    font-size: 16px; /* cegah auto-zoom iOS */
    transition: border-color 0.15s, box-shadow 0.15s;
}
.input-ds:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

@media (max-width: 576px) {
    .container,
    .container-fluid {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }
    .nav-actions .btn,
    .nav-actions button,
    .nav-actions a.btn {
        min-height: 40px;
        min-width: 40px;
    }
    main.container,
    main.container-fluid {
        padding-bottom: calc(1.5rem + var(--safe-bottom));
    }
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }
    /* Form control di mobile: hindari zoom iOS */
    input.form-control,
    select.form-control,
    textarea.form-control {
        font-size: 16px !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
