/* ===========================================
   orangeM - Responsive Fixes
   Custom fixes for mobile responsiveness
   =========================================== */

/* ===== HORIZONTAL SCROLL CONTAINERS ===== */
.scroll-container {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-behavior: smooth;
  position: relative;
}

.scroll-container::-webkit-scrollbar {
  display: none;
}

/* Improve horizontal scrolling on mobile */
@media (max-width: 768px) {
  .scroll-container {
    scroll-snap-type: x mandatory;
    scroll-padding: 1rem;
  }

  .scroll-container > a,
  .scroll-container > div {
    scroll-snap-align: center;
    scroll-snap-stop: normal;
  }
}

/* ===== CUISINE CATEGORIES - MOBILE OPTIMIZED ===== */
.cuisine-category-item {
  min-width: fit-content;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  /* Optimize cuisine category cards for small mobile */
  .cuisine-category-item .cuisine-circle {
    width: 68px !important;
    height: 68px !important;
  }

  .cuisine-category-item .cuisine-name {
    font-size: 0.6875rem !important; /* 11px */
    max-width: 68px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Adjust gap in scroll container for cuisines */
  section .scroll-container {
    gap: 0.875rem !important; /* 14px - tighter spacing on mobile */
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    margin-left: -1rem !important;
    margin-right: -1rem !important;
  }
}

@media (min-width: 641px) and (max-width: 768px) {
  /* Medium mobile/tablet optimization */
  .cuisine-category-item .cuisine-circle {
    width: 76px !important;
    height: 76px !important;
  }

  .cuisine-category-item .cuisine-name {
    font-size: 0.75rem !important; /* 12px */
  }

  section .scroll-container {
    gap: 1rem !important;
  }
}

@media (min-width: 769px) {
  /* Desktop - normal sizing */
  .cuisine-category-item .cuisine-circle {
    width: 80px !important;
    height: 80px !important;
  }
}

/* ===== FILTER SIDEBAR - CLEAN REWRITE ===== */

/* Backdrop */
#filter-backdrop {
  display: none;
}

#filter-backdrop:not(.hidden) {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 998;
  display: block;
}

/* Sidebar Wrapper - Desktop */
.filter-sidebar-wrapper {
  display: none;
}

@media (min-width: 1024px) {
  .filter-sidebar-wrapper {
    display: block;
    width: 18rem; /* 288px */
    flex-shrink: 0;
    align-self: flex-start;
    position: sticky;
    top: 7rem;
  }

  .filter-sidebar-container {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid #f3f4f6;
  }
}

/* Sidebar Wrapper - Mobile */
@media (max-width: 1023px) {
  .filter-sidebar-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 320px;
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    /* Mobilde varsayılan olarak gizli - sadece buton ile açılır */
  }

  /* Sidebar açıkken görünür yap */
  body.filter-sidebar-open .filter-sidebar-wrapper {
    display: block;
  }

  .filter-sidebar-wrapper.translate-x-0 {
    transform: translateX(0);
  }

  .filter-sidebar-container {
    background: white;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
  }

  /* Mobile header */
  .filter-sidebar-container > div:first-child {
    flex-shrink: 0;
  }

  /* Scrollable content */
  .filter-sidebar-container > div:last-child {
    flex: 1;
    min-height: 0; /* Critical for flex overflow */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Prevent body scroll when open */
body.filter-sidebar-open {
  overflow: hidden;
}

@media (max-width: 1023px) {
  body.filter-sidebar-open {
    position: fixed;
    width: 100%;
  }
}

/* Small screens */
@media (max-width: 375px) {
  .filter-sidebar-wrapper {
    width: 280px;
  }
}

/* ===== RESTAURANT CARDS - CLOSED INDICATOR ===== */
.restaurant-card-closed-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: inherit;
}

.restaurant-closed-badge {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  font-size: 0.875rem;
  font-weight: 800;
  padding: 0.625rem 1.25rem;
  border-radius: 1rem;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: pulse-scale 2s ease-in-out infinite;
}

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

