/* =========================================================
   LUFFY FASHION - MOBILE NATIVE APP-LIKE EXPERIENCE (PWA / MOBILE-FIRST)
   ========================================================= */

/* 1. Global Touch & App Optimization */
html, body {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

button, a, input, select, textarea {
  touch-action: manipulation;
}

/* Safe Area Insets for Modern Mobile Notches */
:root {
  --mobile-bar-height: 62px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* =========================================================
   2. STOREFRONT MOBILE BOTTOM APP NAVIGATION BAR
   ========================================================= */
.mobile-app-bottom-bar {
  display: none;
}

@media (max-width: 768px) {
  /* Push page content above bottom bar */
  body.has-mobile-bar {
    padding-bottom: calc(var(--mobile-bar-height) + var(--safe-bottom) + 12px) !important;
  }

  /* Header Brand Logo Mobile Fit */
  .brand-logo-img-v2 {
    height: 35px !important;
    max-width: 160px !important;
  }
  .header-actions {
    gap: 4px !important;
  }
  .header-action-btn {
    width: 36px !important;
    height: 36px !important;
    font-size: 1.05rem !important;
  }

  .mobile-app-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-around;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--mobile-bar-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 -4px 25px rgba(0, 0, 0, 0.08);
    z-index: 9999;
  }

  .app-tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 100%;
    text-decoration: none;
    color: #64748b;
    font-size: 0.68rem;
    font-weight: 700;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    user-select: none;
  }

  .app-tab-item i {
    font-size: 1.25rem;
    transition: transform 0.2s ease, color 0.2s ease;
  }

  .app-tab-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .app-tab-badge {
    position: absolute;
    top: -6px;
    right: -10px;
    background: #ef4444;
    color: #ffffff;
    font-size: 0.62rem;
    font-weight: 800;
    min-width: 17px;
    height: 17px;
    line-height: 17px;
    border-radius: 999px;
    text-align: center;
    padding: 0 4px;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
    border: 1.5px solid #ffffff;
  }

  .app-tab-item:active {
    transform: scale(0.9);
  }

  .app-tab-item.active {
    color: #0f172a;
  }

  .app-tab-item.active i {
    color: #f59e0b;
    transform: translateY(-2px);
  }

  .app-tab-item.active::after {
    content: '';
    position: absolute;
    top: 0;
    width: 24px;
    height: 3px;
    background: #f59e0b;
    border-radius: 0 0 4px 4px;
  }
}

/* =========================================================
   3. MOBILE APP SLIDE-OUT DRAWER (STOREFRONT)
   ========================================================= */
.mobile-drawer-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mobile-drawer-overlay.active {
  display: block;
  opacity: 1;
}

.mobile-app-drawer {
  position: fixed;
  top: 0;
  left: -320px;
  width: 300px;
  max-width: 85vw;
  height: 100%;
  background: #ffffff;
  box-shadow: 5px 0 30px rgba(0, 0, 0, 0.2);
  z-index: 10001;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.mobile-app-drawer.open {
  transform: translateX(320px);
}

.drawer-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  padding: 24px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #f59e0b;
}

.drawer-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.drawer-logo-img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #f59e0b;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.drawer-brand-text h3 {
  font-size: 1.05rem;
  font-weight: 800;
  color: #ffffff;
  margin: 0;
  letter-spacing: 0.5px;
}

.drawer-brand-text span {
  font-size: 0.65rem;
  color: #f59e0b;
  font-weight: 700;
  letter-spacing: 1.5px;
  display: block;
  margin-top: 2px;
}

.drawer-close-btn {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #ffffff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
}

.drawer-close-btn:active {
  background: rgba(255, 255, 255, 0.25);
}

.drawer-body {
  padding: 18px 16px;
  flex: 1;
}

.drawer-section-title {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #94a3b8;
  letter-spacing: 1px;
  margin: 14px 10px 8px;
}

.drawer-nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  color: #1e293b;
  font-weight: 700;
  font-size: 0.92rem;
  text-decoration: none;
  transition: all 0.2s ease;
  margin-bottom: 3px;
}

.drawer-nav-item i {
  font-size: 1.1rem;
  color: #64748b;
  width: 22px;
  text-align: center;
  transition: color 0.2s ease;
}

.drawer-nav-item:active, .drawer-nav-item.active {
  background: #fef3c7;
  color: #92400e;
}

.drawer-nav-item:active i, .drawer-nav-item.active i {
  color: #d97706;
}

.drawer-footer {
  padding: 16px 20px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}

.drawer-contact-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  background: #0f172a;
  color: #ffffff;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.18);
}

.drawer-contact-btn:active {
  background: #1e293b;
}

/* =========================================================
   4. STICKY MOBILE ACTION BAR ON PRODUCT DETAILS
   ========================================================= */
.mobile-sticky-product-bar {
  display: none;
}

