/* ============================================================
   Mobile Menu — Global hamburger + drawer (Faz M1)
   Auto-applied to .main-header / .account-header / .admin-header
   Breakpoints:
     ≤ 720px : mobile (hamburger active)
     721-1024 : tablet (current desktop layout, slight tweaks)
     ≥ 1025 : desktop (untouched)
   ============================================================ */

:root {
  --bp-mobile: 720px;
  --bp-tablet: 1024px;
}

/* Hamburger button — hidden by default (desktop) */
.tio-hamburger {
  align-items: center;
  background: transparent;
  border: 1px solid rgba(28, 26, 23, 0.18);
  border-radius: 4px;
  color: #1a1714;
  cursor: pointer;
  display: none; /* shown only via media query */
  flex-direction: column;
  flex-shrink: 0;
  gap: 4px;
  height: 38px;
  justify-content: center;
  padding: 0;
  transition: border-color 0.18s ease, background 0.18s ease;
  width: 42px;
  z-index: 60;
}
.tio-hamburger:hover {
  border-color: rgba(28, 26, 23, 0.4);
}
.tio-hamburger-line {
  background: #1a1714;
  border-radius: 2px;
  display: block;
  height: 1.5px;
  transition: transform 0.22s ease, opacity 0.18s ease;
  width: 18px;
}

