/* CSS Custom Properties for Search Width Synchronization */
:root {
  --search-width-desktop: 300px;
  --search-width-tablet: 120px;
  --search-width-mobile: 100px;
  --search-width-small: 80px;
  --search-width-tiny: 70px;
  --search-height-desktop: 40px;
  --search-height-tablet: 36px;
  --search-height-mobile: 32px;
  --search-height-small: 28px;
  --search-height-tiny: 26px;

  /* Additional responsive variables for better control */
  --search-width-large-tablet: 200px;
  --search-width-medium-mobile: 110px;
  --search-height-large-tablet: 38px;
  --search-height-medium-mobile: 34px;
}

.qili-header {
  background-color: #232f3e;
  color: white;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 1fr 2fr 1fr; /* Equal outer sections, larger middle for search */
  align-items: center;
  gap: 20px; /* Add gap between sections for visual separation */
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  z-index: 10000; /* Increased z-index to be above sub-header */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  overflow: visible; /* Ensure dropdown can overflow the header */
  min-width: 320px; /* Prevent total collapse on very small screens */
}

/* Ensure proper flex distribution for better search bar width */
@media (max-width: 1200px) {
  .qili-header {
    grid-template-columns: minmax(120px, 1fr) minmax(200px, 2fr) minmax(
        180px,
        1fr
      ); /* Better minimum sizes */
  }

  .qili-header-middle-section {
    max-width: 450px; /* Further reduce on larger tablets */
    margin: 0 12px;
  }
}

@media (max-width: 1024px) {
  .qili-header {
    grid-template-columns: minmax(100px, 1fr) minmax(180px, 2fr) minmax(
        160px,
        1fr
      ); /* Tighter constraints */
  }

  .qili-header-left-section {
    width: 80px; /* Further reduced for more search space */
    min-width: 60px;
  }

  .qili-header-middle-section {
    margin: 0 10px;
    max-width: none; /* Remove constraint on tablets */
    min-width: 200px;
  }

  .qili-header-right-section {
    width: 160px; /* Increased to accommodate cart, auth, and proper spacing */
  }
}

/* Additional breakpoint for better tablet sizing */
@media (max-width: 900px) {
  .qili-header {
    grid-template-columns: minmax(90px, 1fr) minmax(160px, 2fr) minmax(
        150px,
        1fr
      );
  }

  .search-bar {
    width: var(--search-width-large-tablet) !important;
    height: var(--search-height-large-tablet);
    min-width: 120px;
  }

  .search-button {
    height: var(--search-height-large-tablet);
  }

  .search-history-dropdown {
    width: calc(
      var(--search-width-large-tablet) + 40px
    ) !important; /* Add large tablet button width */
    min-width: calc(var(--search-width-large-tablet) + 40px) !important;
    max-width: calc(var(--search-width-large-tablet) + 40px) !important;
    top: calc(var(--search-height-large-tablet) - 1px);
  }
}

/* Add new breakpoint to handle cutoff at 980px+ range */
@media (max-width: 1024px) {
  .qili-header {
    grid-template-columns: minmax(140px, 1fr) minmax(140px, 1.5fr) minmax(
        200px,
        1.3fr
      ); /* Narrow search, expand right section for cart+auth grouping */
    gap: 8px;
    padding: 0 10px;
  }

  .qili-header-left-section {
    min-width: 140px;
  }

  .qili-header-right-section {
    min-width: 200px;
    display: flex;
    gap: 4px; /* Tight gap to keep cart near auth buttons */
    justify-content: flex-end;
    align-items: center;
  }

  /* Slightly reduce button padding to fit better */
  .dashboard-link,
  .data-management-link,
  .cart-link,
  .header-auth-btn {
    padding: 0.4rem 0.6rem; /* More compact */
  }

  /* Make search narrower */
  .search-bar {
    width: var(
      --search-width-mobile
    ) !important; /* Use mobile width for compactness */
    height: var(--search-height-mobile);
    min-width: 120px;
  }

  .search-button {
    height: var(--search-height-mobile);
  }

  .search-history-dropdown {
    width: calc(var(--search-width-mobile) + 32px) !important;
    max-width: calc(var(--search-width-mobile) + 32px) !important;
  }
}