@media (max-width: 768px) {
  body.has-sticky-product-bar {
    padding-bottom: calc(72px + var(--safe-bottom)) !important;
  }

  body.has-sticky-product-bar .mobile-app-bottom-bar {
    display: none !important;
  }

  .mobile-sticky-product-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(68px + var(--safe-bottom));
    padding: 10px 16px calc(10px + var(--safe-bottom));
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    z-index: 9998;
  }

  .sticky-price-wrap {
    display: flex;
    flex-direction: column;
    min-width: 80px;
  }

  .sticky-price-wrap .price-now {
    font-size: 1.25rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.1;
  }

  .sticky-price-wrap .price-original {
    font-size: 0.78rem;
    color: #94a3b8;
    text-decoration: line-through;
  }

  .sticky-btn-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
  }

  .sticky-btn-cart {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 14px;
    background: #f1f5f9;
    color: #0f172a;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
  }

  .sticky-btn-cart:active {
    background: #e2e8f0;
  }

  .sticky-btn-buy {
    flex: 1.2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 800;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
    cursor: pointer;
  }

  .sticky-btn-buy:active {
    transform: scale(0.98);
  }
}

/* =========================================================
   5. ADMIN PANEL MOBILE BOTTOM APP NAVIGATION
   ========================================================= */
.admin-mobile-app-bar {
  display: none;
}

@media (max-width: 768px) {
  body.admin-body {
    padding-bottom: calc(var(--mobile-bar-height) + var(--safe-bottom)) !important;
  }

  .admin-mobile-app-bar {
    display: flex;
    align-items: center;
    justify-content: space-around;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--mobile-bar-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: #0f172a;
    border-top: 1px solid rgba(245, 158, 11, 0.3);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.35);
    z-index: 9999;
  }

  .admin-app-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 100%;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 700;
    transition: all 0.2s ease;
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
  }

  .admin-app-tab i {
    font-size: 1.15rem;
    transition: transform 0.2s ease, color 0.2s ease;
  }

  .admin-app-tab.active {
    color: #ffffff;
  }

  .admin-app-tab.active i {
    color: #f59e0b;
    transform: translateY(-2px);
  }

  .admin-app-tab.active::after {
    content: '';
    position: absolute;
    top: 0;
    width: 28px;
    height: 3px;
    background: #f59e0b;
    border-radius: 0 0 4px 4px;
  }

  .admin-app-tab:active {
    transform: scale(0.92);
  }

  /* Admin Sidebar Overlay on Mobile */
  .admin-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10001;
  }

  .admin-sidebar-overlay.active {
    display: block;
  }

  .admin-sidebar {
    z-index: 10002 !important;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  }
}

/* =========================================================
   6. MOBILE BOTTOM-SHEET MODALS (ADMIN & STOREFRONT)
   ========================================================= */
.admin-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 10005;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.admin-modal-overlay.open {
  display: flex !important;
}

.admin-modal {
  background: #ffffff;
  border-radius: 16px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
}

.admin-modal-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e2e8f0;
}

.admin-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #64748b;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 768px) {
  .admin-modal-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  .admin-modal {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 88vh !important;
    border-radius: 22px 22px 0 0 !important;
    margin: 0 !important;
    animation: slideUpSheet 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  }

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

  .admin-modal-header {
    padding: 16px 20px !important;
    position: sticky;
    top: 0;
    background: #ffffff;
    z-index: 10;
  }

  .admin-modal-body {
    padding: 16px 20px !important;
    max-height: calc(88vh - 140px) !important;
    overflow-y: auto !important;
  }

  .admin-modal-footer {
    padding: 14px 20px !important;
    position: sticky;
    bottom: 0;
    background: #ffffff;
    z-index: 10;
    border-top: 1px solid #e2e8f0;
  }
}

/* =========================================================
   7. TOUCH-FRIENDLY CARD & TABLE IMPROVEMENTS
   ========================================================= */
@media (max-width: 768px) {
  /* Product Cards on Mobile */
  .product-card {
    border-radius: 12px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.05);
  }

  .product-thumb {
    border-radius: 12px 12px 0 0;
  }

  .product-info {
    padding: 10px 12px;
  }

  .product-info h3 {
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .product-price .price-current {
    font-size: 1rem;
  }

  /* Admin Toolbar on Mobile */
  .admin-toolbar {
    flex-direction: column;
    align-items: stretch !important;
    gap: 10px;
  }

  .admin-toolbar .admin-search-box {
    width: 100%;
  }

  .admin-toolbar .btn-primary-action {
    width: 100%;
    justify-content: center;
    padding: 12px;
  }

  /* Admin metrics 2 columns */
  .admin-metrics-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  .metric-card {
    padding: 14px 12px !important;
  }

  .metric-num {
    font-size: 1.25rem !important;
  }

  /* Admin Table horizontal touch container */
  .admin-table-wrap {
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  }

  .admin-table th, .admin-table td {
    padding: 10px 12px !important;
    font-size: 0.82rem !important;
  }
}