/* Drawer container — hidden by default */
.tio-mobile-drawer {
  background: #fff;
  bottom: 0;
  box-shadow: -8px 0 24px rgba(28, 26, 23, 0.08);
  display: flex;
  flex-direction: column;
  max-width: 360px;
  pointer-events: none;
  position: fixed;
  right: 0;
  top: 0;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0.24, 1);
  visibility: hidden;
  width: 86%;
  z-index: 1100;
}
.tio-mobile-drawer.open {
  pointer-events: auto;
  transform: translateX(0);
  visibility: visible;
}
.tio-mobile-drawer-backdrop {
  background: rgba(18, 16, 14, 0);
  bottom: 0;
  left: 0;
  pointer-events: none;
  position: fixed;
  right: 0;
  top: 0;
  transition: background 0.28s ease;
  z-index: 1099;
}
.tio-mobile-drawer-backdrop.open {
  background: rgba(18, 16, 14, 0.42);
  pointer-events: auto;
}
.tio-mobile-drawer-header {
  align-items: center;
  border-bottom: 1px solid rgba(28, 26, 23, 0.08);
  display: flex;
  justify-content: space-between;
  padding: 18px 22px;
}
.tio-mobile-drawer-brand {
  align-items: center;
  display: flex;
  gap: 10px;
}
.tio-mobile-drawer-brand img {
  border-radius: 50%;
  height: 30px;
  object-fit: cover;
  width: 30px;
}
.tio-mobile-drawer-brand strong {
  color: #1a1714;
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.tio-mobile-drawer-close {
  background: transparent;
  border: 1px solid rgba(28, 26, 23, 0.18);
  border-radius: 4px;
  color: #1a1714;
  cursor: pointer;
  font-size: 0.92rem;
  height: 34px;
  line-height: 1;
  padding: 0;
  width: 34px;
}
.tio-mobile-drawer-close:hover {
  border-color: #1a1714;
}

.tio-mobile-drawer-nav {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  padding: 14px 0;
}
.tio-mobile-drawer-nav a {
  border-bottom: 1px solid rgba(28, 26, 23, 0.06);
  color: #1a1714;
  display: block;
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 16px 22px;
  text-decoration: none;
  transition: background 0.16s ease, color 0.16s ease;
}
.tio-mobile-drawer-nav a:hover,
.tio-mobile-drawer-nav a.active {
  background: #faf8f5;
  color: #1a1714;
}
.tio-mobile-drawer-nav-section {
  color: rgba(36, 32, 29, 0.42);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  margin: 14px 22px 4px;
  text-transform: uppercase;
}

.tio-mobile-drawer-footer {
  border-top: 1px solid rgba(28, 26, 23, 0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 22px 24px;
}
.tio-mobile-drawer-action {
  align-items: center;
  background: #1a1714;
  border: 1px solid #1a1714;
  border-radius: 3px;
  color: #fff;
  display: flex;
  font-size: 0.74rem;
  font-weight: 600;
  justify-content: center;
  letter-spacing: 0.14em;
  padding: 12px 18px;
  text-decoration: none;
  text-transform: uppercase;
  transition: background 0.18s ease;
}
.tio-mobile-drawer-action:hover {
  background: #2e2a27;
}
.tio-mobile-drawer-action.ghost {
  background: transparent;
  border: 1px solid rgba(28, 26, 23, 0.22);
  color: #1a1714;
}
.tio-mobile-drawer-action.ghost:hover {
  background: #faf8f5;
  border-color: #1a1714;
}

/* Body lock when drawer open */
body.tio-menu-open {
  overflow: hidden;
}

/* ===== Mobile activation (≤ 720px) ===== */
@media (max-width: 720px) {
  .tio-hamburger {
    display: flex;
  }
  .main-header,
  .account-header,
  .admin-header {
    flex-wrap: nowrap;
    gap: 10px;
    padding: 14px 16px !important;
  }
  /* Hide desktop nav on mobile (drawer takes over) */
  .main-header .main-nav,
  .account-header .account-main-nav,
  .admin-header .admin-main-nav {
    display: none !important;
  }
  /* Compact brand text */
  .main-header .brand-text small,
  .account-header .brand-text small {
    font-size: 0.62rem;
  }
  .main-header .brand-text strong,
  .account-header .brand-text strong {
    font-size: 0.84rem;
  }
  .main-header .brand-logo,
  .account-header .brand-logo,
  .admin-header .brand-logo {
    height: 36px;
    width: 36px;
  }
  /* Header right elements compact on mobile */
  .main-header .header-right {
    align-items: center;
    display: flex;
    gap: 8px;
  }
  .main-header .header-search {
    display: none; /* search moves into drawer or stays accessible via cart icons row */
  }
  .main-header .account-actions .button-ghost {
    display: none; /* login button moves into drawer */
  }
  .main-header .cart-button {
    flex-shrink: 0;
  }
  /* Make header sticky on mobile for better UX */
  .main-header,
  .account-header {
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 50;
  }
  /* Hide info ribbon's longer items, keep only first */
  .info-ribbon {
    font-size: 0.66rem;
    gap: 14px;
    padding: 8px 12px;
  }
  .info-ribbon p:nth-child(3) {
    display: none;
  }
}

/* Very narrow phones */
@media (max-width: 380px) {
  .main-header .brand-text small,
  .account-header .brand-text small {
    display: none;
  }
  .info-ribbon p:nth-child(2) {
    font-size: 0.6rem;
  }
}

/* Force hide drawer on desktop (safety) */
@media (min-width: 721px) {
  .tio-mobile-drawer,
  .tio-mobile-drawer-backdrop {
    display: none !important;
  }
  body.tio-menu-open {
    overflow: auto;
  }
}

/* ============================================================
   Mobile Shop (Faz M2) — homepage / product grid / filters
   ============================================================ */

/* Filter trigger button (injected by mobile-shop.js) — hidden on desktop */
.tio-filter-trigger {
  align-items: center;
  background: #fff;
  border: 1px solid rgba(28, 26, 23, 0.18);
  border-radius: 3px;
  color: #1a1714;
  cursor: pointer;
  display: none; /* shown only on mobile */
  font: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  gap: 8px;
  justify-content: center;
  letter-spacing: 0.14em;
  padding: 12px 18px;
  text-transform: uppercase;
  transition: border-color 0.18s ease, background 0.18s ease;
  width: 100%;
}
.tio-filter-trigger:hover {
  border-color: #1a1714;
}
.tio-filter-trigger-count {
  background: #1a1714;
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  font-size: 0.62rem;
  height: 18px;
  letter-spacing: 0;
  min-width: 18px;
  padding: 0 5px;
  align-items: center;
  justify-content: center;
}
.tio-filter-trigger-count.empty {
  display: none;
}

@media (max-width: 720px) {
  /* === Filter bottom sheet === */
  .store-filters {
    display: none !important;
    background: #fff;
    border-bottom: none;
    border-top: 1px solid rgba(136, 126, 109, 0.16);
    bottom: 0;
    box-shadow: 0 -8px 28px rgba(28, 26, 23, 0.12);
    grid-template-columns: 1fr;
    left: 0;
    margin: 0;
    max-height: 80vh;
    padding: 18px 18px calc(18px + env(safe-area-inset-bottom, 0px));
    position: fixed;
    right: 0;
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0.24, 1);
    z-index: 1100;
    overflow-y: auto;
  }
  body.tio-filters-open .store-filters {
    display: grid !important;
    transform: translateY(0);
  }
  body.tio-filters-open {
    overflow: hidden;
  }
  /* Hide the desktop inline "Filtreleri Temizle" button on mobile — sheet has its own */
  .filter-actions {
    display: none !important;
  }
}
.tio-filter-backdrop {
  background: rgba(18, 16, 14, 0);
  bottom: 0;
  display: none;
  left: 0;
  pointer-events: none;
  position: fixed;
  right: 0;
  top: 0;
  transition: background 0.28s ease;
  z-index: 1099;
}
@media (max-width: 720px) {
  body.tio-filters-open .tio-filter-backdrop {
    background: rgba(18, 16, 14, 0.42);
    display: block;
    pointer-events: auto;
  }
  .tio-filter-trigger {
    display: flex;
    margin: 0 0 14px;
  }
  /* "Bitir" close header inside the sheet */
  .tio-filter-sheet-head {
    align-items: center;
    border-bottom: 1px solid rgba(28, 26, 23, 0.08);
    display: none; /* injected only on mobile */
    grid-column: 1 / -1;
    justify-content: space-between;
    margin: -2px 0 12px;
    padding-bottom: 12px;
  }
  body.tio-filters-open .tio-filter-sheet-head {
    display: flex;
  }
  .tio-filter-sheet-head strong {
    color: #1a1714;
    font-size: 0.84rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
  .tio-filter-sheet-close {
    background: transparent;
    border: 1px solid rgba(28, 26, 23, 0.18);
    border-radius: 4px;
    color: #1a1714;
    cursor: pointer;
    font-size: 0.92rem;
    height: 32px;
    line-height: 1;
    padding: 0;
    width: 32px;
  }
  .tio-filter-sheet-actions {
    background: #fff;
    border-top: 1px solid rgba(28, 26, 23, 0.08);
    bottom: 0;
    display: none;
    gap: 10px;
    grid-column: 1 / -1;
    margin: 12px -18px -18px;
    padding: 14px 18px calc(14px + env(safe-area-inset-bottom, 0px));
    position: sticky;
  }
  body.tio-filters-open .tio-filter-sheet-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .tio-filter-sheet-actions button {
    background: #1a1714;
    border: 1px solid #1a1714;
    border-radius: 3px;
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    padding: 12px 14px;
    text-transform: uppercase;
  }
  .tio-filter-sheet-actions button.ghost {
    background: transparent;
    border-color: rgba(28, 26, 23, 0.22);
    color: #1a1714;
  }

  /* === Hero stack and tighter typography on phones === */
  .hero-slab {
    gap: 12px !important;
    padding: 14px !important;
  }
  .hero-panel-lead h1 {
    font-size: clamp(1.4rem, 7vw, 1.9rem) !important;
    line-height: 1.15;
  }
  .hero-panel-lead .hero-copy,
  .hero-panel-lead .hero-mini {
    font-size: 0.84rem;
  }
  .hero-panel-card {
    padding: 16px;
  }

  /* === Quote / values stack === */
  .quote-strip {
    padding: 28px 16px !important;
  }
  .quote-strip p {
    font-size: 0.92rem !important;
  }

  /* === Product grid: 2-col by default, 1-col only on very narrow === */
  .product-grid {
    gap: 12px !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .store-shell {
    padding: 14px !important;
  }
  .store-card-info {
    padding: 10px 10px 12px !important;
  }
  .store-card-name {
    font-size: 0.82rem !important;
  }
  .store-card-price {
    font-size: 0.86rem !important;
  }

  /* === Top category tabs: horizontal scroll === */
  .top-category-tabs {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden;
    padding-bottom: 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .top-category-tabs::-webkit-scrollbar {
    display: none;
  }
  .top-category-tabs > * {
    flex-shrink: 0 !important;
  }

  /* === Marquee carousel cards more compact === */
  .marquee-item-card {
    min-width: min(220px, 72vw) !important;
    width: 220px !important;
  }
  .marquee-head {
    padding: 0 14px;
  }

  /* === Sort & search controls full width === */
  .controls {
    padding: 0 14px 14px !important;
  }

  /* === Sections breathing room === */
  .marquee-shell {
    padding: 22px 0 !important;
  }
}

@media (max-width: 380px) {
  .product-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================================
   Mobile M3 — Product detail / Cart drawer / Checkout
   ============================================================ */

@media (max-width: 720px) {
  /* === Cart drawer full width on mobile === */
  .cart-drawer {
    width: 100vw !important;
    max-width: 100vw !important;
    border-left: none !important;
  }
  body.look-koton .cart-drawer {
    border-left: none !important;
  }
  .cart-drawer .drawer-header {
    padding: 14px 16px;
    position: sticky;
    top: 0;
    background: inherit;
    z-index: 5;
  }
  .cart-drawer .cart-items {
    padding: 0 14px;
  }
  /* Sticky checkout button at the bottom of drawer */
  .cart-drawer .drawer-summary {
    background: inherit;
    border-top: 1px solid rgba(28, 26, 23, 0.06);
    bottom: 0;
    margin: 0 !important;
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px)) !important;
    position: sticky;
  }
  body.look-koton .cart-drawer .drawer-summary {
    background: #fff;
  }
  .cart-drawer #checkout-button {
    margin-top: 10px;
    padding: 14px;
    width: 100%;
  }

  /* === Product detail mobile === */
  .product-detail-main {
    padding: 12px !important;
  }
  body.look-koton.product-page .product-detail-shell {
    grid-template-columns: 1fr !important;
    gap: 18px !important;
    padding: 0 !important;
  }
  body.look-koton.product-page .product-detail-gallery-stage {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }
  /* Move thumbs to a horizontal scrolling row below main image on mobile */
  body.look-koton.product-page .product-detail-thumbs.product-detail-thumbs-rail {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    grid-row: 2 !important;
    height: auto !important;
    margin: 0 !important;
    max-height: none !important;
    order: 2;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 4px 0 8px !important;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  body.look-koton.product-page .product-detail-thumbs.product-detail-thumbs-rail::-webkit-scrollbar {
    display: none;
  }
  body.look-koton.product-page .product-detail-thumbs .product-detail-thumb {
    flex-shrink: 0 !important;
    width: 64px !important;
    height: 80px !important;
  }
  body.look-koton.product-page .product-detail-main-image-wrap {
    order: 1;
  }
  body.look-koton.product-page .product-detail-name {
    font-size: 1.1rem !important;
  }
  body.look-koton.product-page .product-detail-info {
    padding: 0 !important;
  }
  body.look-koton.product-page .modal-price-line {
    font-size: 1.1rem;
  }
  /* Add bottom padding so sticky CTA doesn't cover content */
  body.product-page .product-detail-main {
    padding-bottom: calc(82px + env(safe-area-inset-bottom, 0px)) !important;
  }
  /* Sticky add-to-cart bar at bottom of viewport */
  body.product-page .detail-form-actions {
    background: #fff;
    border-top: 1px solid rgba(28, 26, 23, 0.10);
    bottom: 0;
    box-shadow: 0 -4px 16px rgba(28, 26, 23, 0.05);
    display: flex !important;
    gap: 10px !important;
    grid-template-columns: none !important;
    left: 0;
    margin: 0 !important;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    position: fixed;
    right: 0;
    z-index: 40;
  }
  body.product-page .detail-form-actions .detail-qty-wrap {
    flex: 0 0 auto;
    width: 78px;
  }
  body.product-page .detail-form-actions #detail-add-button {
    flex: 1;
    margin: 0 !important;
    min-height: 46px;
  }

  /* === Checkout page mobile === */
  .checkout-page {
    grid-template-columns: 1fr !important;
    margin: 12px auto 80px !important;
    width: 100% !important;
    padding: 0 12px;
  }
  /* Reorder: cart summary first (collapsible), then form */
  .checkout-page-left { order: 2; }
  .checkout-page-right { order: 1; }
  .checkout-page-left,
  .checkout-page-right {
    border-radius: 6px !important;
    padding: 14px !important;
  }
  .checkout-page-right h2 {
    cursor: pointer;
    user-select: none;
  }
  .checkout-page-right h2::after {
    content: " ▾";
    color: rgba(36, 32, 29, 0.4);
    font-size: 0.8em;
    transition: transform 0.18s ease;
    display: inline-block;
  }
  body.tio-summary-collapsed .checkout-page-right h2::after {
    transform: rotate(-90deg);
  }
  body.tio-summary-collapsed .checkout-page-right > *:not(h2) {
    display: none !important;
  }
  /* Single column inputs */
  .checkout-page .input-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  .checkout-page .input-grid label.full,
  .checkout-page .input-grid > div.full {
    grid-column: auto !important;
  }
  /* Sticky "Siparişi Tamamla" button */
  .checkout-page #complete-order-button {
    background: #fff;
    border-top: 1px solid rgba(28, 26, 23, 0.10);
    bottom: 0;
    box-shadow: 0 -4px 16px rgba(28, 26, 23, 0.05);
    left: 0;
    margin: 0 !important;
    padding: 14px !important;
    position: fixed;
    right: 0;
    width: 100%;
    z-index: 40;
    border-radius: 0 !important;
  }
  body.look-koton .checkout-page #complete-order-button {
    background: #1a1714;
    color: #fff;
    padding: 16px !important;
  }
  body.look-koton .checkout-page #complete-order-button:hover {
    background: #2e2a27;
  }

  /* === Checkout meta footer keeps spacing for fixed CTA === */
  .checkout-meta-footer {
    margin-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* ============================================================
   Mobile M4 — Hesabım (account) page
   ============================================================ */

@media (max-width: 720px) {
  body.account-page .account-main {
    padding: 12px !important;
  }
  body.account-page .hero-card {
    padding: 18px !important;
    margin-bottom: 12px !important;
  }
  body.account-page .hero-card h1 {
    font-size: 1.1rem !important;
    line-height: 1.3 !important;
  }
  body.account-page .hero-card p {
    font-size: 0.84rem !important;
  }

  body.account-page .account-grid {
    gap: 12px !important;
  }

  /* Tab row: keep 3 horizontal buttons, compact typography */
  body.account-page .tab-row {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 6px !important;
  }
  body.account-page .tab-button {
    font-size: 0.7rem !important;
    letter-spacing: 0.06em !important;
    min-height: 38px !important;
    padding: 0 6px !important;
  }

  /* Auth tabs (login/register switch) compact */
  body.account-page .auth-tabs {
    grid-template-columns: 1fr 1fr !important;
    gap: 6px !important;
  }
  body.account-page .auth-tabs button {
    font-size: 0.74rem !important;
    padding: 10px !important;
  }

  /* Stack-form single column inputs already, just tighten */
  body.account-page .stack-form {
    gap: 12px !important;
  }
  body.account-page .stack-form input,
  body.account-page .stack-form select,
  body.account-page .stack-form textarea {
    font-size: 0.92rem !important;
    padding: 10px 12px !important;
  }
  body.account-page .stack-form > button[type="submit"] {
    margin-top: 4px;
    min-height: 44px !important;
  }

  /* Cards padding tighter */
  body.account-page .card {
    padding: 14px !important;
  }

  /* Address book */
  body.account-page .address-book-list {
    display: grid !important;
    gap: 10px !important;
  }
  body.account-page .address-book-item {
    padding: 14px !important;
  }
  body.account-page .address-book-actions {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  body.account-page .address-book-actions button {
    flex: 1 1 calc(50% - 4px);
    min-height: 38px;
  }

  /* Forgot password actions stack on phone */
  body.account-page .forgot-password-actions {
    flex-direction: column !important;
    gap: 8px !important;
  }
  body.account-page .forgot-password-actions button {
    width: 100%;
  }

  /* Order item hover transform off (no hover on touch) */
  body.account-page .order-item:hover {
    transform: none !important;
  }
  /* Order action row buttons full-width stacked */
  body.account-page .order-actions {
    flex-direction: column;
    gap: 6px;
  }
  body.account-page .order-action-btn {
    min-height: 40px;
    width: 100%;
  }

  /* Saved addresses card list compact */
  body.account-page .saved-addresses-list {
    display: grid !important;
    gap: 8px !important;
  }
  body.account-page .saved-address-item {
    padding: 12px !important;
  }

  /* Settings sub-sections breathing room */
  body.account-page #settings-view section {
    margin-bottom: 18px;
  }
  body.account-page #settings-view h3 {
    font-size: 0.84rem;
    letter-spacing: 0.08em;
    margin-bottom: 10px;
    text-transform: uppercase;
  }

  /* Make sticky header from M1 transparent against the warm background */
  body.account-page .account-header {
    background: rgba(255, 250, 244, 0.96) !important;
  }
}

/* Override the existing 640px stacking of tab-row (poor UX) */
@media (max-width: 640px) {
  body.account-page .tab-row {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
  body.account-page .auth-tabs {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* Very narrow phones */
@media (max-width: 380px) {
  body.account-page .tab-button {
    font-size: 0.62rem !important;
    letter-spacing: 0.04em !important;
  }
  body.account-page .hero-card h1 {
    font-size: 1rem !important;
  }
}
