/* Google Fonts Overwrite */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Outfit:wght@400;600;700;800&display=swap');

:root {
  /* Sync with Dart App Colors */
  --primary: #1A237E;
  /* Navy Blue */
  --primary-dark: #0D1642;
  --primary-light: #534BAE;

  --accent: #E53935;
  /* Red (Location) */
  --success: #2E7D32;
  /* Deep Green (Price/Phone) */

  --bg-main: #F8F9FA;
  --bg-card: #FFFFFF;
  --bg-glass: rgba(255, 255, 255, 0.95);

  --text-main: #1A237E;
  --text-muted: #616161;
  --text-light: #9E9E9E;

  --border-light: #EEEEEE;

  --shadow-md: 0 8px 15px rgba(0, 0, 0, 0.04);
  --shadow-premium: 0 12px 20px rgba(0, 0, 0, 0.08);

  --radius-lg: 20px;

  --font-header: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;

  --sidebar-width: 90px;
  --cart-width: 380px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  color: var(--text-main);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.pos-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  background: var(--bg-main);
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  background: white;
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 0;
  z-index: 50;
}

.sidebar-header {
  margin-bottom: 3rem;
}

.sidebar-logo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  /* Rounded like in mobile */
  object-fit: cover;
  padding: 2px;
  background: white;
  border: 1px solid var(--border-light);
}

.sidebar-nav ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
  padding: 0 15px;
}

.sidebar-nav li {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  cursor: pointer;
  color: #BDBDBD;
  transition: all 0.2s ease;
}

.sidebar-nav li:hover {
  background: #E3F2FD;
  /* Blue[50] */
  color: var(--primary);
}

.sidebar-nav li.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 10px rgba(26, 35, 126, 0.2);
}

.sidebar-nav li i {
  font-size: 1.25rem;
}

/* --- Main Content --- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.top-bar {
  height: 80px;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
}

.search-wrapper {
  position: relative;
  flex: 0 1 480px;
}

.search-wrapper i {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 1.1rem;
}

.search-wrapper input {
  width: 100%;
  height: 50px;
  padding: 0 20px 0 50px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  background: white;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}

.search-wrapper input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1), var(--shadow-md);
}

.filter-wrapper {
  display: flex;
  gap: 12px;
  align-items: center;
}

.filter-wrapper select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7' /%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px !important;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  font-weight: 500 !important;
  color: var(--text-muted) !important;
}

.filter-wrapper select:hover {
  border-color: var(--primary-light);
  color: var(--primary) !important;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  background: white;
  padding: 6px 16px 6px 6px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

.user-profile span {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.user-profile img {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  object-fit: cover;
}

/* Category Filters */
.category-filters {
  padding: 0 2rem 1.5rem;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-filters::-webkit-scrollbar {
  display: none;
}

.filter-btn {
  padding: 10px 24px;
  border: 1px solid var(--border-light);
  background: white;
  color: var(--text-muted);
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}

.filter-btn:hover {
  border-color: var(--primary-light);
  color: var(--primary);
  transform: translateY(-2px);
}

.filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 8px 16px -4px rgba(99, 102, 241, 0.4);
}

/* Badge Positioning */
.product-card .badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.9);
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  color: #0D47A1;
  z-index: 2;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.product-grid {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 15px;
  align-content: start;
}

.product-card {
  background: white;
  border-radius: var(--radius-lg);
  /* ZOOM FIX: Remove overflow:hidden and fixed height constraints */
  overflow: visible;
  box-shadow: var(--shadow-md);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  border: 1px solid #F5F5F5;
  min-height: 320px;
  /* Base height for mobile look */
  height: auto;
  /* Allow growth during zoom */
  position: relative;
}

.product-card img {
  width: 100%;
  height: auto;
  min-height: 160px;
  max-height: 220px;
  object-fit: cover;
  background-color: #F5F5F5;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  transition: transform 0.6s ease;
}

.product-card:hover img {
  transform: scale(1.05);
}

.product-details {
  padding: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: white;
  z-index: 1;
}

.product-details h3 {
  font-family: var(--font-header);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
  /* Ensure full visibility */
  display: block;
  overflow: visible;
}

.product-details .price {
  font-family: var(--font-header);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary);
  margin-top: 4px;
}

.product-details .product-info-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 600;
}

.product-details .product-info-row i {
  width: 16px;
  text-align: center;
}

.product-details .location i {
  color: var(--accent);
}

.product-details .store i {
  color: var(--primary);
}

.product-details .phone i {
  color: var(--success);
}

