/*
 * Badri Bersaudara — Member Portal Design System
 * Sprint 2.1
 *
 * Palet: Emerald hijau koperasi sebagai primary, slate untuk teks,
 * amber sebagai accent untuk aksi penting.
 * Tipografi: Inter untuk UI, angka menggunakan font-variant-numeric
 * tabular-nums agar alignment rapi di semua angka keuangan.
 */

/* ============================================================
   IMPORT FONT
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ============================================================
   CSS CUSTOM PROPERTIES — DESIGN TOKENS
   ============================================================ */
:root {
    /* --- Primary: Emerald (identitas koperasi) --- */
    --color-primary-50:  #ecfdf5;
    --color-primary-100: #d1fae5;
    --color-primary-200: #a7f3d0;
    --color-primary-500: #10b981;
    --color-primary-600: #059669;
    --color-primary-700: #047857;
    --color-primary-900: #064e3b;

    /* --- Accent: Amber (aksi penting, notifikasi) --- */
    --color-accent-400: #fbbf24;
    --color-accent-500: #f59e0b;
    --color-accent-600: #d97706;

    /* --- Slate (teks, background) --- */
    --color-slate-50:   #f8fafc;
    --color-slate-100:  #f1f5f9;
    --color-slate-200:  #e2e8f0;
    --color-slate-300:  #cbd5e1;
    --color-slate-400:  #94a3b8;
    --color-slate-500:  #64748b;
    --color-slate-600:  #475569;
    --color-slate-700:  #334155;
    --color-slate-800:  #1e293b;
    --color-slate-900:  #0f172a;

    /* --- Semantic --- */
    --color-danger:  #ef4444;
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-info:    #3b82f6;

    /* --- Background --- */
    --bg-app:      #f1f5f9;     /* background utama app */
    --bg-surface:  #ffffff;     /* surface card/panel */
    --bg-hero:     linear-gradient(135deg, var(--color-primary-700) 0%, var(--color-primary-500) 100%);

    /* --- Teks --- */
    --text-primary:   var(--color-slate-900);
    --text-secondary: var(--color-slate-500);
    --text-muted:     var(--color-slate-400);
    --text-inverse:   #ffffff;

    /* --- Border --- */
    --border-color: var(--color-slate-200);
    --border-radius-sm:  8px;
    --border-radius-md:  12px;
    --border-radius-lg:  16px;
    --border-radius-xl:  20px;
    --border-radius-full: 9999px;

    /* --- Shadow --- */
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.08), 0 1px 2px -1px rgb(0 0 0 / 0.06);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.07), 0 4px 6px -4px rgb(0 0 0 / 0.05);
    --shadow-card: 0 2px 12px 0 rgb(0 0 0 / 0.06);

    /* --- Spacing --- */
    --space-1:  4px;
    --space-2:  8px;
    --space-3:  12px;
    --space-4:  16px;
    --space-5:  20px;
    --space-6:  24px;
    --space-8:  32px;
    --space-10: 40px;

    /* --- Typography --- */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-xs:   11px;
    --font-size-sm:   13px;
    --font-size-base: 15px;
    --font-size-md:   17px;
    --font-size-lg:   20px;
    --font-size-xl:   24px;
    --font-size-2xl:  28px;
    --font-size-3xl:  36px;

    /* --- Bottom Nav --- */
    --bottom-nav-height: 64px;
    --bottom-nav-bg:     #ffffff;

    /* --- Header --- */
    --header-height: 56px;

    /* --- Transition --- */
    --transition-fast:   150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow:   350ms ease;

    /* --- Z-index --- */
    --z-header:     100;
    --z-bottom-nav: 100;
    --z-overlay:    200;
    --z-modal:      300;
    --z-toast:      400;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--text-primary);
    background-color: var(--bg-app);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Angka keuangan selalu tabular */
.numeric, .currency, .balance {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    letter-spacing: -0.01em;
}

/* ============================================================
   APP SHELL — LAYOUT UTAMA
   ============================================================ */

/* Container utama — max-width untuk tidak terlalu lebar di desktop */
.app-shell {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh; /* dynamic viewport height untuk mobile browser */
    position: relative;
    background-color: var(--bg-app);
}

/* Area konten — padding bottom untuk Bottom Nav */
.app-content {
    padding-bottom: calc(var(--bottom-nav-height) + var(--space-4));
    min-height: 100vh;
    min-height: 100dvh;
}

/* ============================================================
   HEADER MEMBER
   ============================================================ */
.member-header {
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    background: var(--bg-hero);
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-5);
}