/* Alternative badge for smaller cards */
.restaurant-closed-badge-small {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.375rem 0.75rem;
  border-radius: 0.5rem;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 11;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

/* ===== MOBILE SEARCH BAR SPACING ===== */
@media (max-width: 1024px) {
  .main-header-inner + form {
    padding-top: 0.5rem;
    padding-bottom: 0.875rem;
  }
}

@media (max-width: 640px) {
  .main-header-inner + form {
    padding-top: 0.375rem;
    padding-bottom: 0.75rem;
  }
}

/* ===== HERO SECTION - MOBILE SPACING FIX ===== */
/* Ensures hero content is not hidden under mobile search bar */
@media (max-width: 1024px) {
  /* Target hero section specifically */
  section.relative.overflow-hidden:first-child > div.relative.container {
    padding-top: 2.5rem !important; /* 40px for tablet */
  }
}

@media (max-width: 640px) {
  /* Mobile gets more padding due to smaller header */
  section.relative.overflow-hidden:first-child > div.relative.container {
    padding-top: 2rem !important; /* 32px for mobile */
  }
}

/* ===== LOAD MORE BUTTON VISIBILITY ===== */
.load-more-btn.hidden {
  display: none !important;
}

/* ===== CART ITEM CONTROLS FIX ===== */
.cart-item-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
}

.cart-item-controls button {
  cursor: pointer;
  transition: all 0.2s ease;
}

.cart-item-controls button:active {
  transform: scale(0.95);
}

.cart-item-controls button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== CHECKOUT PAGE - LOGGED OUT SECTIONS ===== */
.checkout-auth-required {
  opacity: 0.5;
  pointer-events: none;
  position: relative;
}

.checkout-auth-required::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.8), rgba(249, 250, 251, 0.9));
  border-radius: 1rem;
  backdrop-filter: blur(4px);
}

/* ===== IMPROVED MOBILE RESPONSIVENESS ===== */
@media (max-width: 640px) {
  /* Improve card spacing on mobile */
  .scroll-container {
    gap: 0.75rem;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* Adjust restaurant card widths for better mobile experience */
  .scroll-container .flex-shrink-0 {
    min-width: 280px;
    max-width: 85vw;
  }
}

/* ===== SMOOTH SCROLLING FOR ALL CONTAINERS ===== */
.scroll-container {
  scroll-behavior: smooth;
}

/* ===== FILTER SIDEBAR ANIMATION ===== */
#filter-sidebar.translate-x-0 {
  transform: translateX(0) !important;
}

#filter-sidebar.-translate-x-full {
  transform: translateX(-100%) !important;
}

/* ===== MOBILE MENU - RIGHT SIDE ANIMATION ===== */
#mobile-menu > div:last-child {
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

#mobile-menu:not(.hidden) > div:last-child {
  transform: translateX(0);
}

