:root {
  --primary-color: #27ae60;
  --accent-color: #f1c40f;
  --secondary-color: #2c3e50;
  --bg-color: #f4f7f6;
  --white: #ffffff;
  --text-color: #333333;
  --gray: #bdc3c7;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
}

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
}

.container {
  width: 90%;
  max-width: 1200px;
  margin: auto;
}

header {
  background: var(--white);
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  padding: 15px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

header .container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  position: relative;
}

.header-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-top .hamburger-btn {
  order: -1;
}

.header-search {
  margin: 0;
  width: 100%;
}

header h1 {
  margin: 0;
  color: var(--primary-color);
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  height: 42px;
  width: auto;
  margin-right: 8px;
  border-radius: 6px;
  object-fit: contain;
}

.hamburger-btn {
  display: block;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--secondary-color);
  cursor: pointer;
  padding: 5px;
  line-height: 1;
  z-index: 110;
}

nav {
  width: 100%;
  order: 3;
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.35s ease;
}

nav.nav-open {
  max-height: 300px;
}

nav ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  padding: 10px 0 5px;
}

nav a {
  display: block;
  color: var(--secondary-color);
  text-decoration: none;
  font-weight: 500;
  padding: 10px 15px !important;
  border-radius: 10px !important;
  font-size: 15px !important;
  background: transparent !important;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.2s, color 0.2s;
}

nav a:hover,
nav a.active {
  background: #e8f5e9 !important;
  color: var(--primary-color) !important;
}

nav li:last-child a {
  border-bottom: none;
}

/* Search Bar */
.search-bar {
  display: flex;
  margin: 30px 0;
  background: var(--white);
  padding: 5px;
  border-radius: 50px;
  box-shadow: var(--shadow);
}

.search-bar input {
  flex: 1;
  padding: 15px 25px;
  border: none;
  border-radius: 50px 0 0 50px;
  font-size: 16px;
  outline: none;
  font-family: 'Inter', sans-serif;
}

.search-bar button {
  border-radius: 50px;
  padding: 0 30px;
}

/* Category Tabs */
.category-tabs {
  display: flex;
  gap: 15px;
  margin-bottom: 40px;
  overflow-x: auto;
  padding-bottom: 10px;
  scrollbar-width: none;
}

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

.category-tab {
  flex: 0 0 auto;
  background: var(--white);
  padding: 20px 30px;
  border-radius: 15px;
  text-align: center;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid transparent;
  user-select: none;
}

.category-tab:hover {
  transform: translateY(-5px);
  border-color: var(--primary-color);
}

.category-tab i {
  display: block;
  font-size: 24px;
  margin-bottom: 10px;
  color: var(--primary-color);
  transition: color 0.3s;
}

.category-tab span {
  font-weight: 600;
  color: var(--secondary-color);
  transition: color 0.3s;
}

/* FIX: Active tab — icon and text must be white (was invisible on green bg) */
.category-tab.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.category-tab.active i {
  color: var(--white);
}

.category-tab.active span {
  color: var(--white);
}

/* Buttons */
.btn {
  background-color: var(--primary-color);
  color: var(--white);
  padding: 12px 24px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-weight: bold;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  transition: transform 0.2s, background 0.2s;
}

.btn:hover {
  background-color: #219a52;
  transform: translateY(-2px);
}

.btn-block {
  display: block;
  width: 100%;
  box-sizing: border-box;
}

/* Forms */
.form-container {
  background: var(--white);
  padding: 30px;
  border-radius: 10px;
  max-width: 400px;
  margin: 50px auto;
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.form-container h2 {
  margin-top: 0;
  text-align: center;
  color: var(--secondary-color);
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px;
  box-sizing: border-box;
  border: 1px solid var(--gray);
  border-radius: 5px;
  font-size: 16px;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary-color);
}

