/* ─────────────────────────────────────────────────────────────────────────
   ShopOS — Responsive POS Layout (Mobile, Tablet, Touch & Desktop)
   ───────────────────────────────────────────────────────────────────────── */

/* ── RTL/Print tweaks ────────────────────────────────────────────────────── */
.pos-layout .text-right {
  text-align: left !important;
}

/* By default, mobile tabs and floating catalog bar are hidden on Desktop / Wide screens */
.pos-mobile-tabs,
.pos-mobile-catalog-bottombar {
  display: none !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — POS Layout (Tablet ≤1024px)
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .pos-layout {
    grid-template-columns: 1fr 1.35fr;
    gap: 8px;
    padding: 8px;
    height: 100vh;
    height: 100dvh;
    box-sizing: border-box;
  }

  .pos-layout.catalog-expanded {
    grid-template-columns: 1fr 1.35fr;
  }

  .pos-layout.catalog-compact {
    grid-template-columns: 0.65fr 1.35fr;
  }

  .pos-layout.catalog-hidden {
    grid-template-columns: minmax(0, 1fr);
  }

  .pos-layout .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(115px, 1fr));
    gap: 8px;
  }

  .pos-layout .product-card {
    padding: 10px 8px;
  }

  .pos-summary-row {
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
  }

  .summary-box {
    padding: 4px 6px;
  }

  .summary-label {
    font-size: 10px;
  }

  .summary-value {
    font-size: 12.5px;
  }

  .pos-scan-row {
    gap: 6px;
    padding: 4px 8px;
  }

  .giant-total-text {
    font-size: 22px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — POS Layout (Mobile ≤768px)
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── 1. Mobile Segmented Tab Bar ── */
  .pos-mobile-tabs {
    display: flex !important;
    width: 100%;
    gap: 6px;
    padding: 8px 10px;
    background: var(--card-bg, #12122a);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 60;
    box-sizing: border-box;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  .pos-mobile-tab-btn {
    flex: 1;
    min-height: 42px;
    border-radius: var(--r-md, 10px);
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-2);
    font-family: 'Cairo', sans-serif;
    font-size: 13px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .pos-mobile-tab-btn:hover {
    color: var(--text-1);
    background: rgba(255, 255, 255, 0.08);
  }

  .pos-mobile-tab-btn.active {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #ffffff;
    border-color: #818cf8;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
    font-weight: 800;
  }

  .pos-mobile-badge {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    font-size: 11px;
    font-weight: 800;
    padding: 1px 7px;
    border-radius: 999px;
    min-width: 18px;
    text-align: center;
    transition: all 0.2s ease;
  }

  .pos-mobile-tab-btn.active .pos-mobile-badge {
    background: #ffffff;
    color: #4338ca;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  }

  /* ── 2. Layout & Panels Visibility ── */
  .pos-layout {
    display: block !important;
    width: 100% !important;
    max-width: 100vw !important;
    height: auto !important;
    min-height: calc(100dvh - 105px);
    padding: 8px 8px 85px 8px !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
    margin: 0 !important;
    gap: 0 !important;
  }

  /* Cart Tab Active */
  .pos-layout.mobile-view-cart .pos-left {
    display: none !important;
  }

  .pos-layout.mobile-view-cart .pos-right {
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 8px 10px !important;
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
    box-sizing: border-box !important;
  }

  /* Catalog Tab Active */
  .pos-layout.mobile-view-catalog .pos-right {
    display: none !important;
  }

  .pos-layout.mobile-view-catalog .pos-left {
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 8px 10px !important;
    height: calc(100dvh - 120px) !important;
    max-height: calc(100dvh - 120px) !important;
    overflow-y: auto !important;
    box-sizing: border-box !important;
  }

  /* ── 3. Top Cashier Controls ── */
  .pos-catalog-controls {
    display: flex !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    justify-content: flex-start !important;
    gap: 6px !important;
    padding-bottom: 6px !important;
    border-bottom: 1px solid var(--border-light);
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .pos-catalog-controls::-webkit-scrollbar {
    display: none !important;
  }

  .pos-top-tools {
    display: flex !important;
    gap: 6px !important;
    flex-wrap: nowrap !important;
    flex-shrink: 0 !important;
  }

  .pos-tool-btn {
    min-height: 32px !important;
    padding: 4px 10px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    flex-shrink: 0 !important;
  }

  /* ── 3.5. Multi-Bill Tabs Mobile ── */
  .pos-bills-bar {
    padding: 4px 6px !important;
    gap: 4px !important;
    margin-bottom: 6px !important;
  }

  .pos-bill-tab {
    padding: 4px 8px !important;
    min-height: 30px !important;
    font-size: 11.5px !important;
  }

  .btn-new-bill span,
  .btn-cycle-bill span {
    display: none !important;
  }

  .btn-new-bill,
  .btn-cycle-bill {
    padding: 4px 8px !important;
    min-height: 30px !important;
  }

  /* ── 4. Summary Row (2×2 Grid) ── */
  .pos-summary-row {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .summary-box {
    padding: 6px 8px !important;
    border-radius: var(--r-sm) !important;
  }

  .summary-label {
    font-size: 11px !important;
    font-weight: 700 !important;
  }

  .summary-value {
    font-size: 13.5px !important;
  }

  .summary-value input {
    font-size: 13px !important;
    padding: 3px 6px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* ── 5. Scan Row (Barcode + Camera + Retail Stock) ── */
  .pos-scan-row {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    padding: 8px 10px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    border-radius: var(--r-md) !important;
  }

  .pos-scan-row .scan-group {
    width: 100% !important;
    margin: 0 !important;
    box-sizing: border-box !important;
  }

  /* Barcode input group is first */
  .pos-scan-row .scan-group:last-child {
    order: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 4px !important;
  }

  .pos-scan-row .scan-label {
    font-size: 12px !important;
    font-weight: 700 !important;
    color: var(--text-2);
  }

  .pos-scan-row .scan-input-wrap {
    flex: 1 !important;
    width: 100% !important;
  }

  .pos-scan-input {
    height: 40px !important;
    font-size: 13px !important;
    padding: 6px 10px 6px 36px !important;
    border-radius: var(--r-sm) !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .btn-scan-camera-premium {
    width: 44px !important;
    height: 40px !important;
    flex-shrink: 0 !important;
    font-size: 16px !important;
    border-radius: var(--r-sm) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Retail Stock box is second (below barcode) */
  .pos-scan-row .scan-group:first-child {
    order: 2 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    background: rgba(255, 255, 255, 0.02) !important;
    padding: 4px 8px !important;
    border-radius: var(--r-sm) !important;
    border: 1px dashed rgba(255, 255, 255, 0.08) !important;
  }

  .scan-label.red {
    font-size: 11.5px !important;
  }

  .retail-qty-box {
    font-size: 13px !important;
    padding: 2px 10px !important;
    min-width: 45px !important;
  }

  /* ── 6. Cart Table (100% Width, Zero Overflow) ── */
  .cart-table-wrap {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    min-height: 180px !important;
    max-height: 38vh !important;
    border-radius: var(--r-md) !important;
    border: 1px solid var(--border) !important;
    box-sizing: border-box !important;
    margin: 2px 0 !important;
  }

  .cart-table {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
    font-size: 12px !important;
  }

  /* Hide Cost column on mobile to save space */
  .cart-table th:nth-child(5),
  .cart-table td:nth-child(5) {
    display: none !important;
  }

  /* Proportional column widths totaling 100% */
  .cart-table th:nth-child(1),
  .cart-table td:nth-child(1) {
    width: 37% !important;
    text-align: right !important;
  }

  .cart-table th:nth-child(2),
  .cart-table td:nth-child(2) {
    width: 17% !important;
    text-align: center !important;
  }

  .cart-table th:nth-child(3),
  .cart-table td:nth-child(3) {
    width: 24% !important;
    text-align: center !important;
  }

  .cart-table th:nth-child(4),
  .cart-table td:nth-child(4) {
    width: 16% !important;
    text-align: center !important;
  }

  .cart-table th:nth-child(6),
  .cart-table td:nth-child(6) {
    width: 6% !important;
    text-align: center !important;
  }

  .cart-table th {
    padding: 8px 3px !important;
    font-size: 12px !important;
  }

  .cart-table td {
    padding: 6px 3px !important;
  }

  .cart-table-item-name {
    font-size: 12px !important;
    font-weight: 700 !important;
    line-height: 1.35 !important;
    max-width: 100% !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
  }

  .cart-unit-select {
    font-size: 10px !important;
    padding: 1px 3px !important;
    max-width: 100% !important;
    margin-top: 2px !important;
  }

  .cart-table-qty-container {
    display: inline-flex !important;
    align-items: center !important;
    gap: 2px !important;
    justify-content: center !important;
  }

  .cart-table-qty-btn {
    width: 24px !important;
    height: 24px !important;
    font-size: 11px !important;
    border-radius: 5px !important;
    flex-shrink: 0 !important;
  }

  .cart-table-qty-input {
    width: 32px !important;
    height: 24px !important;
    font-size: 12px !important;
    padding: 0 !important;
    text-align: center !important;
  }

  .cart-table-price-input {
    width: 48px !important;
    height: 24px !important;
    font-size: 12px !important;
    padding: 1px 2px !important;
    text-align: center !important;
  }

  .cart-table-total {
    font-size: 12px !important;
    font-weight: 800 !important;
    color: #38bdf8 !important;
  }

  .cart-table-remove {
    font-size: 15px !important;
    padding: 4px !important;
  }

  /* ── 7. Checkout Area & Payments ── */
  .pos-checkout-area {
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 8px 10px !important;
    gap: 8px !important;
    border-radius: var(--r-md) !important;
  }

  .pos-giant-total {
    padding: 6px 10px !important;
  }

  .giant-total-text {
    font-size: 20px !important;
  }

  .pos-controls-row {
    width: 100% !important;
    flex-direction: column !important;
    gap: 6px !important;
  }

  .pos-layout .pay-methods {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 6px !important;
  }

  .pos-layout .pay-btn {
    min-height: 40px !important;
    font-size: 12.5px !important;
    font-weight: 700 !important;
    padding: 6px 8px !important;
    border-radius: var(--r-sm) !important;
  }

  .pos-checkout-buttons {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    width: 100% !important;
  }

  .pos-checkout-buttons .btn-checkout-giant {
    flex: 1 1 100% !important;
    min-height: 46px !important;
    font-size: 15.5px !important;
    font-weight: 800 !important;
    border-radius: var(--r-md) !important;
    order: 1 !important;
  }

  .pos-checkout-buttons .btn-card-sale {
    flex: 1 1 calc(50% - 3px) !important;
    min-height: 38px !important;
    font-size: 12.5px !important;
    order: 2 !important;
  }

  .pos-checkout-buttons .btn-commission {
    flex: 1 1 calc(50% - 3px) !important;
    min-height: 38px !important;
    font-size: 12.5px !important;
    order: 3 !important;
  }

  .pos-checkout-buttons .btn-open-drawer {
    flex: 1 1 100% !important;
    min-height: 38px !important;
    font-size: 13px !important;
    order: 4 !important;
  }

  /* Hide hotkeys hint strip on touch screens */
  .pos-hotkeys-bar,
  .hotkey-hint,
  .hotkey-badge-checkout {
    display: none !important;
  }

  /* ── 8. Catalog View (when active on Mobile) ── */
  .pos-left-footer {
    display: none !important;
  }

  .pos-layout .cat-pills {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    gap: 6px !important;
    padding: 4px 2px 8px 2px !important;
    width: 100% !important;
  }

  .pos-layout .cat-pills::-webkit-scrollbar {
    display: none !important;
  }

  .pos-layout .cat-pill {
    flex: 0 0 auto !important;
    padding: 6px 12px !important;
    font-size: 12px !important;
  }

  .pos-layout .product-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)) !important;
    gap: 8px !important;
    padding: 4px 2px 70px 2px !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .pos-layout .product-card {
    min-height: 125px !important;
    padding: 8px 6px !important;
    gap: 4px !important;
    border-radius: var(--r-md) !important;
  }

  .pos-layout .product-card.has-image {
    min-height: 175px !important;
    padding: 5px 5px 5px 5px !important;
  }

  .pos-layout .product-card.has-image .product-card-body {
    margin: 2px 0 !important;
    flex: 0 0 auto !important;
  }

  .pos-layout .product-card.has-image .product-card-name {
    min-height: unset !important;
    max-height: 28px !important;
    font-size: 11px !important;
    line-height: 1.25 !important;
  }

  .pos-layout .product-card.has-image .product-card-footer {
    flex-shrink: 0 !important;
    min-height: 22px !important;
    padding-top: 4px !important;
  }

  .pos-layout .product-card-media {
    height: 72px !important;
    min-height: 72px !important;
    border-radius: 8px !important;
    flex-shrink: 0 !important;
  }

  .pos-layout .product-card-zoom-btn {
    opacity: 0.8 !important;
    transform: scale(0.9) !important;
    width: 23px !important;
    height: 23px !important;
    font-size: 10px !important;
  }

  .pos-layout .product-card-icon {
    width: 30px !important;
    height: 30px !important;
    font-size: 13px !important;
  }

  .pos-layout .product-card-name {
    font-size: 11.5px !important;
    line-height: 1.3 !important;
    font-weight: 700 !important;
  }

  .pos-layout .product-card-price {
    font-size: 12.5px !important;
    font-weight: 800 !important;
  }

  /* ── 9. Floating Catalog Bottom Bar (Mobile Only) ── */
  .pos-mobile-catalog-bottombar {
    position: fixed !important;
    bottom: 12px !important;
    left: 10px !important;
    right: 10px !important;
    z-index: 95 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 10px 16px !important;
    background: linear-gradient(135deg, #059669 0%, #10b981 100%) !important;
    color: #ffffff !important;
    border-radius: var(--r-lg, 14px) !important;
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.45) !important;
    cursor: pointer !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    user-select: none !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    animation: slideUpBottomBar 0.3s ease-out;
  }

  .pos-mobile-catalog-bottombar:active {
    transform: scale(0.98);
  }

  .pos-mobile-bottombar-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .pos-mobile-bottombar-count {
    font-size: 11.5px;
    opacity: 0.95;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
  }

  .pos-mobile-bottombar-total {
    font-size: 16px;
    font-weight: 900;
    font-family: 'Cairo', 'Inter', sans-serif;
  }

  .pos-mobile-bottombar-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 800;
    background: rgba(0, 0, 0, 0.2);
    padding: 6px 12px;
    border-radius: var(--r-sm, 8px);
  }

  @keyframes slideUpBottomBar {
    from {
      transform: translateY(60px);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }

  .pos-mobile-catalog-bottombar.bounce-bump {
    animation: bounceBump 0.25s ease;
  }

  @keyframes bounceBump {
    0% { transform: scale(1); }
    50% { transform: scale(1.04); }
    100% { transform: scale(1); }
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Small Mobile (≤480px)
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .pos-layout .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(95px, 1fr)) !important;
    gap: 6px !important;
  }

  .pos-layout .product-card-name {
    font-size: 11px !important;
  }

  .pos-layout .product-card-price {
    font-size: 12px !important;
  }

  .giant-total-text {
    font-size: 19px !important;
  }

  .cart-table th:nth-child(1),
  .cart-table td:nth-child(1) {
    width: 36% !important;
  }

  .cart-table th:nth-child(2),
  .cart-table td:nth-child(2) {
    width: 17% !important;
  }

  .cart-table th:nth-child(3),
  .cart-table td:nth-child(3) {
    width: 25% !important;
  }

  .cart-table th:nth-child(4),
  .cart-table td:nth-child(4) {
    width: 15% !important;
  }

  .cart-table th:nth-child(6),
  .cart-table td:nth-child(6) {
    width: 7% !important;
  }
}

@media print {
  .pos-layout {
    display: none !important;
  }
}