.member-header__greeting {
    display: flex;
    flex-direction: column;
}

.member-header__hello {
    font-size: var(--font-size-xs);
    color: rgba(255, 255, 255, 0.75);
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.member-header__name {
    font-size: var(--font-size-md);
    color: var(--text-inverse);
    font-weight: 700;
    line-height: 1.2;
}

.member-header__actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.member-header__btn {
    width: 36px;
    height: 36px;
    border-radius: var(--border-radius-full);
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: var(--text-inverse);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition-fast);
    text-decoration: none;
    font-size: 16px;
    position: relative;
}

.member-header__btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.member-header__badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 16px;
    height: 16px;
    background: var(--color-accent-500);
    border-radius: var(--border-radius-full);
    font-size: 9px;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    border: 2px solid var(--color-primary-700);
}

/* ============================================================
   BOTTOM NAVIGATION
   ============================================================ */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: var(--bottom-nav-height);
    background: var(--bottom-nav-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: var(--z-bottom-nav);
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -4px 20px 0 rgb(0 0 0 / 0.06);
}

.bottom-nav__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: var(--space-2) 0;
    text-decoration: none;
    color: var(--text-muted);
    transition: color var(--transition-fast);
    cursor: pointer;
    border: none;
    background: none;
    font-family: var(--font-family);
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav__item:hover,
.bottom-nav__item.active {
    color: var(--color-primary-600);
}

.bottom-nav__icon {
    font-size: 20px;
    line-height: 1;
    position: relative;
    /* Icon tidak aktif lebih redup */
    opacity: 0.45;
    transition: opacity var(--transition-fast);
}

.bottom-nav__item.active .bottom-nav__icon,
.bottom-nav__item:hover .bottom-nav__icon {
    opacity: 1;
}

.bottom-nav__label {
    font-size: var(--font-size-xs);
    font-weight: 500;
    line-height: 1;
}

/* Indicator dot untuk item aktif */
.bottom-nav__item.active .bottom-nav__icon::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: var(--color-primary-600);
    border-radius: var(--border-radius-full);
}

/* ============================================================
   CARD KOMPONEN
   ============================================================ */
.card {
    background: var(--bg-surface);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.card--padded {
    padding: var(--space-5);
}

.card--clickable {
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.card--clickable:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-sm);
}

/* ============================================================
   SECTION CONTAINER
   ============================================================ */
.section {
    padding: var(--space-5) var(--space-5) 0;
}

.section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.section__title {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--text-primary);
}

.section__link {
    font-size: var(--font-size-sm);
    color: var(--color-primary-600);
    font-weight: 500;
    text-decoration: none;
}

/* ============================================================
   LOADING SKELETON
   ============================================================ */
@keyframes skeleton-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

.skeleton {
    background: var(--color-slate-200);
    border-radius: var(--border-radius-sm);
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton--text {
    height: 14px;
    width: 100%;
}

.skeleton--text-sm {
    height: 11px;
    width: 60%;
}

.skeleton--text-lg {
    height: 28px;
    width: 70%;
}

.skeleton--circle {
    border-radius: var(--border-radius-full);
}

.skeleton--card {
    height: 120px;
    border-radius: var(--border-radius-lg);
    width: 100%;
}

/* Skeleton untuk Balance Card */
.skeleton-balance {
    background: linear-gradient(135deg, var(--color-primary-700), var(--color-primary-500));
    border-radius: var(--border-radius-xl);
    padding: var(--space-6);
    margin: 0 var(--space-5);
}

.skeleton-balance .skeleton {
    background: rgba(255, 255, 255, 0.2);
}

/* ============================================================
   HERO AREA (area di bawah header, masih hijau)
   ============================================================ */
.hero-area {
    background: var(--bg-hero);
    padding: var(--space-4) var(--space-5) var(--space-8);
    margin-bottom: calc(-1 * var(--space-6));
}

/* ============================================================
   BUTTON
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 12px var(--space-6);
    border-radius: var(--border-radius-full);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.btn--primary {
    background: var(--color-primary-600);
    color: white;
}

.btn--primary:active {
    background: var(--color-primary-700);
    transform: scale(0.98);
}

.btn--ghost {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn--full {
    width: 100%;
}

/* ============================================================
   BADGE / PILL
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--border-radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
    line-height: 1.4;
}

.badge--success {
    background: var(--color-primary-50);
    color: var(--color-primary-700);
}

.badge--warning {
    background: #fffbeb;
    color: var(--color-accent-600);
}

.badge--danger {
    background: #fef2f2;
    color: #dc2626;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-10) var(--space-6);
    text-align: center;
    gap: var(--space-3);
}

.empty-state__icon {
    font-size: 48px;
    opacity: 0.3;
}

.empty-state__title {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--text-secondary);
}

.empty-state__desc {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    max-width: 240px;
    line-height: 1.6;
}

/* ============================================================
   DIVIDER
   ============================================================ */
.divider {
    height: 1px;
    background: var(--border-color);
    margin: var(--space-4) 0;
}

/* ============================================================
   AVATAR
   ============================================================ */
.avatar {
    border-radius: var(--border-radius-full);
    object-fit: cover;
    background: var(--color-primary-100);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary-700);
    font-weight: 700;
    flex-shrink: 0;
}

