/* ========================================
   B2B Toys Ordering App - Custom Styles
   ======================================== */

/* === CSS Variables === */
:root {
  --primary: #E53935;
  --primary-dark: #C62828;
  --primary-light: #FFCDD2;
  --accent: #FF6F00;
  --bg: #F5F5F5;
  --bg-white: #FFFFFF;
  --text-primary: #212121;
  --text-secondary: #757575;
  --text-light: #BDBDBD;
  --border: #E0E0E0;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xl: 20px;
  --whatsapp: #25D366;
  --call: #4285F4;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
button { cursor: pointer; border: none; outline: none; font-family: inherit; }
input, textarea, select { font-family: inherit; outline: none; }

/* === Utility === */
.container { max-width: 480px; margin: 0 auto; padding: 0 16px; }

/* === Auth Pages (Login, OTP, Profile) === */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  background: linear-gradient(135deg, #FAFAFA 0%, #FFF5F5 100%);
}

.auth-card {
  background: var(--bg-white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 36px 28px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  background: var(--bg-white);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
  overflow: hidden;
  padding: 10px;
}

.auth-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.auth-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.form-group {
  margin-bottom: 18px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  transition: var(--transition);
  background: #FAFAFA;
}

.form-input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.1);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn-primary {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  box-shadow: 0 4px 16px rgba(229, 57, 53, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 8px;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(229, 57, 53, 0.4);
}

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

/* OTP Input */
.otp-container {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 24px 0;
  width: 100%;
}

.otp-input {
  width: 40px;
  height: 50px;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  background: #FAFAFA;
}

.otp-input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.1);
}

.otp-hint {
  font-size: 12px;
  color: var(--text-light);
  margin-top: -8px;
  margin-bottom: 16px;
}

/* === Main App Layout === */
.app-wrapper {
  padding-bottom: 72px; /* space for bottom nav */
}

/* === Header === */
.app-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(229, 57, 53, 0.25);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.header-logo img {
  height: 100%;
  width: auto;
  object-fit: contain;
}

.header-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.header-greeting h2 {
  font-size: 16px;
  font-weight: 600;
}

.header-greeting p {
  font-size: 12px;
  opacity: 0.85;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.header-btn {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  backdrop-filter: blur(4px);
  transition: var(--transition);
}

.header-btn:hover {
  background: rgba(255,255,255,0.25);
}

/* === Banner Slider === */
.banner-section {
  padding: 16px 0;
}

.banner-slider {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 0 20px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-padding: 0 20px;
}

.banner-slider::-webkit-scrollbar { display: none; }

.banner-slide {
  flex: 0 0 100%;
  scroll-snap-align: center;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  aspect-ratio: 4 / 3;
  flex-shrink: 0;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.banner-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.banner-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  color: #fff;
}

.banner-content h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.banner-content p {
  font-size: 13px;
  opacity: 0.9;
}

.banner-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
}

.banner-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-light);
  transition: var(--transition);
}

.banner-dot.active {
  width: 24px;
  border-radius: 4px;
  background: var(--primary);
}

/* === Section Titles === */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 16px 12px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.section-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}

/* === Categories === */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 0 16px;
}

.category-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: var(--transition);
}

.category-card:active {
  transform: scale(0.95);
}

.category-img {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: var(--transition);
  border: 2px solid #f0f0f0;
}

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

.category-card:hover .category-img {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(229, 57, 53, 0.15);
}

.category-name {
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  color: var(--text-primary);
  line-height: 1.3;
}

/* === Product Grid === */
.products-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 0 16px 20px;
}

.product-card {
  background: var(--bg-white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: var(--transition);
  position: relative;
}

.product-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.product-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  z-index: 2;
}

.product-img {
  width: 100%;
  aspect-ratio: 1;
  background: #f9f9f9;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

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



.product-info {
  padding: 12px;
}

.product-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-price-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.product-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
}

.product-mrp {
  font-size: 12px;
  color: var(--text-light);
  text-decoration: line-through;
}

.product-discount {
  font-size: 11px;
  font-weight: 600;
  color: #2E7D32;
}

.btn-add-cart {
  width: 100%;
  padding: 10px;
  background: var(--bg);
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  border-radius: 8px;
  border: 1.5px solid var(--primary);
  transition: var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.btn-add-cart:hover {
  background: var(--primary);
  color: #fff;
}

/* === Floating Buttons === */
.floating-buttons {
  position: fixed;
  bottom: 84px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 90;
}

.fab {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  transition: var(--transition);
  animation: fabPulse 2s ease-in-out infinite;
}

@keyframes fabPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.fab:hover {
  transform: scale(1.1) !important;
}

.fab-whatsapp { background: var(--whatsapp); }
.fab-call { background: var(--call); }

/* === Bottom Navigation === */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-white);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 6px 0 4px;
  padding-bottom: max(4px, env(safe-area-inset-bottom));
  border-top: 1px solid #ECECEC;
  z-index: 100;
  max-width: 100%;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 14px;
  color: #888;
  font-size: 11px;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
  background: none;
  letter-spacing: 0.2px;
}

