/* ================================================================
   MOBILE RESPONSIVE CSS – Koperasi Pinjaman Mandiri Jaya
   Mobile-first, covers: Landing · Admin Panel · Portal Nasabah
   Import AFTER style.css / admin.css / components.css / nasabah.css
   ================================================================ */

/* ================================================================
   BASE MOBILE UTILITIES
   ================================================================ */
:root {
  --touch-target: 44px;       /* minimum touch target (Apple HIG) */
  --mobile-pad:   16px;
  --mobile-pad-sm: 12px;
}

/* Prevent horizontal overflow everywhere */
html, body { max-width: 100%; overflow-x: hidden; }

/* Smooth tap highlight removal */
* { -webkit-tap-highlight-color: transparent; }

/* Better touch inputs */
input, select, textarea, button {
  -webkit-appearance: none;
  touch-action: manipulation;
  font-size: 16px !important; /* prevent iOS zoom on focus */
}

/* Readable font sizes on small screens */
@media (max-width: 480px) {
  html { font-size: 14px; }
}

/* ================================================================
   ①  LANDING PAGE  (index.php)
   ================================================================ */

/* ── Navbar ── */
@media (max-width: 768px) {
  #navbar .nav-inner    { padding: 0 var(--mobile-pad); height: 60px; }
  .logo-text .name      { font-size: 0.9rem; }
  .logo-text .tagline   { font-size: 0.58rem; }
  .logo-icon            { width: 38px; height: 38px; font-size: 1.1rem; border-radius: 10px; }

  .nav-links, .nav-cta  { display: none; }
  .nav-toggle           { display: flex; }

  body.nav-open .nav-links,
  body.nav-open .nav-cta {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 60px; left: 0; right: 0;
    background: rgba(27,67,50,0.98);
    backdrop-filter: blur(20px);
    padding: 20px var(--mobile-pad);
    gap: 6px;
    z-index: 999;
    border-top: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    animation: slideDown 0.25s ease;
  }
  @keyframes slideDown {
    from { opacity:0; transform:translateY(-10px); }
    to   { opacity:1; transform:translateY(0); }
  }
  body.nav-open .nav-links a {
    padding: 13px 18px;
    border-radius: 12px;
    font-size: 0.95rem;
    min-height: var(--touch-target);
    display: flex; align-items: center;
  }
  body.nav-open .nav-cta {
    padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,0.08);
    margin-top: 6px;
  }
  body.nav-open .nav-cta .btn {
    justify-content: center;
    min-height: var(--touch-target);
    font-size: 0.95rem;
  }
}

/* ── Hero ── */
@media (max-width: 992px) {
  #hero { padding-top: 60px; }
  .hero-grid { grid-template-columns: 1fr; gap: 0; text-align: center; }
  .hero-visual { display: none; }
  .hero-label { justify-content: center; }
  .hero-desc  { margin: 0 auto 36px; max-width: 520px; }
  .hero-actions { justify-content: center; }
  .hero-stats { justify-content: center; gap: 28px; }
  .hero-title { font-size: clamp(2rem, 7vw, 3rem); }
}

@media (max-width: 600px) {
  #hero { padding: 40px 0 56px; }
  .hero-title { font-size: 2rem; }
  .hero-desc  { font-size: 0.95rem; }
  .hero-actions { flex-direction: column; align-items: center; }
  .hero-actions .btn { width: 100%; max-width: 320px; justify-content: center; min-height: var(--touch-target); }
  .hero-stats { gap: 20px; flex-wrap: wrap; justify-content: center; }
  .stat-num   { font-size: 1.8rem; }
}

/* ── Sections ── */
@media (max-width: 992px) {
  .section-pad { padding: 72px 0; }
  .about-grid  { grid-template-columns: 1fr; }
  .about-visual{ display: none; }
  .vm-grid     { grid-template-columns: 1fr; gap: 20px; }
  .services-grid { grid-template-columns: 1fr 1fr; gap: 16px; }
  .principles-wrap { grid-template-columns: 1fr; gap: 40px; }
  .principles-left .section-title,
  .principles-left .divider,
  .principles-left p { text-align: center; }
  .principles-left .divider { margin: 16px auto 24px; }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 32px; }
}