.avatar--sm { width: 32px; height: 32px; font-size: var(--font-size-sm); }
.avatar--md { width: 40px; height: 40px; font-size: var(--font-size-base); }
.avatar--lg { width: 56px; height: 56px; font-size: var(--font-size-lg); }

/* ============================================================
   UTILITY
   ============================================================ */
.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-inverse   { color: var(--text-inverse); }
.text-success   { color: var(--color-primary-600); }
.text-warning   { color: var(--color-accent-500); }
.text-danger    { color: var(--color-danger); }

.text-xs   { font-size: var(--font-size-xs); }
.text-sm   { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-lg   { font-size: var(--font-size-lg); }
.text-xl   { font-size: var(--font-size-xl); }
.text-2xl  { font-size: var(--font-size-2xl); }

.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }
.font-extrabold{ font-weight: 800; }

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }

.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }

.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.flex-1       { flex: 1; }

.w-full  { width: 100%; }
.hidden  { display: none !important; }

/* Pastikan form-error tidak makan space saat hidden */
.form-error.hidden { margin: 0; padding: 0; }

/* ============================================================
   ANIMASI MASUK (page load)
   ============================================================ */
@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-up {
    animation: fade-up var(--transition-normal) ease both;
}

.animate-delay-1 { animation-delay: 50ms; }
.animate-delay-2 { animation-delay: 100ms; }
.animate-delay-3 { animation-delay: 150ms; }
.animate-delay-4 { animation-delay: 200ms; }

/* ============================================================
   SAFE AREA (iPhone notch support)
   ============================================================ */
.safe-top    { padding-top: env(safe-area-inset-top, 0); }
.safe-bottom { padding-bottom: env(safe-area-inset-bottom, 0); }

/* ============================================================
   RESPONSIVE — di desktop tetap terpusat seperti mobile app
   ============================================================ */
@media (min-width: 481px) {
    body {
        background-color: var(--color-slate-300);
    }

    .app-shell {
        box-shadow: 0 0 60px 0 rgb(0 0 0 / 0.15);
    }

    .bottom-nav {
        border-radius: 0;
    }
}

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

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

/* ============================================================
   CAROUSEL
   ============================================================ */
#carousel-track {
    display: flex;
    gap: 12px;
    padding: 0 var(--space-5);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
}

#carousel-track::-webkit-scrollbar {
    display: none;
}

.carousel-slide {
    flex: 0 0 87%;
    scroll-snap-align: start;
    border-radius: 18px;
    padding: var(--space-5);
    position: relative;
    overflow: hidden;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.carousel-slide__deco {
    position: absolute;
    top: -30px;
    right: -30px;
    width: 130px;
    height: 130px;
    background: rgba(255, 255, 255, 0.09);
    border-radius: 50%;
    pointer-events: none;
}

.carousel-slide__deco2 {
    position: absolute;
    bottom: -20px;
    right: 60px;
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 50%;
    pointer-events: none;
}

.carousel-slide__badge {
    display: inline-flex;
    align-items: center;
    font-size: 9px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 3px 9px;
    border-radius: 20px;
    font-weight: 700;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
    align-self: flex-start;
}

.carousel-slide__title {
    font-size: 16px;
    font-weight: 800;
    color: white;
    line-height: 1.3;
    letter-spacing: -0.01em;
    margin-bottom: 5px;
}

.carousel-slide__desc {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.78);
    line-height: 1.6;
}

/* Dot indicator */
.carousel-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    margin-top: 12px;
    padding: 0 var(--space-5);
}

.carousel-dot {
    height: 6px;
    border-radius: 3px;
    background: var(--color-slate-300);
    transition: width 0.3s ease, background 0.3s ease;
    cursor: pointer;
    width: 6px;
}

.carousel-dot.active {
    width: 20px;
    background: var(--color-primary-600);
}
