/* ============================================================
   MIKU Store — Responsive & UI Polish Patch (style-responsive.css)
   Loaded AFTER style.css to safely override specific rules.
   Tidak mengubah logika JS atau backend.
   ============================================================ */

/* === 1. GLOBAL: Font, Overflow, Box-sizing === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.25);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
}

html {
  box-sizing: border-box;
}
*, *::before, *::after {
  box-sizing: inherit;
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  overflow-x: hidden;
  max-width: 100vw;
}

/* === 2. CONTAINER === */
.container {
  width: 94%;
  max-width: 1180px;
  margin-inline: auto;
}

/* === 3. HEADER: More compact on desktop === */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg-dark);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.header-container {
  height: 56px;
  padding: 0 0.75rem;
}

.logo {
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
}

.header-btn {
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

/* === 4. HERO SECTION: tidak terlalu dominan === */
.hero-section {
  margin: 1rem 0 1.25rem;
}

.hero-placeholder {
  height: clamp(140px, 20vw, 240px);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.hero-placeholder img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* === 5. CONTENT SECTIONS: lebih compact === */
.content-section {
  margin-bottom: 1.75rem;
}

.content-section h2 {
  font-size: clamp(1rem, 2.5vw, 1.35rem);
  margin-bottom: 0.85rem;
}

/* === 6. PRODUCT GRID & CARDS === */
.product-grid {
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
}

.product-card {
  height: clamp(150px, 18vw, 180px);
  border-radius: var(--radius-md);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.product-card:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 6px 20px rgba(236,72,153,0.2);
}

.product-card img {
  height: clamp(80px, 10vw, 110px);
  border-radius: var(--radius-sm);
}

/* === 7. FOOTER: lebih compact === */
footer {
  padding: 1rem 0;
}

.footer-links {
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* === 8. CARD global === */
.card {
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

/* === 9. MODAL: max-height + internal scroll safe === */
.modal-content {
  border-radius: var(--radius-md);
  max-height: min(calc(100vh - 2rem), 640px);
  overflow-y: auto;
  padding: 1.5rem;
}

/* === 10. PRICELIST / COMPARE-PRICES PAGE ===
   KRITIS: sidebar/list game TIDAK BOLEH ikut horizontal scroll.
   Hanya .table-container yang boleh scroll horizontal.
*/

/* Container utama: flex column on mobile, row on desktop */
.pricelist-container {
  overflow-x: visible !important; /* OVERRIDE: hapus overflow-x: auto dari parent */
  flex-wrap: nowrap;
}

/* Desktop layout */
@media (min-width: 769px) {
  .pricelist-container {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 1.5rem;
  }

  .pricelist-container .game-selector {
    flex: 0 0 240px;
    width: 240px;
    max-width: 240px;
    position: sticky;
    top: 5rem;
    min-height: auto;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
  }

  .pricelist-container .dashboard-content {
    flex: 1;
    min-width: 0; /* PENTING: cegah flex child overflow */
  }
}

/* Mobile layout: stack vertically */
@media (max-width: 768px) {
  .pricelist-container {
    flex-direction: column !important;
    overflow-x: visible !important; /* TIDAK ADA overflow-x di parent */
  }

  .pricelist-container .game-selector {
    position: static !important;
    left: auto !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    transform: none !important;
    transition: none !important;
    z-index: auto !important;
    margin-bottom: 1rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background-color: var(--bg-surface);
    box-shadow: var(--shadow-sm);
  }

  .pricelist-container .dashboard-content {
    min-width: 0;
    width: 100%;
  }
}

/* Table scroll hanya pada .table-container, BUKAN parent layout */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.modern-table-wrapper {
  overflow: visible; /* biarkan inner .table-container yang handle scroll */
  max-width: 100%;
}

.modern-table-wrapper .table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Tabel bisa lebih lebar dari kontainer, tapi scrollnya terbatas di wrapper */
table {
  min-width: max-content; /* membolehkan tabel lebih lebar dari layar */
}

/* === 11. DASHBOARD & ADMIN SIDEBAR === */
.dashboard-container,
.admin-page-container {
  gap: 1.5rem;
}

.sidebar,
.admin-sidebar {
  border-radius: var(--radius-md);
}

@media (max-width: 768px) {
  .dashboard-container,
  .admin-page-container {
    margin-top: 1rem;
  }

  /* table di dalam dashboard jangan menyebabkan horizontal scroll halaman */
  .dashboard-content .table-container,
  .admin-content .table-container {
    overflow-x: auto;
    max-width: 100%;
  }
}

/* === 12. ADMIN MASTER-DETAIL: tidak overflow === */
.admin-master-detail {
  grid-template-columns: minmax(0, 40%) minmax(0, 1fr);
  width: 100%;
}

.master-list,
.detail-list {
  min-width: 0; /* override min-width: 350px yang menyebabkan overflow */
}

@media (max-width: 768px) {
  .admin-master-detail {
    grid-template-columns: 1fr;
  }
  .admin-forms-container {
    flex-direction: column;
  }
  .admin-form {
    min-width: 0;
  }
}

/* === 13. PRODUCT ORDER PAGE === */
.order-page-wrapper {
  max-width: min(920px, 100%);
  margin-inline: auto;
}

.order-form-grid {
  gap: 0.75rem;
}

@media (max-width: 600px) {
  .order-form-grid {
    grid-template-columns: 1fr;
  }
}

/* === 14. GAME INFO on product page === */
#game-info img {
  width: clamp(70px, 12vw, 100px);
  height: clamp(70px, 12vw, 100px);
}

/* === 15. BALANCE AMOUNT — tidak terlalu besar di mobile === */
.balance-amount {
  font-size: clamp(1.5rem, 5vw, 2.5rem);
}

/* === 16. BUTTONS — proper tap target === */
button,
.header-btn,
.edit-btn,
.topup-btn,
.order-button,
.btn-submit-deposit,
.approve-btn {
  min-height: 40px;
  cursor: pointer;
}

/* === 17. FORM INPUTS — proper tap target === */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="datetime-local"],
select,
textarea {
  min-height: 42px;
  font-size: 1rem;
}

/* === 18. DEPOSIT WRAPPER — full width on mobile === */
.deposit-wrapper,
.mutasi-wrapper,
.main-wrapper {
  max-width: min(800px, 100%);
  margin: 1.5rem auto;
  padding: 0 0.5rem;
  box-sizing: border-box;
}

/* === 19. INVOICE === */
#invoice-details-container .card {
  overflow-wrap: break-word;
  word-break: break-word;
}

/* === 20. STATUS BADGES === */
.status-badge,
.badge {
  white-space: nowrap;
}

/* === 21. SEARCH INPUT pada header — tidak overflow === */
.search-container {
  max-width: min(450px, 100%);
  width: 100%;
}

#search-input {
  font-size: 0.9rem;
}