/* ===== ORDER RECEIPT MODAL - MOBILE RESPONSIVE ===== */
@media (max-width: 640px) {
  /* Modal backdrop */
  #orderModal {
    padding: 0 !important;
    align-items: stretch !important;
  }

  /* Modal container */
  #orderModal > div {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
  }

  /* Receipt container */
  #orderModal .receipt-container {
    border-radius: 0 !important;
    max-height: 100vh;
    max-height: 100dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Close button */
  #orderModal button[onclick="closeOrderModal()"] {
    top: 0.5rem !important;
    right: 0.5rem !important;
    width: 2rem !important;
    height: 2rem !important;
  }

  #orderModal button[onclick="closeOrderModal()"] svg {
    width: 1rem !important;
    height: 1rem !important;
  }

  /* Status banner */
  #orderModal .receipt-container > div:first-child {
    padding: 0.75rem 1rem !important;
  }

  #orderModal .receipt-container > div:first-child p:first-of-type {
    font-size: 0.625rem !important;
  }

  #orderModal .receipt-container > div:first-child p:last-of-type {
    font-size: 1rem !important;
  }

  /* Main content padding */
  #orderModal .receipt-container > div:last-child {
    padding: 1rem !important;
  }

  /* Restaurant logo */
  #orderModal .receipt-container img[alt] {
    width: 3.5rem !important;
    height: 3.5rem !important;
    margin-bottom: 0.5rem !important;
  }

  /* Restaurant name */
  #orderModal .receipt-container h2 {
    font-size: 1rem !important;
  }

  /* Info boxes */
  #orderModal .grid.grid-cols-2 > div {
    padding: 0.625rem !important;
  }

  /* Dividers spacing */
  #orderModal .receipt-divider {
    margin: 0.75rem 0 !important;
  }

  /* Section titles */
  #orderModal h4 {
    font-size: 0.625rem !important;
    margin-bottom: 0.5rem !important;
  }

  /* Order items */
  #orderModal .receipt-item-row {
    padding: 0.375rem 0 !important;
  }

  /* Totals section */
  #orderModal .space-y-1\.5,
  #orderModal .space-y-2 {
    gap: 0.375rem !important;
  }

  /* Total text */
  #orderModal .text-xl {
    font-size: 1.25rem !important;
  }

  #orderModal .text-2xl {
    font-size: 1.5rem !important;
  }

  /* Payment info box */
  #orderModal .bg-gray-50.rounded-lg {
    padding: 0.625rem !important;
  }

  /* Action buttons */
  #orderModal button[onclick*="cancelOrder"],
  #orderModal button[onclick*="showAddressChangeModal"],
  #orderModal button[onclick*="reorder"] {
    padding: 0.625rem 0.75rem !important;
    font-size: 0.8125rem !important;
  }

  /* Timer badges */
  #orderModal .receipt-cancel-timer,
  #orderModal .receipt-address-timer {
    padding: 0.625rem 0.75rem !important;
    font-size: 0.75rem !important;
  }

  /* Barcode wrapper */
  #orderModal .barcode-wrapper {
    padding: 0.5rem 0 !important;
  }

  #orderModal .barcode-svg {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Footer text */
  #orderModal .text-center.mt-4 p,
  #orderModal .text-center.mt-6 p {
    font-size: 0.625rem !important;
  }

  /* Notes box */
  #orderModal .bg-amber-50 {
    padding: 0.625rem !important;
  }

  /* Customer info icons */
  #orderModal [data-lucide="user"],
  #orderModal [data-lucide="phone"],
  #orderModal [data-lucide="map-pin"] {
    width: 0.875rem !important;
    height: 0.875rem !important;
  }
}

@media (max-width: 375px) {
  /* Extra small screens */
  #orderModal .receipt-container h2 {
    font-size: 0.9375rem !important;
  }

  #orderModal .text-xl {
    font-size: 1.125rem !important;
  }

  #orderModal .text-2xl {
    font-size: 1.375rem !important;
  }
}