@media (max-width: 600px) {
  .section-pad    { padding: 56px 0; }
  .container      { padding: 0 var(--mobile-pad); }
  .section-title  { font-size: 1.8rem; }
  .services-grid  { grid-template-columns: 1fr; gap: 14px; }
  .principle-cards{ grid-template-columns: 1fr; gap: 12px; }
  .vm-card        { padding: 28px 22px; }
  .service-card   { padding: 28px 22px; }
  .cta-actions    { flex-direction: column; align-items: center; }
  .cta-actions .btn { width: 100%; max-width: 300px; justify-content: center; min-height: var(--touch-target); }
  .footer-grid    { grid-template-columns: 1fr; gap: 24px; }
  .footer-bottom  { flex-direction: column; text-align: center; gap: 8px; }
  #scrollTop      { bottom: 20px; right: 16px; width: 42px; height: 42px; }
}

/* ── Section: Prinsip ── */
@media (max-width: 480px) {
  .prin-card { padding: 20px 18px; }
  .service-card { padding: 24px 18px; }
}

/* ================================================================
   ②  ADMIN LOGIN  (admin/login.php)
   ================================================================ */
@media (max-width: 600px) {
  .login-wrap   { max-width: 100%; padding: 0 4px; }
  .login-card   { padding: 28px 22px; border-radius: 18px; }
  .login-logo h1 { font-size: 1.3rem; }
  .login-logo .logo-icon { width: 56px; height: 56px; font-size: 1.5rem; border-radius: 16px; }
  .back-link    { margin-top: 16px; }
  .demo-info    { font-size: 0.75rem; }
  body > .login-wrap { margin: 16px auto; }
}

/* ================================================================
   ③  ADMIN PANEL – SIDEBAR + TOPBAR
   ================================================================ */
@media (max-width: 1024px) {
  .sidebar        { width: 240px; }
  .main-content   { margin-left: 240px; }
}

/* ── Sidebar slide-in ── */
@media (max-width: 768px) {
  /* Sidebar selalu tertutup di mobile */
  .sidebar {
    position: fixed !important;
    top: 0; left: 0; bottom: 0;
    z-index: 300;
    transform: translateX(-100%) !important;
    width: 260px !important;
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1) !important;
    box-shadow: none;
  }
  /* Buka sidebar */
  .sidebar.open {
    transform: translateX(0) !important;
    box-shadow: 8px 0 40px rgba(0,0,0,0.35) !important;
  }

  .main-content   { margin-left: 0 !important; }
  .sidebar-toggle { display: flex !important; align-items: center; justify-content: center; min-height: 36px; min-width: 36px; }
  .topbar         { padding: 0 var(--mobile-pad) !important; height: 58px !important; }
  .topbar-date    { display: none !important; }
  .topbar-btn     { width: 36px !important; height: 36px !important; }
  .page-title-bar h1 { font-size: 0.95rem !important; }
  .page-title-bar .breadcrumb-bar { font-size: 0.68rem !important; }

  /* Overlay */
  .sidebar-overlay {
    display: none;
    position: fixed !important;
    inset: 0;
    z-index: 299;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
  }
  .sidebar-overlay.show { display: block !important; }

  /* Sidebar nav links – bigger touch targets */
  .nav-link-item { padding: 12px 14px !important; min-height: 44px !important; font-size: 0.9rem !important; }
  .sidebar-brand { height: 58px !important; }
  .admin-layout  { display: block !important; }
}

/* ── Stats Grid ── */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-row.col-3-1 { grid-template-columns: 1fr; }
  .dash-row.col-1-2 { grid-template-columns: 1fr; }
  .dash-row.col-2   { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-card  { padding: 16px 14px; }
  .stat-icon  { width: 42px; height: 42px; font-size: 1.1rem; border-radius: 11px; }
  .stat-value { font-size: 1.4rem; }
  .stat-label { font-size: 0.66rem; }
  .stat-change{ font-size: 0.66rem; }
  .page-content { padding: var(--mobile-pad); }
}

@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ── Welcome Banner ── */
@media (max-width: 768px) {
  .welcome-banner { flex-direction: column; align-items: flex-start; padding: 20px; gap: 14px; }
  .wb-actions     { flex-wrap: wrap; gap: 8px; }
  .wb-btn         { padding: 8px 14px; font-size: 0.78rem; min-height: var(--touch-target); }
  .wb-text h2     { font-size: 1.15rem; }
  .wb-text p      { font-size: 0.8rem; }
}

