/**
 * TEDARICK layout stabilization — footer stick, page shells, grids
 */

html {
  height: 100%;
}

body.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  min-height: 100dvh;
}

body.app-shell .site-main {
  flex: 1 0 auto;
  width: 100%;
}

/* Static / legal pages (hakkimizda, sss, cerez) */
.section.page-shell {
  padding: 3rem 0 4rem;
}

.page-shell .container {
  max-width: 720px;
}

.page-shell h1 {
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  font-weight: 700;
  color: var(--token-graphite, #0f1419);
  margin: 0 0 1rem;
  line-height: 1.2;
}

.page-shell h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
  color: var(--token-graphite, #0f1419);
}

.page-shell p,
.page-shell li {
  color: var(--token-slate-700, #475569);
  line-height: 1.7;
  margin-bottom: 0.75rem;
}

.page-shell ul {
  list-style: disc;
  padding-left: 1.25rem;
  margin-bottom: 1rem;
}

.page-shell a {
  color: var(--token-accent, #1d4ed8);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  font-size: 0.8125rem;
  color: var(--token-slate-500, #64748b);
  margin-bottom: 1.5rem;
}

.breadcrumb a {
  color: var(--token-accent, #1d4ed8);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.page-shell .breadcrumb {
  margin-bottom: 1.5rem;
}

/* SEO landing pages */
.section.seo-landing {
  padding: 2.5rem 0 4rem;
}

.section.seo-landing h1 {
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  margin: 0 0 1rem;
}

/* Listing grid always visible */
.listing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
  width: 100%;
  margin: 1.25rem 0;
}

.listing-grid:empty {
  display: none;
}

/* Footer always at bottom, never collapsed */
.site-footer {
  flex-shrink: 0;
  margin-top: auto;
  width: 100%;
  position: relative;
  z-index: 1;
}

.footer-grid--full {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 1fr);
  gap: 2rem;
  padding: 3rem 0 2rem;
}

@media (max-width: 900px) {
  .footer-grid--full {
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
  }
}

@media (max-width: 560px) {
  .footer-grid--full {
    grid-template-columns: 1fr;
    padding: 2rem 0 1.5rem;
  }
}

/* Footer — mobil hizalama (yamuk / taşma düzeltmesi) */
@media (max-width: 767px) {
  .site-footer {
    overflow-x: clip;
  }

  .site-footer .container,
  .site-footer .footer-bottom.container {
    width: 100%;
    max-width: 100%;
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    box-sizing: border-box;
  }

  .site-footer .footer-grid--full {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1rem;
    padding: 2rem 0 1rem;
    margin: 0;
  }

  .site-footer .footer-brand {
    width: 100%;
    max-width: 20rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }

  .site-footer .footer-brand .logo {
    justify-content: center;
    margin: 0 auto;
  }

  .site-footer .footer-tagline {
    margin: 0;
    text-align: center;
    max-width: 28ch;
    line-height: 1.5;
    word-break: break-word;
  }

  .site-footer .footer-mobile-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.35rem 0.65rem;
    width: 100%;
    padding: 0.75rem 0 0;
    margin: 0;
    text-align: center;
    line-height: 1.4;
  }

  .site-footer .footer-mobile-bar span[aria-hidden="true"] {
    line-height: 1;
  }

  .site-footer .footer-bottom {
    padding-top: 1rem;
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
    text-align: center;
  }

  .site-footer .footer-bottom p {
    margin: 0;
    line-height: 1.55;
    word-break: break-word;
  }

  body.has-mobile-nav .site-footer {
    margin-bottom: 0;
  }
}

/* Corp homepage sections — ensure visible */
.corp-section {
  padding: 3.5rem 0 !important;
}

.corp-section--alt {
  background: var(--token-surface-raised, #f8fafc);
}

.corp-cta {
  padding: 3.5rem 0 !important;
  margin-bottom: 0;
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.faq-item {
  border: 1px solid var(--token-border, #e2e8f0);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  background: var(--token-surface, #fff);
}

.faq-item summary {
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item p {
  margin: 0.75rem 0 0;
  font-size: 0.9375rem;
}

/* Auth pages */
.site-footer--auth {
  margin-top: auto;
  padding: 1.25rem 0;
  background: var(--token-graphite, #0f1419);
  color: rgba(255, 255, 255, 0.75);
}

.footer-auth-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1rem 1.5rem;
  font-size: 0.8125rem;
}

.footer-auth-inner a {
  color: rgba(255, 255, 255, 0.85);
}

/* Messaging */
.page-messages {
  padding: 2rem 0 3rem;
}

.page-messages-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

.msg-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  min-height: 420px;
  border: 1px solid var(--token-border, #e2e8f0);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.msg-sidebar {
  border-right: 1px solid var(--token-border, #e2e8f0);
  background: var(--token-surface-raised, #f8fafc);
  overflow-y: auto;
  max-height: 70vh;
}

.msg-thread-item {
  display: block;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--token-border, #e2e8f0);
  text-decoration: none;
  color: inherit;
}

.msg-thread-item:hover,
.msg-thread-item.active {
  background: rgba(29, 78, 216, 0.08);
}

.msg-thread-item.unread strong {
  color: var(--token-accent, #1d4ed8);
}

.msg-thread-item small {
  display: block;
  font-size: 0.75rem;
  color: var(--token-slate-500, #64748b);
  margin-top: 0.2rem;
}

.msg-main {
  display: flex;
  flex-direction: column;
  min-height: 420px;
}

.msg-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: 55vh;
}

.msg-bubble {
  max-width: 85%;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  font-size: 0.875rem;
  line-height: 1.5;
}

.msg-bubble time {
  display: block;
  font-size: 0.6875rem;
  opacity: 0.65;
  margin-top: 0.35rem;
}

.msg-bubble.sent {
  align-self: flex-end;
  background: var(--token-accent, #1d4ed8);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-bubble.received {
  align-self: flex-start;
  background: #f1f5f9;
  border-bottom-left-radius: 4px;
}

.msg-compose {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--token-border, #e2e8f0);
}

.msg-compose .form-input {
  flex: 1;
}

.msg-placeholder,
.msg-empty-hint {
  padding: 2rem;
  text-align: center;
  color: var(--token-slate-500, #64748b);
  font-size: 0.875rem;
}

@media (max-width: 768px) {
  .msg-layout {
    grid-template-columns: 1fr;
  }

  .msg-layout--panel.has-active-chat .msg-threads {
    display: none !important;
  }

  .msg-layout--panel:not(.has-active-chat) .msg-main {
    display: none !important;
  }

  .msg-layout--panel:not(.has-active-chat) .msg-threads {
    max-height: none;
    border-right: none;
    border-bottom: none;
  }

  .msg-sidebar {
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--token-border, #e2e8f0);
  }
}

.corp-empty-state {
  padding: 2rem;
  text-align: center;
  background: var(--token-surface-raised, #f8fafc);
  border: 1px dashed var(--token-border, #e2e8f0);
  border-radius: 8px;
  color: var(--token-slate-600, #64748b);
}

/* Pazaryeri — kategori chip'leri (listings.php) */
.filter-chips-row {
  margin: 0 0 1rem;
  width: 100%;
  overflow: hidden;
}

.filter-bar-scroll {
  display: flex !important;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0.25rem 0 0.5rem;
}

@media (max-width: 767px) {
  .filter-bar-scroll.desktop-only,
  .desktop-only.filter-bar-scroll {
    display: none !important;
  }
}

.filter-bar-scroll::-webkit-scrollbar {
  display: none;
}

.filter-bar-scroll--wrap {
  flex-wrap: wrap !important;
  overflow-x: visible;
  margin-top: 1rem;
}

.filter-bar-scroll .filter-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  flex-shrink: 0;
  margin: 0;
  min-height: 40px;
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.25;
  white-space: nowrap;
  text-decoration: none;
  border-radius: 999px;
  background: var(--token-surface-raised, #f1f5f9);
  border: 1px solid var(--token-border, #e2e8f0);
  color: var(--token-slate-600, #475569);
  box-sizing: border-box;
}

.filter-bar-scroll .filter-chip:hover {
  border-color: var(--token-accent, #1d4ed8);
  color: var(--token-accent, #1d4ed8);
}

.filter-bar-scroll .filter-chip.active {
  background: rgba(29, 78, 216, 0.1);
  border-color: var(--token-accent, #1d4ed8);
  color: var(--token-accent, #1d4ed8);
  font-weight: 600;
}

.listings-mobile-toolbar .mobile-filter-bar {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}

.listings-mobile-toolbar .mobile-search-inline {
  flex: 1;
  min-width: 0;
}

.listings-mobile-toolbar .mobile-search-inline .th-input {
  width: 100%;
  min-height: 48px;
}

@media (min-width: 768px) {
  .listings-mobile-toolbar {
    display: none !important;
  }
}

/* Admin auth logo */
.auth-brand-logo {
  display: block;
  margin: 0 auto 1rem;
  max-width: 180px;
  height: auto;
  width: auto;
}

/* Mobil alt menü — ikon üstte, etiket altta (tüm sayfalarda aynı) */
.eco-mobile-nav {
  display: flex;
  flex-direction: row;
  justify-content: space-around;
  align-items: stretch;
  gap: 0;
  background: #fff;
  border-top: 1px solid var(--token-border, #e2e8f0);
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.06);
  padding: 0.4rem 0.25rem calc(0.4rem + env(safe-area-inset-bottom, 0px));
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
}

.eco-mobile-nav a {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-width: 0;
  min-height: 52px;
  padding: 0.35rem 0.2rem;
  border-radius: 0;
  font-size: 0.625rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: 0;
  text-align: center;
  text-decoration: none;
  color: var(--token-slate-500, #64748b);
  background: transparent;
  -webkit-tap-highlight-color: transparent;
}

.eco-mobile-nav a.active {
  color: var(--token-accent, #1d4ed8);
  font-weight: 600;
  background: transparent;
}

.eco-mobile-nav__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 1.5rem;
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
  color: inherit;
}

.eco-mobile-nav__icon svg {
  display: block;
  width: 1.375rem;
  height: 1.375rem;
  flex-shrink: 0;
}

.eco-mobile-nav__label {
  display: block;
  max-width: 100%;
  margin: 0;
  padding: 0;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.eco-mobile-nav__link--messages {
  position: relative;
}

.eco-mobile-nav__badge {
  position: absolute;
  top: 0.15rem;
  right: calc(50% - 1.75rem);
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.25rem;
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 1rem;
  text-align: center;
  color: #fff;
  background: #d97706;
  border-radius: 999px;
  box-sizing: border-box;
}

@media (max-width: 375px) {
  .eco-mobile-nav a {
    font-size: 0.6rem;
  }

  .eco-mobile-nav__icon svg {
    width: 1.25rem;
    height: 1.25rem;
  }
}

/* Mobil header — taşma ve çift satır düzeni (legacy header; v2 kendi CSS'ini kullanır) */
@media (max-width: 767px) {
  .site-header:not(.site-header--v2) {
    overflow: hidden;
  }

  .site-header:not(.site-header--v2) .header-inner {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    max-width: 100%;
    height: var(--header-h, 56px);
    padding-inline: 0.75rem;
    box-sizing: border-box;
  }

  .site-header:not(.site-header--v2) .header-inner .logo {
    flex: 0 1 auto;
    min-width: 0;
    max-width: calc(100% - 3.25rem);
    overflow: hidden;
  }

  .site-header:not(.site-header--v2) .header-inner .logo-img {
    height: 32px;
    max-width: 110px;
  }

  /* Görsel yanında tekrarlayan yazı markayı dar ekranda gizle */
  .site-header:not(.site-header--v2) .header-inner .logo-text {
    display: none !important;
  }

  .site-header:not(.site-header--v2) .nav-toggle {
    display: flex !important;
    flex: 0 0 auto;
    margin-left: auto;
    order: 10;
  }

  /* Giriş yapmış: Panel/Mesajlar alt menüde — üst bar sade */
  body.has-mobile-nav.is-logged-in .site-header:not(.site-header--v2) .header-actions {
    display: none !important;
  }

  body.has-mobile-nav.is-logged-in .site-header:not(.site-header--v2) .header-actions__desktop {
    display: none !important;
  }

  /* Misafir: yalnızca kompakt kayıt butonu */
  body.has-mobile-nav:not(.is-logged-in) .site-header:not(.site-header--v2) .header-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 0.35rem;
    margin-left: 0.25rem;
    max-width: 42%;
  }

  body.has-mobile-nav:not(.is-logged-in) .site-header:not(.site-header--v2) .header-actions .btn-primary.btn-sm {
    padding: 0.45rem 0.65rem;
    font-size: 0.75rem;
    white-space: nowrap;
  }
}