/* Earlier breakpoint to start protecting right section */
@media (max-width: 950px) {
  .qili-header {
    grid-template-columns: minmax(80px, 0.8fr) minmax(150px, 1.8fr) minmax(
        160px,
        1.1fr
      ); /* Start giving more space to right section */
    gap: 8px;
    padding: 0 8px;
  }

  .qili-header-right-section {
    min-width: 160px;
  }

  /* Start reducing auth button size earlier */
  .header-auth-btn {
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
  }
}

/* Add new breakpoint to handle the problematic screen width */
@media (max-width: 850px) {
  .qili-header {
    grid-template-columns: minmax(50px, 0.5fr) minmax(120px, 1.5fr) minmax(
        200px,
        1.5fr
      ); /* Much more space to right section */
    gap: 4px;
    padding: 0 4px;
  }

  .qili-header-left-section {
    gap: 4px;
  }

  .qili-header-right-section {
    gap: 4px;
    min-width: 200px; /* Increased minimum width */
  }

  /* Start hiding auth button text earlier */
  .header-auth-btn {
    padding: 0.25rem 0.4rem;
    font-size: 0.75rem;
  }

  /* Make left buttons smaller */
  .dashboard-link,
  .data-management-link {
    width: 28px;
    height: 28px;
  }

  .dashboard-link::before,
  .data-management-link::before {
    font-size: 14px;
  }
}

.qili-header-left-section {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px; /* Reduced gap to match right section spacing */
  padding: 4px 8px; /* Match right section padding for consistent alignment */
  flex-shrink: 1; /* Allow some shrinking but maintain usability */
  min-width: fit-content; /* Ensure minimum width */
  overflow: visible; /* Prevent cutoff */
  height: 52px; /* Explicit height to match right section */
}

/* Force both left buttons to always be visible */
.dashboard-link,
.data-management-link {
  flex-shrink: 0; /* Prevent shrinking/disappearing */
  min-width: 32px;
  min-height: 32px;
}

.header-link {
  display: inline-block;
  padding: 6px;
  border-radius: 2px;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid rgba(0, 0, 0, 0);
}

.header-link:hover {
  border: 1px solid white;
}

.qili-header-middle-section {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative; /* Ensure this is the positioning context for the dropdown */
  overflow: visible; /* Ensure dropdown can overflow the container */
  z-index: 10001; /* Higher than sub-header to create proper stacking context */
  flex-shrink: 1; /* Allow shrinking when space is limited */
  min-width: 0; /* Allow shrinking below content size */
}