/* ── Quick Actions ── */
@media (max-width: 768px) {
  .quick-actions { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .quick-action-btn { padding: 14px 6px; }
  .qa-icon { width: 36px; height: 36px; font-size: 1rem; }
  .quick-action-btn span { font-size: 0.68rem; }
}
@media (max-width: 480px) {
  .quick-actions { grid-template-columns: 1fr 1fr; }
}

/* ── Tables – horizontal scroll on mobile ── */
@media (max-width: 768px) {
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap::after {
    content: '';
    position: absolute; right: 0; top: 0; bottom: 0;
    width: 24px;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.8));
    pointer-events: none;
  }
  .admin-table { min-width: 580px; }
  .admin-table thead th { padding: 8px 12px; font-size: 0.65rem; }
  .admin-table td       { padding: 10px 12px; font-size: 0.8rem; }
  .tbl-name  { font-size: 0.82rem; }
  .tbl-sub   { font-size: 0.68rem; }
  .tbl-avatar{ width: 28px; height: 28px; font-size: 0.72rem; }
}

/* ── Panel headers ── */
@media (max-width: 600px) {
  .panel-header { padding: 14px 16px 10px; flex-wrap: wrap; gap: 8px; }
  .panel-body   { padding: 14px 16px; }
  .panel-title  { font-size: 0.85rem; }
  .panel-action { font-size: 0.72rem; padding: 4px 10px; }
}

/* ── Filter bar ── */
@media (max-width: 768px) {
  .filter-bar { flex-wrap: wrap; gap: 8px; }
  .search-input-wrap { max-width: 100%; flex: 1 1 180px; }
  .filter-select { min-width: 110px; font-size: 0.8rem; }
  .search-input  { font-size: 0.82rem !important; }
}

/* ── Page topbar actions ── */
@media (max-width: 600px) {
  .page-topbar { flex-direction: column; align-items: flex-start; }
  .page-topbar-actions { width: 100%; }
  .page-topbar-actions .btn-add,
  .page-topbar-actions .btn-export { flex: 1; justify-content: center; }
  .btn-add   { min-height: var(--touch-target); font-size: 0.82rem; }
  .btn-export{ min-height: var(--touch-target); font-size: 0.82rem; }
}

/* ── Form ── */
@media (max-width: 600px) {
  .form-row-2 { grid-template-columns: 1fr; gap: 0; }
  .form-row-3 { grid-template-columns: 1fr; gap: 0; }
  .form-panel-body { padding: 18px; }
  .form-actions { flex-direction: column-reverse; gap: 8px; }
  .btn-submit, .btn-cancel {
    width: 100%; justify-content: center;
    min-height: var(--touch-target);
    font-size: 0.9rem;
  }
}

/* ── Modals ── */
@media (max-width: 600px) {
  .modal-dialog { margin: 12px; max-width: calc(100% - 24px) !important; }
  .modal-custom .modal-header { padding: 16px 18px; border-radius: 14px 14px 0 0; }
  .modal-custom .modal-body   { padding: 18px; }
  .modal-custom .modal-footer { padding: 14px 18px; flex-wrap: wrap; gap: 8px; }
  .modal-custom .modal-title  { font-size: 0.9rem; }
  .modal-custom .btn-submit,
  .modal-custom .btn-cancel   { flex: 1; justify-content: center; min-height: var(--touch-target); }
}

/* ── Detail views (buku besar, laporan) ── */
@media (max-width: 600px) {
  .detail-grid { grid-template-columns: 1fr; }
  .detail-item { grid-template-columns: 110px 1fr; }
}

/* ── Chart container ── */
@media (max-width: 600px) {
  .chart-container { height: 200px; }
}

/* ── Summary list ── */
@media (max-width: 480px) {
  .summary-item { padding: 10px 12px; gap: 10px; }
  .si-name      { font-size: 0.8rem; }
  .si-sub       { font-size: 0.68rem; }
  .si-val       { font-size: 0.8rem; }
  .si-date      { font-size: 0.66rem; }
}

/* ── Pagination ── */
@media (max-width: 600px) {
  .pagination-wrap { flex-direction: column; align-items: center; gap: 10px; padding: 12px 16px; }
  .pg-btn { width: 36px; height: 36px; font-size: 0.78rem; }
}

/* ── Dashboard specific ── */
@media (max-width: 768px) {
  .dash-row { gap: 14px; margin-bottom: 14px; }
  .activity-item { padding: 10px 0; gap: 10px; }
  .act-body p    { font-size: 0.8rem; }
  .act-time      { font-size: 0.66rem; }
  .principle-cards { grid-template-columns: 1fr; }
}

/* ── Laporan SHU ── */
@media (max-width: 768px) {
  .dash-row.col-2 { grid-template-columns: 1fr !important; }
}

/* ── Users page ── */
@media (max-width: 600px) {
  .admin-table { min-width: 480px; }
}

/* ================================================================
   ④  PORTAL NASABAH  (nasabah/*.php)
   ================================================================ */