/* === 22. NOTIFICATION PANEL — tidak melebar keluar layar === */
.notification-panel {
  max-width: calc(100vw - 2rem);
  right: 0;
}

/* === 23. TOAST — safe on mobile === */
.toast {
  max-width: calc(100vw - 2rem);
  right: 1rem;
  left: 1rem;
  text-align: center;
}

@media (min-width: 600px) {
  .toast {
    left: auto;
    max-width: 360px;
  }
}

/* === 24. SIDEBAR NAV LINKS — tidak wrap aneh === */
.sidebar-nav a {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* === 25. PRICELIST SEARCH WRAPPER INSIDE SIDEBAR === */
.pricelist-search-wrapper {
  padding: 0;
  margin-bottom: 0.75rem;
}

#game-search-input,
#game-validate-search-input,
#game-selector-dropdown {
  width: 100%;
  box-sizing: border-box;
  max-width: 100%;
}

/* === 26. COMPARE CARD === */
.compare-card {
  overflow: hidden; /* Pastikan tidak meluber */
}

.compare-header h3 {
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  word-break: break-word;
}

/* === 27. MOBILE-SPESIFIK TAMBAHAN === */
@media (max-width: 480px) {
  .product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }

  .product-card {
    height: 140px;
    padding: 0.5rem;
  }

  .product-card img {
    height: 72px;
  }

  .hero-placeholder {
    height: clamp(120px, 40vw, 160px);
    border-radius: var(--radius-md);
  }

  .header-btn {
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
  }

  .card {
    padding: 0.9rem;
  }

  .modal-content {
    padding: 1rem;
    width: 96%;
    max-height: calc(100dvh - 1rem);
  }

  .confirmation-actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  .confirmation-actions .order-button,
  .confirmation-actions .edit-btn {
    width: 100%;
  }

  .balance-amount {
    font-size: 1.6rem;
  }

  .footer-links {
    gap: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }
}

/* === 28. TABLET (769px - 1024px) === */
@media (min-width: 769px) and (max-width: 1024px) {
  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .pricelist-container .game-selector {
    flex: 0 0 210px;
    width: 210px;
  }
}

/* === 29. ADMIN TABLE pada mobile — hanya wrapper scroll === */
@media (max-width: 768px) {
  .admin-content .table-container table,
  .dashboard-content .table-container table {
    white-space: nowrap;
    min-width: 500px;
  }
}

/* === 30. SMOOTH TRANSITIONS === */
.product-card,
.product-card-selectable,
.sidebar-nav a,
.header-btn,
button {
  transition: all 0.18s ease;
}

/* === 31. GAME SELECTOR DROPDOWN full-width on mobile === */
@media (max-width: 768px) {
  .game-selector-form {
    flex-direction: column;
  }
  .game-selector-form input,
  .game-selector-form select {
    min-width: 0;
    width: 100%;
  }
}

/* === 32. FORM ROWS wrapping === */
@media (max-width: 480px) {
  .form-row-container {
    flex-direction: column;
    align-items: stretch;
  }
  .form-row-container button {
    width: 100%;
  }
  .promo-form-container {
    flex-direction: column;
  }
  .promo-form-container button {
    width: 100%;
  }
}