/* Mobile search centering - ensure search bar is properly constrained */
@media (max-width: 768px) {
  .qili-header {
    display: grid;
    grid-template-columns: minmax(50px, 0.6fr) minmax(120px, 1.4fr) minmax(
        180px,
        1.2fr
      ); /* More aggressive space allocation for right section */
    align-items: center;
    gap: 6px; /* Further reduced gap */
    padding: 0 6px; /* Further reduced padding */
  }

  .qili-header-left-section {
    padding: 2px 4px; /* Further reduced padding */
    gap: 4px;
  }

  .qili-header-right-section {
    padding: 2px 4px; /* Further reduced padding */
    gap: 4px;
    min-width: 180px; /* Increased minimum width */
  }

  /* Ensure left section buttons are smaller */
  .dashboard-link,
  .data-management-link {
    width: 28px;
    height: 28px;
  }

  .dashboard-link::before,
  .data-management-link::before {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .qili-header {
    padding: 0 4px;
    gap: 4px; /* Tight gap for mobile */
    grid-template-columns: minmax(40px, 0.6fr) minmax(80px, 1.2fr) minmax(
        120px,
        1fr
      ); /* Prioritize right section space */
  }

  .qili-header-left-section {
    padding: 2px 4px; /* Minimal padding for mobile */
    gap: 4px;
  }

  .qili-header-right-section {
    padding: 2px 4px; /* Minimal padding for mobile */
    gap: 3px;
    min-width: 120px; /* Ensure minimum width */
  }
}

/* Additional breakpoint for medium mobile screens */
@media (max-width: 600px) {
  .qili-header {
    grid-template-columns: minmax(50px, 0.7fr) minmax(90px, 1.3fr) minmax(
        140px,
        1fr
      ); /* Even more space for right section */
    gap: 6px;
    padding: 0 6px;
  }

  .search-bar {
    width: var(--search-width-medium-mobile) !important;
    height: var(--search-height-medium-mobile);
    min-width: 80px; /* Reduced minimum width */
    padding: 0 6px;
    font-size: 14px;
  }

  .search-button {
    height: var(--search-height-medium-mobile);
    min-width: 34px; /* Reduced button width */
  }

  .search-history-dropdown {
    width: calc(
      var(--search-width-medium-mobile) + 34px
    ) !important; /* Add medium mobile button width */
    min-width: calc(var(--search-width-medium-mobile) + 34px) !important;
    max-width: calc(var(--search-width-medium-mobile) + 34px) !important;
    top: calc(var(--search-height-medium-mobile) - 1px);
  }

  .qili-header-right-section {
    min-width: 140px;
    gap: 4px;
  }
}

@media (max-width: 360px) {
  .qili-header {
    padding: 0 4px;
    gap: 2px; /* Tight gap for small screens */
    grid-template-columns: 64px 1fr 112px; /* Fixed widths for consistent layout */
    align-items: center;
  }

  .qili-header-left-section {
    display: flex;
    gap: 2px;
    justify-content: flex-start;
  }

  .qili-header-middle-section {
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .qili-header-right-section {
    display: flex;
    gap: 2px;
    justify-content: flex-end;
    align-items: center;
  }

  /* Ensure all buttons have same height */
  .dashboard-link,
  .data-management-link,
  .cart-link,
  .header-auth-btn {
    width: 30px !important;
    height: 30px !important;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
  }

  /* Search bar sizing */
  .search-bar {
    width: 100%;
    height: 30px !important;
    font-size: 12px;
    min-width: unset;
  }

  .search-button {
    height: 30px !important;
    width: 30px !important;
  }
}

@media (max-width: 320px) {
  .qili-header {
    padding: 0 3px;
    gap: 2px; /* Ultra-tight gap for smallest screens */
    grid-template-columns: 60px 1fr 100px; /* Fixed widths for smallest screens */
    align-items: center;
  }

  .qili-header-left-section {
    display: flex;
    gap: 2px;
    justify-content: flex-start;
  }

  .qili-header-middle-section {
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .qili-header-right-section {
    display: flex;
    gap: 1px;
    justify-content: flex-end;
    align-items: center;
  }

  /* Ensure all buttons have same height - smaller for 320px */
  .dashboard-link,
  .data-management-link,
  .cart-link,
  .header-auth-btn {
    width: 28px !important;
    height: 28px !important;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
  }

  /* Search bar sizing */
  .search-bar {
    width: 100%;
    height: 28px !important;
    font-size: 11px;
    min-width: unset;
  }

  .search-button {
    height: 28px !important;
    width: 28px !important;
  }
}

/* Search bar styles */
.search-bar {
  width: var(
    --search-width-desktop
  ) !important; /* Force CSS variable for synchronized width */
  max-width: 100%;
  height: var(
    --search-height-desktop
  ); /* Use CSS variable for synchronized height */
  padding: 0 15px;
  border: 1px solid #ddd; /* Add border to match dropdown */
  border-right: none; /* Remove right border to connect with button */
  border-radius: 4px 0 0 4px;
  font-size: 16px;
  transition: all 0.2s ease;
  box-sizing: border-box; /* Ensure consistent box model */
  flex-shrink: 1; /* Allow shrinking when space is limited */
  min-width: 120px; /* Ensure minimum usable width */
}

@media (max-width: 768px) {
  .search-bar {
    width: var(--search-width-tablet) !important; /* Force CSS variable */
    height: var(--search-height-tablet); /* Use CSS variable */
    padding: 0 10px;
    font-size: 14px;
    min-width: 100px; /* Adjusted minimum width for tablet */
  }
}

@media (max-width: 480px) {
  .search-bar {
    width: var(--search-width-mobile) !important; /* Force CSS variable */
    height: var(--search-height-mobile); /* Use CSS variable */
    padding: 0 6px;
    font-size: 13px;
    min-width: 70px; /* Reduced minimum width for mobile */
    max-width: 100px; /* Add maximum width constraint */
  }
}

@media (max-width: 360px) {
  .search-bar {
    width: var(--search-width-small) !important; /* Force CSS variable */
    padding: 0 3px; /* Minimal padding */
    font-size: 12px;
    height: var(--search-height-small); /* Use CSS variable */
    min-width: 50px; /* Smaller minimum width for small screens */
    max-width: 80px; /* Add maximum width constraint */
  }
}

@media (max-width: 320px) {
  /* Mobile search bar sizing to match container constraints */
  .search-bar {
    width: var(--search-width-tiny) !important; /* Force CSS variable */
    height: var(--search-height-tiny); /* Use CSS variable */
    padding: 0 2px;
    font-size: 11px;
    min-width: 40px; /* Very small minimum width for tiny screens */
    max-width: 70px; /* Add maximum width constraint */
  }
}

.search-bar::placeholder {
  color: rgb(146, 146, 146);
}

.search-bar:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 48, 135, 0.2);
}

.search-button {
  min-width: 45px;
  height: var(
    --search-height-desktop
  ); /* Use CSS variable to match search bar */
  background-color: #1a252f;
  border: 1px solid #ddd; /* Add border to match search bar */
  border-left: none; /* Remove left border to connect with search bar */
  border-radius: 0 4px 4px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .search-button {
    min-width: 36px; /* Reduced */
    height: var(--search-height-tablet); /* Use CSS variable */
  }
}

@media (max-width: 480px) {
  .search-button {
    min-width: 32px; /* Reduced */
    height: var(--search-height-mobile); /* Use CSS variable */
  }
}

@media (max-width: 360px) {
  .search-button {
    min-width: 28px; /* Reduced to match smaller search bar */
    height: var(--search-height-small); /* Use CSS variable */
  }
}

@media (max-width: 320px) {
  .search-button {
    min-width: 26px;
    height: var(--search-height-tiny); /* Use CSS variable */
  }
}

.search-button:hover {
  background-color: #2c3a49;
}

.search-icon {
  width: 22px;
  height: 22px;
  filter: brightness(0) invert(1); /* Make icon white */
}

@media (max-width: 768px) {
  .search-icon {
    width: 18px;
    height: 18px;
  }
}

@media (max-width: 480px) {
  .search-icon {
    width: 16px;
    height: 16px;
  }
}

@media (max-width: 360px) {
  .search-icon {
    width: 14px;
    height: 14px;
  }
}

@media (max-width: 320px) {
  .search-icon {
    width: 12px;
    height: 12px;
  }
}

/* Extra small screens optimization */
/* Search History Dropdown */
.search-history-dropdown {
  position: absolute;
  top: calc(
    var(--search-height-desktop) - 1px
  ); /* Use CSS variable for height */
  left: 50%; /* Center horizontally */
  transform: translateX(
    -50%
  ); /* Center the dropdown with the search container */
  background: white;
  border: 1px solid #ddd;
  border-top: none; /* Remove top border to connect seamlessly with search bar */
  border-radius: 0 0 4px 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000; /* High z-index relative to parent stacking context */
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  max-height: 250px;
  overflow-y: auto;
  pointer-events: none;
  /* Match width of entire search container (search bar + button) */
  width: calc(
    var(--search-width-desktop) + 45px
  ) !important; /* Add button width */
  min-width: calc(var(--search-width-desktop) + 45px) !important;
  max-width: calc(var(--search-width-desktop) + 45px) !important;
  box-sizing: border-box !important; /* Force same box model as search bar */
}

.search-history-dropdown.show {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateX(-50%) !important; /* Maintain centering when shown */
  z-index: 1001 !important; /* Slightly higher when shown */
  pointer-events: auto !important;
}

.search-history-header {
  padding: 8px 12px;
  background: #f5f5f5;
  border-bottom: 1px solid #e0e0e0;
  font-size: 12px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center; /* Center the text */
}

.search-history-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  font-size: 14px;
  color: #333;
  transition: background-color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.search-history-item:hover {
  background-color: #f8f8f8;
}

.search-history-item:last-child {
  border-bottom: none;
}

.search-history-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 8px;
}