/* ── Topnav nasabah ── */
@media (max-width: 600px) {
  .topnav-inner  { padding: 0 var(--mobile-pad); gap: 8px; }
  .nav-brand-text .name { font-size: 0.85rem; }
  .nav-brand-text .sub  { font-size: 0.55rem; }
  .nav-user-info { display: none; }     /* hide on tiny screen, avatar stays */
  .nav-logout    { padding: 6px 10px; font-size: 0.72rem; }
  .nav-logout i  { display: none; }
  .nav-avatar    { width: 32px; height: 32px; font-size: 0.82rem; }
}

/* ── Portal wrap ── */
@media (max-width: 768px) {
  .portal-wrap { padding: 16px var(--mobile-pad); }
}

/* ── Hero card nasabah ── */
@media (max-width: 768px) {
  .hero-card     { flex-direction: column; align-items: flex-start; padding: 20px; gap: 14px; }
  .hero-left h1  { font-size: 1.3rem; }
  .hero-left .meta { gap: 10px; }
  .hero-meta-item{ font-size: 0.72rem; }
  .hero-right    { text-align: left; }
  .hero-badge    { font-size: 0.75rem; padding: 6px 12px; }
}

/* ── Stat grid nasabah ── */
@media (max-width: 768px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .sc-icon   { width: 40px; height: 40px; font-size: 1.1rem; border-radius: 11px; margin-bottom: 10px; }
  .sc-label  { font-size: 0.65rem; }
  .sc-value  { font-size: 1.2rem; }
  .sc-sub    { font-size: 0.68rem; }
}
@media (max-width: 400px) {
  .stat-grid { grid-template-columns: 1fr; }
}

/* ── Content grid nasabah ── */
@media (max-width: 900px) {
  .content-grid { grid-template-columns: 1fr !important; }
}

/* ── Panel nasabah ── */
@media (max-width: 600px) {
  .panel-head  { padding: 13px 15px 10px; flex-wrap: wrap; gap: 6px; }
  .panel-body  { padding: 13px 15px; }
  .panel-title { font-size: 0.85rem; }
  .panel-link  { font-size: 0.72rem; padding: 4px 10px; }
}

/* ── Tagihan item ── */
@media (max-width: 600px) {
  .tagihan-item { padding: 11px 12px; gap: 10px; }
  .ti-no        { width: 32px; height: 32px; border-radius: 8px; font-size: 0.78rem; }
  .ti-jatuh     { font-size: 0.78rem; }
  .ti-nominal   { font-size: 0.85rem; }
  .ti-denda     { font-size: 0.65rem; }
  .ti-pinjaman  { font-size: 0.7rem; }
}

/* ── Riwayat item ── */
@media (max-width: 600px) {
  .riwayat-item { padding: 10px 0; gap: 10px; }
  .ri-icon      { width: 32px; height: 32px; border-radius: 8px; font-size: 0.9rem; }
  .ri-label     { font-size: 0.8rem; }
  .ri-sub       { font-size: 0.68rem; }
  .ri-nominal   { font-size: 0.82rem; }
  .ri-tgl       { font-size: 0.65rem; }
}

/* ── Pinjaman progress ── */
@media (max-width: 600px) {
  .pp-item { padding: 13px; }
  .pp-no   { font-size: 0.75rem; }
  .pp-pokok{ font-size: 0.72rem; }
  .pp-footer{ font-size: 0.68rem; }
}

/* ── Notifikasi ── */
@media (max-width: 600px) {
  .notif-item h4 { font-size: 0.8rem; }
  .notif-item p  { font-size: 0.72rem; }
  .notif-time    { font-size: 0.62rem; }
  .notif-icon    { width: 32px; height: 32px; border-radius: 8px; font-size: 0.9rem; }
}

/* ── Jadwal table (nasabah) ── */
@media (max-width: 768px) {
  .portal-wrap table { min-width: 640px; font-size: 0.78rem; }
  .portal-wrap table th { padding: 8px 12px; font-size: 0.62rem; }
  .portal-wrap table td { padding: 10px 12px; }
}

/* ── Login nasabah ── */
@media (max-width: 600px) {
  .login-wrap > div:first-child { padding: 0 4px; }
  .login-card { padding: 26px 20px; border-radius: 18px; }
  .login-logo h1 { font-size: 1.25rem; }
}

/* ── Riwayat & pinjaman nasabah ── */
@media (max-width: 600px) {
  .portal-wrap > div[style*="grid"] { gap: 12px; }
}

/* ================================================================
   ⑤  GLOBAL TOUCH IMPROVEMENTS
   ================================================================ */