/* ===== REVIEW MODAL - MOBILE RESPONSIVE ===== */
@media (max-width: 640px) {
  .review-modal-container {
    width: 100vw !important;
    max-width: 100vw !important;
    margin: 0 !important;
    border-radius: 0 !important;
    max-height: 100vh;
    max-height: 100dvh;
  }

  .review-modal-content {
    max-height: 100vh;
    max-height: 100dvh;
    overflow-y: auto;
  }

  /* Header adjustments */
  #reviewModal .bg-gradient-to-br {
    padding: 1rem 1rem 1.5rem 1rem !important;
  }

  #reviewModal .bg-gradient-to-br img {
    width: 4rem !important;
    height: 4rem !important;
    margin-bottom: 0.5rem !important;
  }

  #reviewModal .bg-gradient-to-br h2 {
    font-size: 1.125rem !important;
    margin-bottom: 0.25rem !important;
  }

  #reviewModal .bg-gradient-to-br p {
    font-size: 0.75rem !important;
  }

  /* Close button */
  #reviewModal .absolute.top-4.right-4 {
    top: 0.75rem !important;
    right: 0.75rem !important;
    width: 2rem !important;
    height: 2rem !important;
  }

  #reviewModal .absolute.top-4.right-4 svg {
    width: 1rem !important;
    height: 1rem !important;
  }

  /* Content padding */
  #reviewModal .p-5 {
    padding: 1rem !important;
  }

  #reviewModal .space-y-6 > * + * {
    margin-top: 1.25rem !important;
  }

  /* Rating section */
  #reviewModal .text-lg {
    font-size: 1rem !important;
  }

  #reviewModal .star-rating {
    gap: 0.5rem !important;
  }

  #reviewModal .star-btn {
    width: 2.5rem !important;
    height: 2.5rem !important;
  }

  /* Textarea */
  #reviewModal .review-textarea {
    min-height: 5rem !important;
    font-size: 0.875rem !important;
    padding: 0.75rem !important;
  }

  /* Item ratings */
  #reviewModal .review-item-row {
    padding: 0.625rem !important;
    gap: 0.5rem !important;
  }

  #reviewModal .review-item-image {
    width: 2.5rem !important;
    height: 2.5rem !important;
  }

  #reviewModal .review-item-name {
    font-size: 0.8125rem !important;
  }

  #reviewModal .like-dislike-btn {
    width: 2rem !important;
    height: 2rem !important;
    padding: 0.25rem !important;
  }

  #reviewModal .like-dislike-btn svg {
    width: 1rem !important;
    height: 1rem !important;
  }

  /* Courier rating section */
  #reviewModal .bg-gray-50 {
    padding: 0.75rem !important;
  }

  #reviewModal .bg-gray-50 .w-14 {
    width: 2.75rem !important;
    height: 2.75rem !important;
  }

  #reviewModal .bg-gray-50 .w-14 svg {
    width: 1.25rem !important;
    height: 1.25rem !important;
  }

  #reviewModal .bg-gray-50 h4 {
    font-size: 0.875rem !important;
  }

  #reviewModal .bg-gray-50 p {
    font-size: 0.75rem !important;
  }
}

@media (max-width: 375px) {
  /* Extra small screens */
  #reviewModal .star-btn {
    width: 2rem !important;
    height: 2rem !important;
  }

  #reviewModal .review-item-image {
    width: 2rem !important;
    height: 2rem !important;
  }

  #reviewModal .review-item-name {
    font-size: 0.75rem !important;
  }

  #reviewModal .like-dislike-btn {
    width: 1.75rem !important;
    height: 1.75rem !important;
  }
}

/* ===== AUTH MODALS (LOGIN & REGISTER) - MOBILE FIX ===== */
@media (max-width: 640px) {
  /* Modal overlay - allow scrolling */
  #login-modal.modal-overlay,
  #register-modal.modal-overlay {
    padding: 0 !important;
    align-items: flex-start !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* Modal container - full width on mobile */
  #login-modal .modal-container,
  #register-modal .modal-container {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 0 !important;
    max-height: none !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    display: flex;
    flex-direction: column;
  }

  /* Header - ensure it's visible */
  #login-modal .modal-container > div:first-child,
  #register-modal .modal-container > div:first-child {
    flex-shrink: 0 !important;
    padding-top: max(2rem, env(safe-area-inset-top)) !important;
  }

  /* Body content - scrollable */
  #login-modal .modal-container > div:last-child,
  #register-modal .modal-container > div:last-child {
    flex: 1 !important;
    overflow-y: visible !important;
    padding-bottom: max(2rem, env(safe-area-inset-bottom)) !important;
  }

  /* Close button positioning */
  #login-modal button[onclick*="close"],
  #register-modal button[onclick*="close"] {
    top: max(1rem, env(safe-area-inset-top)) !important;
  }
}

/* Very small screens (iPhone SE, etc) */
@media (max-width: 375px) {
  #login-modal .modal-container > div:first-child,
  #register-modal .modal-container > div:first-child {
    padding-left: 1.5rem !important;
    padding-right: 1.5rem !important;
    padding-top: max(1.5rem, env(safe-area-inset-top)) !important;
    padding-bottom: 2rem !important;
  }

  #login-modal .modal-container > div:last-child,
  #register-modal .modal-container > div:last-child {
    padding: 1.5rem !important;
  }
}