.search-history-time {
  font-size: 11px;
  color: #999;
  flex-shrink: 0;
  font-weight: 500;
}

.search-history-clear {
  padding: 10px 12px;
  text-align: center;
  font-size: 12px;
  color: #666;
  cursor: pointer;
  border-top: 1px solid #e0e0e0;
  background: #f9f9f9;
  transition: all 0.2s ease;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.search-history-clear:hover {
  background-color: #f0f0f0;
  color: #333;
}

.search-history-empty {
  padding: 20px 12px;
  text-align: center;
  font-size: 13px;
  color: #999;
  font-style: italic;
}

@media (max-width: 768px) {
  .search-history-dropdown {
    max-height: 200px;
    width: calc(
      var(--search-width-tablet) + 36px
    ) !important; /* Add tablet button width */
    min-width: calc(var(--search-width-tablet) + 36px) !important;
    max-width: calc(var(--search-width-tablet) + 36px) !important;
    top: calc(
      var(--search-height-tablet) - 1px
    ); /* Use CSS variable for height */
  }

  .search-history-item {
    padding: 8px 10px;
    font-size: 13px;
  }

  .search-history-time {
    font-size: 10px;
  }

  .search-history-header {
    padding: 6px 10px;
    font-size: 11px;
  }

  .search-history-clear {
    padding: 8px 10px;
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  .search-history-dropdown {
    max-height: 180px;
    width: calc(
      var(--search-width-mobile) + 32px
    ) !important; /* Add mobile button width */
    min-width: calc(var(--search-width-mobile) + 32px) !important;
    max-width: calc(var(--search-width-mobile) + 32px) !important;
    top: calc(
      var(--search-height-mobile) - 1px
    ); /* Use CSS variable for height */
  }

  .search-history-item {
    padding: 6px 8px;
    font-size: 12px;
  }

  .search-history-header {
    padding: 5px 8px;
    font-size: 10px;
  }

  .search-history-clear {
    padding: 6px 8px;
    font-size: 10px;
  }

  .search-history-empty {
    padding: 15px 8px;
    font-size: 12px;
  }
}

@media (max-width: 360px) {
  .search-history-dropdown {
    width: calc(
      var(--search-width-small) + 28px
    ) !important; /* Add small button width */
    min-width: calc(var(--search-width-small) + 28px) !important;
    max-width: calc(var(--search-width-small) + 28px) !important;
    top: calc(
      var(--search-height-small) - 1px
    ); /* Use CSS variable for height */
  }
}

/* Extra small screens */
@media (max-width: 320px) {
  .search-history-dropdown {
    width: calc(
      var(--search-width-tiny) + 26px
    ) !important; /* Add tiny button width */
    min-width: calc(var(--search-width-tiny) + 26px) !important;
    max-width: calc(var(--search-width-tiny) + 26px) !important;
    top: calc(
      var(--search-height-tiny) - 1px
    ); /* Use CSS variable for height */
  }
}

.qili-header-right-section {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px; /* Reduced spacing to save space */
  padding: 4px 8px; /* Reduced padding to save space */
  flex-shrink: 0; /* Prevent shrinking to ensure icons remain visible */
  min-width: fit-content; /* Ensure minimum width to contain icons */
  overflow: visible; /* Prevent icon cutoff */
  white-space: nowrap; /* Prevent text wrapping */
  height: 52px; /* Explicit height to match left section */
}

/* Hide the orders link since it's empty and just taking space */
.orders-link {
  display: none;
}

/* Mobile right section optimizations */
@media (max-width: 768px) {
  .qili-header-right-section {
    gap: 4px; /* Tighter spacing for mobile to keep cart close to auth icons */
  }
}

@media (max-width: 480px) {
  .qili-header-right-section {
    gap: 3px; /* Even tighter spacing on smaller screens */
  }
}

@media (max-width: 360px) {
  .qili-header-right-section {
    gap: 2px; /* Minimal gap for ultra-compact layout */
  }
}

@media (max-width: 320px) {
  .qili-header-right-section {
    gap: 2px; /* Maintain minimal gap */
  }
}

@media (max-width: 360px) {
  .qili-header-right-section {
    justify-content: space-between; /* Distribute evenly */
  }
}

@media (max-width: 320px) {
  .qili-header-right-section {
    justify-content: space-between; /* Distribute icons evenly */
  }
}

.dashboard-link {
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  flex-shrink: 0;
  color: #cbd5e0;
  background: transparent;
  border: 1px solid #4a5568;
  height: 44px; /* Explicit height for consistent alignment */
  box-sizing: border-box; /* Include border in height calculation */
}

.dashboard-link:hover {
  background: #4a5568;
  color: white;
}

/* Mobile dashboard button optimizations */
@media (max-width: 768px) {
  .dashboard-text {
    display: none; /* Hide text label on smaller screens */
  }
}

@media (max-width: 480px) {
  .dashboard-link {
    width: 32px;
    height: 32px;
  }
}

@media (max-width: 360px) {
  .dashboard-link {
    width: 28px;
    height: 28px;
  }
}

@media (max-width: 320px) {
  .dashboard-link {
    width: 24px;
    height: 24px;
  }
}

.data-management-link {
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap; /* Change back to nowrap for single line */
  flex-shrink: 0;
  color: white;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: 1px solid transparent;
  height: 44px; /* Explicit height for consistent alignment */
  box-sizing: border-box; /* Include border in height calculation */
}

.data-management-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Mobile data management button optimizations - match dashboard sizing */
@media (max-width: 900px) {
  .dashboard-link,
  .data-management-link {
    padding: 0;
    font-size: 0;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .dashboard-text,
  .data-management-text {
    display: none;
  }

  .dashboard-link i,
  .data-management-link i {
    width: 16px;
    height: 16px;
  }
}
@media (max-width: 768px) {
  .data-management-text {
    display: none; /* Hide text label on smaller screens */
  }
}

@media (max-width: 480px) {
  .data-management-link {
    width: 32px;
    height: 32px;
  }
}

@media (max-width: 360px) {
  .data-management-link {
    width: 28px;
    height: 28px;
  }
}

@media (max-width: 320px) {
  .data-management-link {
    width: 24px;
    height: 24px;
  }
}

.orders-link {
  color: white;
}

.returns-text {
  display: block;
  font-size: 13px;
}

.orders-text {
  display: block;
  font-size: 15px;
  font-weight: 700;
}

.cart-link {
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  flex-shrink: 0;
  color: #cbd5e0;
  background: transparent;
  border: 1px solid #4a5568;
  position: relative;
  height: 44px; /* Explicit height for consistent alignment */
  box-sizing: border-box; /* Include border in height calculation */
}

.cart-link:hover {
  background: #4a5568;
  color: white;
}

.cart-quantity {
  color: white;
  font-size: 11px;
  font-weight: 700;
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
  border: 2px solid white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}

/* Mobile cart button sizing adjustments */
@media (max-width: 900px) {
  .cart-link {
    padding: 0;
    font-size: 0;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .cart-text {
    display: none;
  }

  .cart-quantity {
    position: absolute;
    top: -6px;
    right: -6px;
    font-size: 9px;
    width: 18px;
    height: 18px;
    min-height: 14px;
    border: 1.5px solid white;
  }
}

/* Authentication styles for header */
.auth-section {
  display: flex;
  align-items: center;
  margin-left: 1rem; /* Reduced margin for better mobile fit */
  flex-shrink: 0; /* Prevent shrinking */
}

.auth-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem; /* Reduced gap for mobile */
  flex-shrink: 0; /* Prevent shrinking */
}

.header-auth-btn {
  padding: 0.4rem 0.8rem; /* Reduced padding for mobile */
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.85rem; /* Smaller font for mobile */
  font-weight: 500;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.4rem; /* Reduced gap */
  white-space: nowrap;
  flex-shrink: 0; /* Prevent shrinking */
  height: 44px; /* Explicit height for consistent alignment */
  box-sizing: border-box; /* Include border in height calculation */
}

.header-auth-btn.signin {
  color: #cbd5e0;
  background: transparent;
  border: 1px solid #4a5568;
}

.header-auth-btn.signin:hover {
  background: #4a5568;
  color: white;
}

.header-auth-btn.signup {
  color: white;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: 1px solid transparent;
}

.header-auth-btn.signup:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* User menu in header */
.user-menu {
  position: relative;
  display: inline-block;
  flex-shrink: 0; /* Prevent shrinking */
}

.user-avatar {
  width: 44px; /* Match auth button height */
  height: 44px; /* Match auth button height */
  border-radius: 8px; /* Match auth button border radius */
  background: linear-gradient(
    135deg,
    #667eea 0%,
    #764ba2 100%
  ); /* Match signup button gradient */
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem; /* Match auth button font size */
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); /* Match auth button transition */
  flex-shrink: 0; /* Prevent shrinking */
  border: 1px solid transparent; /* Match auth button border */
  position: relative;
  overflow: hidden; /* For hover effect */
  letter-spacing: 0.025em;
}

/* Add shimmer effect like auth buttons */
.user-avatar::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left 0.5s ease;
}

.user-avatar:hover::before {
  left: 100%;
}

.user-avatar:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  min-width: 240px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.user-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-dropdown::before {
  content: "";
  position: absolute;
  top: -6px;
  right: 12px;
  width: 12px;
  height: 12px;
  background: rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: none;
  border-right: none;
  transform: rotate(45deg);
}

.dropdown-header {
  padding: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.dropdown-name {
  font-weight: 600;
  color: #ffffff;
  margin: 0;
  font-size: 0.95rem;
}

.dropdown-email {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
  margin: 0.25rem 0 0 0;
}

.dropdown-menu {
  list-style: none;
  margin: 0;
  padding: 0.5rem 0;
}

.dropdown-item {
  margin: 0;
}

.dropdown-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 0.9rem;
  border-radius: 8px;
  margin: 0 0.5rem;
}

.dropdown-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  transform: translateX(4px);
}