.nav-item.active {
  color: var(--primary);
  font-weight: 600;
}

.nav-item .nav-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.nav-item .nav-icon svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
  stroke: none;
  transition: var(--transition);
}

.nav-item.active .nav-icon svg {
  transform: scale(1.1);
}

.nav-badge {
  position: absolute;
  top: -2px;
  right: 6px;
  min-width: 18px;
  height: 18px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* === Side Drawer === */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 300px;
  max-width: 85vw;
  background: var(--bg-white);
  z-index: 201;
  transform: translateX(-100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 32px 20px 24px;
}

.drawer-avatar {
  width: 56px;
  height: 56px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 12px;
  backdrop-filter: blur(4px);
}

.drawer-name {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.drawer-phone {
  font-size: 13px;
  opacity: 0.85;
}

.drawer-menu {
  flex: 1;
  padding: 12px 0;
}

.drawer-menu-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  transition: var(--transition);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.drawer-menu-item:hover {
  background: #FFF5F5;
  color: var(--primary);
}

.drawer-menu-item .menu-icon {
  font-size: 20px;
  width: 24px;
  text-align: center;
}

.drawer-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 20px;
}

.drawer-footer {
  padding: 16px 20px 24px;
  border-top: 1px solid var(--border);
}

.btn-logout {
  width: 100%;
  padding: 14px;
  background: #FFF5F5;
  color: var(--primary);
  font-size: 15px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--primary);
  transition: var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-logout:hover {
  background: var(--primary);
  color: #fff;
}

/* === Search Page === */
.search-page {
  padding-top: 16px;
}

.search-bar {
  margin: 0 16px;
  position: relative;
}

.search-bar input {
  width: 100%;
  padding: 14px 16px 14px 48px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  background: var(--bg-white);
  transition: var(--transition);
}

.search-bar input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.1);
}

.search-bar .search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: var(--text-light);
}

/* === Empty State === */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 40px;
  text-align: center;
}


.empty-icon {
  font-size: 80px;
  margin-bottom: 20px;
  opacity: 0.6;
}

.profile-header {
  width: 100%;
  max-width: 400px;
  display: flex;
  align-items: center;
  margin-bottom: 20px;
}

.back-btn-round {
  width: 44px;
  height: 44px;
  background: var(--bg-white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.back-btn-round:active {
  transform: scale(0.95);
}

.auth-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
}

.btn-secondary {
  padding: 14px 32px;
  background: var(--bg-white);
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 2px solid var(--primary);
  transition: var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-secondary:hover {
  background: var(--primary);
  color: #fff;
}

/* === Orders Tabs === */
.tabs {
  display: flex;
  background: var(--bg-white);
  padding: 0 16px;
  border-bottom: 2px solid var(--border);
}

.tab {
  flex: 1;
  padding: 14px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  position: relative;
  transition: var(--transition);
  background: none;
}

.tab.active {
  color: var(--primary);
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
}

/* === Page Header (inner pages) === */
.page-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(229, 57, 53, 0.25);
}

.page-header .back-btn {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  backdrop-filter: blur(4px);
}

.page-header h1 {
  font-size: 18px;
  font-weight: 600;
}

/* === Cart Page === */
.cart-summary {
  background: var(--bg-white);
  margin: 16px;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

/* === Toast Notification === */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #333;
  color: #fff;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  z-index: 999;
  opacity: 0;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* === Animations === */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.fade-in {
  animation: fadeIn 0.4s ease-out;
}

/* === Responsive === */
@media (min-width: 481px) {
  body {
    max-width: 480px;
    margin: 0 auto;
    box-shadow: 0 0 40px rgba(0,0,0,0.08);
  }

  .bottom-nav {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%);
  }
  
  .floating-buttons {
    right: calc(50% - 240px + 16px);
  }
}

/* Loading Spinner */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* === Drawer Dropdown === */
.drawer-menu-item .menu-arrow {
  margin-left: auto;
  font-size: 10px;
  transition: transform 0.3s ease;
  opacity: 0.5;
}

.drawer-menu-item[onclick*="toggleCategoryDropdown"] .menu-arrow {
  display: inline-block;
}

.drawer-submenu {
  background: #fdfdfd;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
  border-left: 3px solid var(--primary);
  margin-left: 20px;
}

.drawer-submenu.open {
  max-height: 500px;
}

.menu-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.menu-icon svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  display: block;
}

.drawer-menu-item:hover .menu-icon,
.drawer-menu-item.active .menu-icon {
  color: var(--primary);
}

.drawer-submenu-item {
  display: block;
  padding: 12px 20px;
  font-size: 14px;
  color: var(--text-secondary);
  transition: var(--transition);
  text-decoration: none;
}

.drawer-submenu-item:hover {
  color: var(--primary);
  background: #FFF5F5;
}
