/* ==========================================================================
   smartPAY Premium CSS V5 - Fully Integrated Desktop & Mobile Layout
   ========================================================================== */

:root {
  --yellow: #ffd21f;
  --yellow2: #ffb800;
  --bg: #f8fafc;        /* Warna latar segar & modern */
  --ink: #0f172a;       /* Slate gelap premium untuk pembacaan jelas */
  --muted: #64748b;     /* Kelabu lembut untuk info sekunder */
  --card: #ffffff;
  --dark: #0f172a;
  --line: rgba(15, 23, 42, 0.08);
  --green: #10b981;
  --blue: #3b82f6;
  --shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.03), 0 8px 10px -6px rgba(15, 23, 42, 0.03);
  --radius: 20px;       /* Radius bucu yang moden dan kemas */
}

* {
  box-sizing: border-box;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a {
  text-decoration: none;
  color: inherit;
}

body {
  padding-top: 74px; /* Jarak untuk desktop fixed header */
}

/* ==========================================================================
   NAVIGATION & HEADER LAYER
   ========================================================================== */

/* Header Desktop */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 999;
  height: 74px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.brand-bubbles {
  position: relative;
  width: 47px;
  height: 36px;
  display: inline-block;
}

.brand-bubbles i {
  position: absolute;
  width: 31px; height: 31px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-style: normal;
  font-weight: 700;
}
.brand-bubbles i:nth-child(1) { left: 0; top: 2px; background: var(--dark); color: #fff; }
.brand-bubbles i:nth-child(2) { left: 16px; top: 8px; background: var(--yellow); color: var(--dark); }

.desktop-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.desktop-nav::-webkit-scrollbar { display: none; }

.desktop-nav a {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}
.desktop-nav a.active, .desktop-nav a:hover {
  background: rgba(15, 23, 42, 0.05);
  color: var(--ink);
}

.account-area {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.account-area span { color: var(--muted); }
.account-area a {
  background: var(--dark);
  color: #fff;
  padding: 8px 16px;
  border-radius: 999px;
}
.account-area a:hover { background: #1e293b; }

/* Bottom Nav Mobile Placeholder (Hidden on Desktop) */
.mobile-bottom-nav { display: none; }

/* ==========================================================================
   SISTEM GRID & RESPONSIVE LAYOUT
   ========================================================================== */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 120px;
}

/* Struktur Grid Utama (Auto Adaptable) */
.two, .two-col, .dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  align-items: start;
}

/* Asymmetric Grid khusus untuk Desktop besar (Kiri Luas, Kanan Sempit) */
@media (min-width: 901px) {
  .two {
    grid-template-columns: 1.6fr 1fr;
  }
  /* Halaman transaksi/payment mengekalkan kestabilan 50-50 */
  .main:has(form) .two,
  .main:has(.qrbox) .two {
    grid-template-columns: 1fr 1fr;
  }
}

/* Inner Page Header (Topbar) */
.topbar {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}
.topbar .title h2, h1, h2 {
  margin: 0;
  font-size: 32px;
  letter-spacing: -0.8px;
  font-weight: 800;
  line-height: 1.2;
}
.topbar .title p, p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

/* ==========================================================================
   UKURAN KAD, PANEL & STATS
   ========================================================================== */

.panel, .card, .quick-section, .featured-section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}
.panel h3, .section-head h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.section-head a {
  color: var(--blue);
  font-weight: 700;
  font-size: 14px;
}

/* Kad E-Wallet Premium (MAE Inspired) */
.hero-wallet, .merchant-hero {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #ffffff;
  border-radius: var(--radius);
  padding: 32px;
  position: relative;
  overflow: hidden;
  margin-bottom: 26px;
  border: none;
  box-shadow: 0 20px 40px -15px rgba(15, 23, 42, 0.3);
}
.hero-wallet:after {
  content: ""; position: absolute; right: -40px; bottom: -40px;
  width: 160px; height: 160px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.04); pointer-events: none;
}
.hero-wallet .eyebrow {
  font-size: 11px; color: var(--yellow); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
}
.hero-wallet h1 { color: #fff; font-size: 24px; margin: 12px 0 6px; font-weight: 700; }
.wallet-amount { font-size: 46px; font-weight: 800; letter-spacing: -1.5px; color: #fff; margin: 12px 0; }
.hero-wallet .view-link { color: rgba(255, 255, 255, 0.55); font-size: 13px; }

/* Admin Theme Custom Hero */
.admin-theme .hero-wallet {
  background: linear-gradient(135deg, #1e3a8a, #0f172a);
}

/* Quick Action Menu Grid */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.quick-item {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 8px; color: var(--ink); font-weight: 600; font-size: 13px;
}
.quick-item .icon {
  width: 58px; height: 58px; border-radius: 16px;
  background: #f1f5f9; border: 1px solid transparent;
  display: grid; place-items: center; font-size: 22px;
}
.quick-item:hover .icon {
  transform: translateY(-4px);
  border-color: var(--yellow);
  background: #fffdf0;
}
.quick-item.scan .icon { background: var(--yellow); color: var(--dark); }

/* Dashboard Platform Info Badges */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px; margin: 24px 0;
}
.stat {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.stat span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
.stat b { display: block; font-size: 26px; font-weight: 800; margin-top: 6px; letter-spacing: -0.5px; }

/* ==========================================================================
   UI UTILITY: FORM, TABLES & BADGES
   ========================================================================== */

/* Baris Senarai Transaksi (List Rows) */
.tx, .transaction-row, .list-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line);
}
.tx:last-child { border-bottom: none; }
.tx strong { display: block; font-size: 15px; font-weight: 600; }
.tx span { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }

.minus { color: #ef4444; font-weight: 700; }
.plus, .success, .positive { color: var(--green); font-weight: 700; }

/* Reka Bentuk Jadual (Tables) */
.table {
  width: 100%; border-collapse: collapse;
}
.table th {
  padding: 12px 14px; color: var(--muted); font-size: 13px;
  font-weight: 700; text-transform: uppercase; border-bottom: 2px solid var(--line); text-align: left;
}
.table td { padding: 16px 14px; border-bottom: 1px solid var(--line); font-size: 15px; }
.table tr:last-child td { border-bottom: none; }

/* Status Badges Pastel Premium */
.status {
  padding: 6px 14px; border-radius: 999px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; display: inline-block; letter-spacing: 0.05em;
}
.status.pending { background: #fef3c7; color: #b45309; }
.status.approved, .status.success { background: #d1fae5; color: #065f46; }
.status.rejected, .status.failed { background: #fee2e2; color: #991b1b; }

/* Butang & Borang (Inputs) */
.btn, button, input[type=submit] {
  min-height: 48px; border: 0; border-radius: 12px;
  background: #e2e8f0; color: var(--ink); font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 22px; cursor: pointer; font-size: 14px;
}
.btn.primary, .primary { background: var(--dark); color: #fff; }
.btn.primary:hover { background: #1e293b; }
.btn.secondary, .secondary { background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); }
.btn.secondary:hover { background: #f8fafc; }

.input, select, textarea {
  width: 100%; min-height: 48px; border: 1px solid #cbd5e1;
  border-radius: 12px; background: #fff; padding: 0 16px; font-size: 15px; color: var(--ink);
}
.input:focus, select:focus { border-color: var(--dark); outline: none; box-shadow: 0 0 0 3px rgba(15,23,42,0.05); }
.label { display: block; font-weight: 700; margin: 16px 0 8px; font-size: 14px; }

/* Notifikasi / Info Boxes (Fix Kontras Teks Malap) */
.notice {
  background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534;
  padding: 14px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; margin: 12px 0;
}
.panel p, .panel h3 + p, .panel .notice + p {
  color: var(--muted) !important; /* Force pembetulan untuk tulisan b9d6f2 sebelum ni */
}

/* QR Peniaga Showcase */
.qr-card { text-align: center; }
.qr-card img {
  width: 200px; max-width: 100%; border-radius: 16px;
  background: #fff; padding: 12px; border: 1px solid var(--line); box-shadow: var(--shadow);
}

/* Network Merchant Cards (network.php) */
.merchant-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px;
}
.merchant-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; display: flex; flex-direction: column; justify-content: space-between; text-align: center;
}

/* ==========================================================================
   OPTIMASI GLOBAL MOBILE LAYER (Media Queries)
   ========================================================================= */

@media (max-width: 900px) {
  body { padding-top: 0; padding-bottom: 84px; }
  
  .app-header {
    position: relative; height: 62px; padding: 0 16px;
    border-bottom: 1px solid var(--line); box-shadow: none; background: #fff;
  }
  .desktop-nav, .account-area { display: none; }
  
  .main { padding: 20px 16px 100px; }
  
  /* Reset Grid Menjadi 1 Kolom Penuh */
  .two, .two-col, .dashboard-grid {
    grid-template-columns: 1fr !important; gap: 16px;
  }
  
  /* Ejas Grid Statistik Ringkas Kedai/User */
  .stats { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat { padding: 14px; }
  .stat b { font-size: 20px; }
  
  /* Topbar bertukar susunan melintang ke menegak */
  .topbar { flex-direction: column; align-items: flex-start; gap: 12px; padding-bottom: 12px; }
  .topbar .btn { width: 100%; text-align: center; }
  .topbar .title h2 { font-size: 26px; }

  /* Jadual Bertukar Kepada Scrollable Pintar */
  .table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }

  /* NAVIGASI BOTTOM BAR MOBILE (MAE Style Premium) */
  .mobile-bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0;
    height: 74px; background: #ffffff; border-top: 1px solid var(--line);
    display: flex; align-items: center; justify-content: space-around;
    z-index: 999; box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.03);
  }
  .mobile-bottom-nav a {
    flex: 1; height: 74px; display: flex; align-items: center;
    justify-content: center; flex-direction: column; gap: 4px;
    color: var(--muted); font-weight: 600; font-size: 11px; text-transform: capitalize;
  }
  .mobile-bottom-nav a small { font-size: 11px; font-weight: 600; }
  .mobile-bottom-nav a.active { color: var(--dark); font-weight: 700; }
  
  /* FAB Tombol Scan QR Ditengah */
  .mobile-bottom-nav .scan-fab {
    height: 60px; max-width: 60px; transform: translateY(-16px);
    background: var(--dark); color: #fff; border-radius: 50%;
    box-shadow: 0 8px 25px rgba(15, 23, 42, 0.25);
  }
  .mobile-bottom-nav .scan-fab.active { color: var(--yellow); }
  .mobile-bottom-nav .scan-fab small { display: none; } /* Sorok teks "Scan" jika ikon/bentuk sudah bulat penuh */
  .mobile-bottom-nav .scan-fab::before {
    content: "📷"; font-size: 20px; /* Letak emoji scan sementara ganti kod ikon kosong */
  }
}

/* Optimasi Skrin Amat Kecil (cth: Phone lama) */
@media (max-width: 400px) {
  .quick-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .stats { grid-template-columns: 1fr; }
  .wallet-amount { font-size: 34px; }
}