.dropdown-link i {
  width: 16px;
  height: 16px;
  color: rgba(255, 255, 255, 0.6);
  transition: color 0.3s ease;
}

.dropdown-link:hover i {
  color: #6366f1;
}

.dropdown-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0.5rem 0;
  border: none;
}

/* Responsive authentication */
/* Add even earlier breakpoint to start transitioning auth buttons */
@media (max-width: 950px) {
  .auth-section {
    margin-left: 0.4rem;
  }

  .auth-buttons {
    gap: 0.3rem;
  }

  .header-auth-btn {
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
  }
}

/* Add earlier breakpoint to start transitioning auth buttons */
@media (max-width: 850px) {
  .auth-section {
    margin-left: 0.3rem;
  }

  .auth-buttons {
    gap: 0.25rem;
  }

  .header-auth-btn {
    padding: 0.25rem 0.4rem;
    font-size: 0.75rem;
  }
}

@media (max-width: 768px) {
  .auth-section {
    margin-left: 0.5rem;
  }

  .auth-buttons {
    gap: 0.3rem;
  }

  .header-auth-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
  }

  .user-avatar {
    width: 26px;
    height: 26px;
    font-size: 0.75rem;
  }

  .user-dropdown {
    right: -1rem;
    min-width: 180px;
  }
}