/* Product Grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 30px;
  margin-bottom: 50px;
}

.product-card {
  background: var(--white);
  padding: 0;
  border-radius: 20px;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
  text-align: center;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.product-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 30px rgba(0,0,0,0.12);
}

.product-image-wrapper {
  padding: 20px;
  background: #f9f9f9;
}

.product-card img {
  width: 100%;
  height: 160px;
  object-fit: contain;
  border-radius: 12px;
  transition: transform 0.3s ease;
}

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

.product-info {
  padding: 20px;
  flex-grow: 1;
}

.product-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 8px 0;
  color: var(--secondary-color);
}

.product-shop {
  font-size: 14px;
  color: #7f8c8d;
  margin-bottom: 12px;
}

.product-price {
  font-size: 22px;
  color: var(--primary-color);
  font-weight: 800;
  margin-bottom: 15px;
}

.buy-now-btn {
  background: var(--white);
  color: var(--primary-color);
  padding: 12px 25px;
  border: 2px solid var(--primary-color);
  border-radius: 50px;
  width: 80%;
  margin: 0 auto 20px;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 13px;
}

.buy-now-btn:hover {
  background: var(--primary-color);
  color: var(--white);
  box-shadow: 0 5px 15px rgba(39, 174, 96, 0.3);
}

/* Dashboard */
.dashboard-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.dashboard-table th,
.dashboard-table td {
  padding: 15px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.dashboard-table th {
  background: var(--secondary-color);
  color: var(--white);
}

/* Responsive Table Wrapper */
.table-responsive {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
  border: 1px solid #eee;
  border-radius: 8px;
}

.table-responsive .dashboard-table {
  margin-bottom: 0;
  border: none;
}

/* Responsive Grid Form */
.responsive-form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

/* Product Detail */
.product-details-wrapper {
  margin-top: 40px;
  display: flex;
  gap: 40px;
  background: var(--white);
  padding: 30px;
  border-radius: 15px;
  box-shadow: var(--shadow);
}

.product-details-wrapper > div {
  flex: 1;
}

.product-details-wrapper img {
  width: 100%;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
  .container {
    width: 92%;
    padding: 0 10px;
    box-sizing: border-box;
  }

  header .container {
    gap: 8px;
    padding: 10px 0;
  }

  header h1 {
    font-size: 22px;
  }

  nav ul {
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
  }

  nav a {
    font-size: 14px;
    padding: 5px 10px;
    background: #f0f2f1;
    border-radius: 20px;
    transition: all 0.2s ease;
  }

  nav a:hover,
  nav a.active {
    background: var(--primary-color);
    color: var(--white);
  }

  .product-details-wrapper {
    flex-direction: column;
    gap: 25px;
    padding: 20px;
    margin-top: 20px;
  }

  .responsive-form-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .form-container {
    width: 100%;
    max-width: 100%;
    margin: 30px auto;
    padding: 20px;
    box-sizing: border-box;
  }
}

@media (max-width: 576px) {
  .search-bar {
    margin: 20px 0;
    padding: 3px;
  }

  .search-bar input {
    padding: 10px 15px;
    font-size: 14px;
  }

  .search-bar button {
    padding: 0 15px;
    font-size: 13px;
  }

  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 30px;
  }

  .product-card {
    border-radius: 12px;
  }

  .product-image-wrapper {
    padding: 10px;
  }

  .product-card img {
    height: 110px;
    border-radius: 8px;
  }

  .product-info {
    padding: 10px;
  }

  .product-title {
    font-size: 14px;
    margin-bottom: 4px;
    height: 2.4em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .product-shop {
    font-size: 11px;
    margin-bottom: 6px;
  }

  .product-price {
    font-size: 16px;
    margin-bottom: 8px;
  }

  .buy-now-btn {
    width: 90%;
    padding: 8px 10px;
    font-size: 11px;
    margin-bottom: 12px;
    border-width: 1px;
  }

  .category-tabs {
    margin-bottom: 25px;
    gap: 10px;
  }

  .category-tab {
    padding: 12px 18px;
    border-radius: 10px;
  }

  .category-tab i {
    font-size: 18px;
    margin-bottom: 6px;
  }

  .category-tab span {
    font-size: 12px;
  }
}

/* ==========================================================================
   Global Mobile Overflow Prevention
   ========================================================================== */
html {
  background-color: #f3f4f6;
  min-height: 100vh;
}

body {
  overflow-x: hidden;
  max-width: 100vw;
  background-color: #ffffff;
}

*, *::before, *::after {
  box-sizing: border-box;
}

/* Ensure all images respect container bounds */
img {
  max-width: 100%;
  height: auto;
}

/* Ensure inputs/textareas don't overflow */
input, textarea, select, button {
  max-width: 100%;
  box-sizing: border-box;
}

/* Hamburger navigation and header promoted to global defaults */

/* ==========================================================================
   Mobile Table → Card View
   ========================================================================== */
@media (max-width: 768px) {
  .table-responsive {
    border: none;
    overflow-x: visible;
  }

  .dashboard-table,
  .dashboard-table thead,
  .dashboard-table tbody,
  .dashboard-table th,
  .dashboard-table td,
  .dashboard-table tr {
    display: block;
  }

  .dashboard-table thead {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }

  .dashboard-table tr {
    background: white;
    margin-bottom: 16px;
    border-radius: 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
    padding: 15px;
    border: 1px solid #f0f0f0;
  }

  .dashboard-table td {
    padding: 10px 0 10px 0;
    border: none;
    border-bottom: 1px solid #f8f8f8;
    position: relative;
    padding-left: 0;
    text-align: left;
    font-size: 14px;
    word-break: break-word;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .dashboard-table td:last-child {
    border-bottom: none;
  }

  .dashboard-table td::before {
    content: attr(data-label);
    position: static;
    width: auto;
    padding-right: 0;
    font-weight: 700;
    font-size: 10px;
    color: #bdc3c7;
    text-transform: uppercase;
    text-align: left;
    display: block;
  }

  .dashboard-table td > div {
    display: flex;
    justify-content: flex-start !important;
    text-align: left !important;
  }

  /* Stats Grid on mobile */
  .stats-grid,
  .admin-stats {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px;
  }

  .stat-card {
    padding: 16px 12px;
  }

  .stat-card .value {
    font-size: 24px;
  }

  .stat-card h3 {
    font-size: 11px;
  }
}

/* ==========================================================================
   Profile Page Mobile Fixes
   ========================================================================== */
@media (max-width: 576px) {
  .profile-card {
    padding: 20px 15px;
    margin-top: 15px;
  }

  .profile-stats {
    flex-direction: row;
    gap: 8px;
    padding: 12px 8px;
  }

  .stat-value {
    font-size: 16px;
  }

  .stat-label {
    font-size: 10px;
  }

  .info-item {
    flex-direction: column;
    gap: 4px;
    padding: 10px 0;
  }

  .info-value {
    font-size: 14px;
  }

  .order-item {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 8px;
    padding: 12px;
  }

  .order-item img,
  .order-product-img {
    width: 50px !important;
    height: 50px !important;
    border-radius: 8px;
  }

  .order-status {
    align-self: flex-end;
  }
}

/* ==========================================================================
   Payment Page Mobile Fixes
   ========================================================================== */
@media (max-width: 576px) {
  .payment-option {
    padding: 18px 16px;
    border-radius: 12px;
  }

  .payment-option h3 {
    font-size: 15px;
    flex-wrap: wrap;
  }

  .payment-option p {
    font-size: 13px;
  }

  .success-card {
    padding: 25px 20px;
    margin: 30px auto;
  }

  .otp-badge {
    font-size: 24px;
    letter-spacing: 5px;
    padding: 12px 18px;
  }
}

/* ==========================================================================
   Shop Owner Dashboard Mobile Fixes
   ========================================================================== */
@media (max-width: 768px) {
  /* Shop owner tabs */
  .shop-tabs-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .shop-tabs-container::-webkit-scrollbar {
    display: none;
  }

  /* Delivery boy form grid */
  .form-row {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Profile header on mobile */
  .profile-header {
    flex-direction: column;
    text-align: center;
    gap: 15px;
    padding: 25px 20px;
  }

  .profile-header h2 {
    font-size: 22px !important;
  }

  .profile-avatar-large {
    width: 70px;
    height: 70px;
    font-size: 28px;
  }

  .profile-stats-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }

  /* Customer modal */
  .cust-modal {
    width: 95% !important;
    max-width: 100% !important;
  }

  .cust-modal-body {
    padding: 16px 18px;
  }

  .cust-info-value {
    font-size: 14px;
  }

  .cust-modal-footer {
    flex-direction: column;
    padding: 0 18px 18px;
  }

  /* Add product form */
  .responsive-form-grid {
    grid-template-columns: 1fr !important;
  }

  .responsive-form-grid > [style*="grid-column:span 2"],
  .responsive-form-grid > [style*="grid-column: span 2"] {
    grid-column: span 1 !important;
  }
}

/* ==========================================================================
   Delivery Boy Dashboard Mobile Fixes
   ========================================================================== */
@media (max-width: 576px) {
  .order-card-body {
    padding: 14px !important;
    gap: 12px !important;
  }

  .product-thumb {
    width: 60px !important;
    height: 60px !important;
    border-radius: 10px !important;
  }

  .order-info {
    min-width: 0 !important;
  }

  .product-name {
    font-size: 15px !important;
  }

  .order-meta {
    font-size: 12px !important;
  }

  .order-price {
    font-size: 17px !important;
  }

  .verify-btn {
    width: 100%;
    justify-content: center;
    padding: 10px 16px !important;
    font-size: 13px !important;
  }

  .stats-row {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 10px !important;
  }

  .stat-box {
    padding: 12px 8px;
  }

  .stat-box .num {
    font-size: 22px;
  }

  .stat-box .lbl {
    font-size: 10px;
  }

  .modal-box {
    padding: 28px 22px;
    width: 94%;
  }

  .otp-input {
    font-size: 22px;
    letter-spacing: 8px;
    padding: 14px;
  }
}

/* ==========================================================================
   Admin Page Mobile Fixes
   ========================================================================== */
@media (max-width: 768px) {
  .lock-card {
    padding: 28px 22px;
  }

  .lock-card i {
    font-size: 36px;
  }

  .lock-card h2 {
    font-size: 20px;
  }

  .action-btns {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .btn-sm {
    padding: 6px 12px !important;
    font-size: 12px !important;
    width: 100%;
    text-align: center;
  }
}

/* ==========================================================================
   Basket Page Mobile Enhancements
   ========================================================================== */
@media (max-width: 576px) {
  .basket-item {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 10px !important;
    padding: 14px !important;
  }

  .basket-item img {
    width: 60px !important;
    height: 60px !important;
    border-radius: 10px !important;
  }

  .basket-item-info h3 {
    font-size: 14px;
  }

  .basket-item-info .item-price {
    font-size: 15px;
  }

  .qty-control {
    padding: 4px 10px;
    gap: 6px;
  }

  .qty-control button {
    width: 24px;
    height: 24px;
    font-size: 14px;
  }

  .qty-control span {
    font-size: 14px;
    min-width: 16px;
  }

  .remove-btn {
    font-size: 15px;
    padding: 6px;
  }

  .order-summary {
    padding: 18px;
  }
}

/* ==========================================================================
   Login / Signup Page Mobile Fixes
   ========================================================================== */
@media (max-width: 576px) {
  .form-container {
    margin: 20px auto !important;
    padding: 20px 16px !important;
    border-radius: 14px;
  }

  .form-container h2 {
    font-size: 20px;
  }

  .login-card {
    padding: 28px 22px !important;
  }

  .auth-card {
    padding: 25px 18px !important;
    margin: 20px auto !important;
  }
}

/* ==========================================================================
   Utility: Hide text on mobile for compact buttons
   ========================================================================== */
@media (max-width: 480px) {
  .hide-mobile-text {
    display: none;
  }
}

.profile-btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 30px;
}

@media (max-width: 480px) {
  .profile-btn-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Small Phone Fixes (320px - 374px: iPhone SE, Galaxy Fold, etc.)
   ========================================================================== */
@media (max-width: 374px) {
  .container {
    width: 96%;
    padding: 0 4px;
  }

  header {
    padding: 10px 0;
  }

  header h1 {
    font-size: 15px;
  }

  .logo {
    height: 34px;
  }

  .hamburger-btn {
    font-size: 20px;
  }

  nav a {
    font-size: 13px !important;
    padding: 8px 12px !important;
  }

  .search-bar {
    margin: 15px 0;
    flex-direction: column;
    border-radius: 14px;
    gap: 8px;
    padding: 8px;
  }

  .search-bar input {
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    width: 100%;
  }

  .search-bar button {
    border-radius: 10px;
    padding: 10px;
    width: 100%;
    font-size: 14px;
  }

  .category-tabs {
    gap: 8px;
    margin-bottom: 20px;
  }

  .category-tab {
    padding: 10px 14px;
    border-radius: 10px;
  }

  .category-tab i {
    font-size: 16px;
    margin-bottom: 4px;
  }

  .category-tab span {
    font-size: 11px;
  }

  .product-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .product-card img {
    height: 140px;
  }

  .btn {
    padding: 10px 18px;
    font-size: 13px;
  }

  .basket-item {
    padding: 12px !important;
    gap: 8px !important;
  }

  .basket-item img {
    width: 50px !important;
    height: 50px !important;
  }

  .basket-item-info h3 {
    font-size: 13px;
  }

  .basket-item-info .item-price {
    font-size: 14px;
  }

  .qty-control {
    padding: 3px 8px;
    gap: 4px;
  }

  .qty-control button {
    width: 22px;
    height: 22px;
    font-size: 13px;
  }

  .order-summary {
    padding: 14px;
  }

  .summary-row {
    font-size: 13px;
    padding: 8px 0;
  }

  .form-container {
    padding: 16px 12px !important;
    margin: 15px auto !important;
  }

  .form-group input,
  .form-group select {
    padding: 10px 8px;
    font-size: 16px;
  }

  .shop-tabs-container h3,
  h3[onclick*="switchTab"] {
    font-size: 12px !important;
    padding: 8px 10px !important;
  }

  .dashboard-table td {
    font-size: 12px;
    padding: 6px 0;
    padding-left: 38%;
  }

  .dashboard-table td::before {
    font-size: 10px;
    width: 35%;
  }

  .empty-basket {
    padding: 40px 10px;
  }

  .empty-basket > i {
    font-size: 48px;
  }

  .empty-basket h2 {
    font-size: 18px;
  }

  .empty-basket .btn {
    padding: 10px 22px;
    font-size: 14px;
  }
}

/* ==========================================================================
   Medium Phone (375px - 575px: iPhone 12, Pixel, Galaxy S)
   ========================================================================== */
@media (min-width: 375px) and (max-width: 575px) {
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .product-card img {
    height: 120px;
  }

  .product-info {
    padding: 10px;
  }

  .product-title {
    font-size: 14px;
  }

  .product-price {
    font-size: 17px;
  }

  .search-bar input {
    padding: 10px 15px;
    font-size: 14px;
  }

  .search-bar button {
    padding: 0 18px;
    font-size: 13px;
  }
}

/* ==========================================================================
   Large Phone / Small Tablet (576px - 768px)
   ========================================================================== */
@media (min-width: 576px) and (max-width: 768px) {
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }

  .product-card img {
    height: 140px;
  }
}

/* ==========================================================================
   Tablet and Desktop (> 768px)
   ========================================================================== */
@media (min-width: 769px) {
  .hamburger-btn {
    display: none;
  }

  nav {
    width: auto;
    max-height: none;
    order: 2;
  }

  nav ul {
    flex-direction: row;
    gap: 5px;
    padding: 0;
  }

  nav a {
    padding: 8px 14px !important;
    font-size: 14px !important;
    border-bottom: none;
    border-radius: 8px !important;
  }

  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 24px;
  }
}