.product-details .description {
  font-size: 0.85rem;
  color: var(--text-light);
  line-height: 1.4;
  margin-top: 6px;
  /* Flexible height for description */
  display: block;
}

/* --- Cart Panel --- */
.cart-panel {
  width: var(--cart-width);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  z-index: 100;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.03);
}

.cart-header {
  padding: 1.75rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cart-header h2 {
  font-family: var(--font-header);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-main);
}

.clear-btn {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--danger);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.clear-btn:hover {
  background: var(--danger);
  color: white;
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.empty-cart-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-light);
  text-align: center;
  gap: 1rem;
}

.empty-cart-message i {
  font-size: 3.5rem;
  opacity: 0.3;
  color: var(--primary);
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.cart-item:hover {
  transform: translateX(4px);
  border-color: var(--primary-light);
  box-shadow: var(--shadow-md);
}

.cart-item img {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  object-fit: cover;
  background-color: #f1f5f9;
  border: 1px solid var(--border-light);
}

.cart-item-details {
  flex: 1;
  min-width: 0;
}

.cart-item-details h4 {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 4px;
  color: var(--text-main);
}

.cart-item-details .price {
  color: #64748b;
  font-weight: 600;
  font-size: 0.85rem;
}

.item-total-line {
  color: var(--primary);
  font-weight: 800;
  font-size: 0.9rem;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.cart-item-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.remove-item-btn {
  background: rgba(239, 68, 68, 0.1);
  border: none;
  color: var(--danger);
  width: 32px;
  height: 32px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.remove-item-btn:hover {
  background: var(--danger);
  color: white;
  transform: scale(1.1);
}

.qty-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
}

.qty-btn {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  border: none;
  background: white;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: all 0.2s;
}

.qty-btn:hover {
  background: var(--primary);
  color: white;
}

.qty-controls span {
  font-size: 0.9rem;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

/* Cart Footer */
.cart-footer {
  padding: 1.75rem;
  border-top: 1px solid var(--border-light);
  background: white;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

.summary-row.total {
  font-family: var(--font-header);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 8px;
  padding-top: 16px;
  border-top: 2px dashed var(--border-light);
}

.checkout-btn {
  width: 100%;
  height: 60px;
  padding: 0 24px;
  border: none;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border-radius: var(--radius-md);
  font-family: var(--font-header);
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: 1rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 10px 20px -5px rgba(99, 102, 241, 0.4);
}

/* --- Integrated Checkout Form --- */
.cart-checkout-form {
  border-top: 1px solid var(--border-light);
  padding: 1.5rem;
  background: #fafafa;
  display: none;
  /* Toggled by JS */
  animation: slideInUp 0.3s ease-out;
}

@keyframes slideInUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.cart-checkout-form h3 {
  font-family: var(--font-header);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.cart-checkout-form .form-group {
  margin-bottom: 1rem;
}

.cart-checkout-form input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border-light);
  border-radius: 12px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-main);
  background: white;
  transition: all 0.2s ease;
}

.cart-checkout-form input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 4px rgba(26, 35, 126, 0.05);
}

.cart-checkout-form input::placeholder {
  color: var(--text-light);
  font-size: 0.9rem;
}

.checkout-btn:active {
  transform: translateY(1px);
}

/* --- Misc --- */
.loading-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5rem 0;
  gap: 1.5rem;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border-light);
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* Responsive Overrides */
@media (max-width: 1200px) {
  :root {
    --cart-width: 340px;
  }
}

@media (max-width: 992px) {
  .pos-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: 70px;
    flex-direction: row;
    padding: 0 20px;
  }

  .sidebar-header {
    margin-bottom: 0;
  }

  .sidebar-nav {
    flex: 1;
  }

  .sidebar-nav ul {
    flex-direction: row;
    justify-content: flex-end;
  }

  .sidebar-nav li {
    width: 44px;
  }

  .cart-panel {
    width: 100%;
    position: absolute;
    bottom: 0;
    height: 50vh;
    transform: translateY(100%);
    transition: transform 0.4s ease;
    display: none;
  }

  .top-bar {
    padding: 10px 15px;
    height: auto;
    flex-wrap: wrap;
    gap: 15px;
  }

  .search-wrapper {
    flex: 1 1 100%;
    order: 3;
  }
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.product-card {
  animation: fadeInUp 0.5s ease backwards;
}

.product-card:nth-child(1n) {
  animation-delay: 0.1s;
}

.product-card:nth-child(2n) {
  animation-delay: 0.2s;
}

.product-card:nth-child(3n) {
  animation-delay: 0.3s;
}