@media (max-width: 900px) {
  .auth-section {
    margin-left: 0;
  }

  .auth-buttons {
    gap: 0.2rem;
  }

  .header-auth-btn {
    padding: 0;
    font-size: 0;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Hide all text content and show only icons */
  .header-auth-btn .auth-btn-text {
    display: none;
  }

  .header-auth-btn.signin .auth-btn-text::before,
  .header-auth-btn.signup .auth-btn-text::before {
    display: none;
  }

  .user-avatar {
    width: 24px;
    height: 24px;
    font-size: 0.65rem;
  }

  .header-auth-btn i {
    display: block !important; /* Show icons on mobile */
    width: 18px;
    height: 18px;
  }
}

@media (max-width: 480px) {
  .header-auth-btn {
    width: 32px;
    height: 32px;
  }

  .header-auth-btn i {
    width: 16px;
    height: 16px;
  }

  .user-avatar {
    width: 20px;
    height: 20px;
    font-size: 0.6rem;
  }
}

@media (max-width: 360px) {
  .auth-section {
    margin-left: 0;
  }

  .auth-buttons {
    gap: 0.15rem;
  }

  .header-auth-btn {
    width: 28px;
    height: 28px;
  }

  .header-auth-btn i {
    width: 14px;
    height: 14px;
  }

  .user-avatar {
    width: 18px;
    height: 18px;
    font-size: 0.55rem;
  }
}

@media (max-width: 320px) {
  .header-auth-btn {
    width: 24px;
    height: 24px;
  }

  .header-auth-btn i {
    width: 12px;
    height: 12px;
  }

  .user-avatar {
    width: 16px;
    height: 16px;
    font-size: 0.5rem;
  }
}