/* Larger touch targets for buttons */
@media (max-width: 768px) {
  .btn, .btn-add, .btn-export, .btn-submit, .btn-cancel,
  .btn-icon, .nav-logout, .wb-btn, .panel-action,
  .pg-btn, .filter-select, .search-input {
    min-height: 40px;
  }
  .btn-icon { width: 36px; height: 36px; font-size: 0.9rem; }

  /* Card hover effects off on touch – use :active instead */
  .stat-card:hover, .service-card:hover, .vm-card:hover,
  .prin-card:hover, .quick-action-btn:hover, .summary-item:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
  }
  .stat-card:active     { transform: scale(0.98); }
  .quick-action-btn:active{ background: var(--green-pale); }

  /* Alert auto-dismiss stays visible longer on mobile */
  .alert-auto { transition: opacity 0.5s ease 5s; }
}

/* ── iOS safe area (notch / home indicator) ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .sidebar   { padding-bottom: env(safe-area-inset-bottom); }
  .topnav    { padding-top: env(safe-area-inset-top); }
  #scrollTop { bottom: calc(24px + env(safe-area-inset-bottom)); }
}

/* ── Print: hide mobile chrome ── */
@media print {
  .sidebar, .topbar, .page-topbar, .filter-bar,
  .sidebar-overlay, .pagination-wrap,
  .topnav, #navbar, #scrollTop { display: none !important; }
  .main-content  { margin-left: 0 !important; }
  .page-content  { padding: 0 !important; }
  .portal-wrap   { padding: 0 !important; }
  body, .admin-layout { background: #fff !important; }
}

/* ================================================================
   ⑥  BOTTOM NAB BAR  (mobile admin – shows on ≤600px)
   ================================================================ */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 600px) {
  /* Push content above bottom nav */
  .main-content { padding-bottom: 64px; }
  .portal-wrap  { padding-bottom: 80px; }

  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    background: var(--green-dark, #1B4332);
    border-top: 1px solid rgba(255,255,255,0.10);
    z-index: 300;
    align-items: center;
    justify-content: space-around;
    padding: 0 4px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.20);
  }
  .mobile-bottom-nav a,
  .mobile-bottom-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex: 1;
    height: 100%;
    background: none;
    border: none;
    color: rgba(255,255,255,0.55);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 0.6rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
    border-radius: 0;
    padding: 8px 4px;
    min-height: var(--touch-target);
  }
  .mobile-bottom-nav a i,
  .mobile-bottom-nav button i {
    font-size: 1.15rem;
    line-height: 1;
  }
  .mobile-bottom-nav a.active,
  .mobile-bottom-nav button.active {
    color: var(--gold, #E9B94A);
    background: rgba(255,255,255,0.06);
    border-radius: 12px;
  }
  .mobile-bottom-nav a:active,
  .mobile-bottom-nav button:active {
    background: rgba(255,255,255,0.08);
  }
}

/* Safe area for bottom nav */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 600px) {
    .mobile-bottom-nav { height: calc(60px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
    .main-content      { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
    .portal-wrap       { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  }
}

/* ================================================================
   ⑦  SWIPE INDICATOR  (table scroll hint on mobile)
   ================================================================ */
@media (max-width: 768px) {
  .table-scroll-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: var(--text-light, #6B8F72);
    margin-bottom: 8px;
    font-style: italic;
  }
  .table-scroll-hint i { font-size: 0.85rem; }
}

/* ================================================================
   ⑧  INPUT DATE / SELECT – mobile friendly
   ================================================================ */
@media (max-width: 768px) {
  input[type="date"],
  input[type="number"],
  input[type="text"],
  input[type="password"],
  input[type="email"],
  textarea,
  select {
    font-size: 16px !important; /* prevent zoom */
    border-radius: 10px;
  }
  .form-control-custom { padding: 12px 14px; }
  .search-input        { padding: 10px 14px 10px 36px; }
  .filter-select       { padding: 10px 14px; }
}

/* ================================================================
   ⑨  LAPORAN PAGES – mobile table
   ================================================================ */
@media (max-width: 768px) {
  /* Jurnal, Buku Besar, Rekap Angsuran */
  #tblJurnal, #tblRekap, #tblAngsuran, #tblPembayaran, #tblAnggota, #tblPinjaman {
    min-width: 600px;
    font-size: 0.78rem;
  }
  /* SHU layout */
  .dash-row.col-2 { grid-template-columns: 1fr; }
}

/* ================================================================
   ⑩  SCROLL TO TOP – mobile position
   ================================================================ */
@media (max-width: 600px) {
  #scrollTop { bottom: 76px; right: 12px; width: 40px; height: 40px; font-size: 1rem; }
}
