/* AKM POS - Mobile-First & Responsive UX Optimizations */

html {
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

body {
  overscroll-behavior-y: none;
  overflow-x: hidden;
}

button {
  touch-action: manipulation;
}

button, input, select, textarea, .btn {
  min-height: 44px;
}

/* Floating Cart Summary Bar on Mobile */
.floating-cart-bar {
  display: none;
}

/* Bottom Sheet Container */
.bottom-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 800;
  display: flex;
  align-items: flex-end;
  animation: fadeIn 0.15s ease-out;
}

.bottom-sheet-content {
  width: 100%;
  max-height: 90vh;
  max-height: 90dvh;
  background: #ffffff;
  border-radius: 24px 24px 0 0;
  padding: 16px 20px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
  animation: slideUpSheet 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
}

.sheet-drag-handle {
  width: 42px;
  height: 5px;
  background: #cbd5e1;
  border-radius: 99px;
  margin: 0 auto 14px;
  flex-shrink: 0;
}

@keyframes slideUpSheet {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* Mobile Nav Bar - Hidden on Desktop */
.mobile-nav {
  display: none;
}

/* Drawer Backdrop */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(3px);
  z-index: 95;
  animation: fadeIn 0.2s ease-out;
}

/* Responsive Breakpoints */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .app aside {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    width: min(84vw, 320px);
    height: 100vh;
    height: 100dvh;
    transform: translateX(-105%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 16px 0 40px rgba(15, 23, 42, 0.2);
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }

  .app aside.open {
    transform: translateX(0);
  }

  header.top-header {
    height: calc(62px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 16px 0;
  }

  .icon-btn-menu {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    background: #f1f5f9;
    color: var(--text);
  }

  .live-clock {
    display: none;
  }

  main.main-viewport {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }

  #content {
    padding: 16px 14px;
  }

  /* POS Mobile */
  .pos-layout {
    grid-template-columns: 1fr;
  }

  .cart-panel {
    display: none; /* In mobile, Cart is handled via Floating Bar & Bottom Sheet */
  }

  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .product-card {
    padding: 10px;
    gap: 8px;
  }

  .product-card-name {
    font-size: 12.5px;
  }

  .product-card-price {
    font-size: 14px;
  }

  /* Floating Cart Summary Bar */
  .floating-cart-bar {
    position: fixed;
    bottom: calc(64px + env(safe-area-inset-bottom));
    left: 12px;
    right: 12px;
    z-index: 70;
    background: linear-gradient(135deg, #0f766e, #115e59);
    color: #ffffff;
    border-radius: var(--radius-xl);
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 8px 24px rgba(15, 118, 110, 0.4);
    animation: slideUpToast 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
  }
  .floating-cart-bar:active {
    transform: scale(0.98);
  }
  .floating-cart-info {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .floating-cart-badge {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 13px;
  }
  .floating-cart-price {
    display: flex;
    flex-direction: column;
  }
  .floating-cart-price small {
    font-size: 11px;
    opacity: 0.85;
  }
  .floating-cart-price b {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.01em;
  }
  .floating-cart-cta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.18);
    padding: 7px 14px;
    border-radius: var(--radius-full);
  }

  /* Bottom Navigation Bar */
  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 75;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 18px rgba(15, 23, 42, 0.06);
  }

  .mobile-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 2px;
    min-height: 48px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
  }

  .mobile-nav-btn svg {
    width: 22px;
    height: 22px;
    stroke-width: 2;
  }

  .mobile-nav-btn.active {
    color: var(--primary);
    font-weight: 800;
  }

  .mobile-nav-btn.active svg {
    transform: translateY(-2px);
    stroke-width: 2.3;
  }

  /* Modals on Mobile: Bottom Sheets */
  .modal {
    padding: 0;
    align-items: flex-end;
  }

  .modal-card {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: 24px 24px 0 0;
    padding: 24px 18px calc(24px + env(safe-area-inset-bottom));
    animation: slideUpSheet 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .form-grid .full {
    grid-column: auto;
  }

  /* Dashboard mobile */
  .grid-kpi.modern {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .kpi-card {
    padding: 14px;
    gap: 10px;
  }
  .kpi-icon-wrap {
    width: 38px;
    height: 38px;
  }
  .kpi-data strong {
    font-size: 18px;
  }
  .dashboard-analytics-grid {
    grid-template-columns: 1fr;
  }

  /* Page Head mobile */
  .page-head {
    margin-bottom: 16px;
  }
  .page-head-title h1 {
    font-size: 20px;
  }
  .page-head-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  }
}

@media (max-width: 520px) {
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .product-card {
    padding: 8px;
  }
  .product-card-price {
    font-size: 13.5px;
  }
  .btn {
    padding: 8px 12px;
    font-size: 13px;
  }
  th, td {
    padding: 10px 12px;
  }
}
