/* ============================================================
   BTSK Global Mobile CSS Framework
   Tüm sayfalarda dahil edilir. Mevcut stilleri bozmadan
   mobile uyumluluğu sağlar.
   ============================================================ */

/* ── 1. RESET & TEMELLER ──────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  /* Bottom nav padding — body'nin en altına boşluk */
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* iOS zoom engelleme — input font-size < 16px olunca zoom yapar */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"],
input[type="week"],
select,
textarea {
  font-size: 16px !important;
}

/* ── 2. TOUCH-FRIENDLY HEDEFLER ───────────────────────────── */
button,
a.link,
a.chip,
a.btn,
a.quick-link,
.chip,
.btn,
.tab-btn,
.seg label span,
.recent-chip,
.quick-link,
.profile-trigger,
.accordion-header,
.collapsible-header,
.page-btn,
[role="button"],
[onclick] {
  min-height: 35px;
  /* İçerik yüksekliğini korumak için min-height kullanıyoruz */
}

/* Küçük inline butonlar istisna */
.smallbtn,
.badge {
  min-height: auto;
}

/* ── 3. SAFE AREA DESTEĞİ ────────────────────────────────── */
.wrap {
  padding-left: max(12px, env(safe-area-inset-left, 12px));
  padding-right: max(12px, env(safe-area-inset-right, 12px));
}

/* ── 4. RESPONSIVE UTILITY SINIFLARI ─────────────────────── */
.mobile-only {
  display: none !important;
}

.desktop-only {
  display: initial;
}

@media (max-width: 768px) {
  .mobile-only {
    display: initial !important;
  }
  .desktop-only {
    display: none !important;
  }
  .mobile-stack {
    flex-direction: column !important;
  }
  .mobile-full {
    width: 100% !important;
    max-width: 100% !important;
  }
  .mobile-gap-sm {
    gap: 8px !important;
  }
  /* Wrap içindeki padding ayarı */
  .wrap {
    padding-left: max(10px, env(safe-area-inset-left, 10px));
    padding-right: max(10px, env(safe-area-inset-right, 10px));
  }
}

/* ── 5. MOBİL HEADER DÜZENLEMELERİ ───────────────────────── */
@media (max-width: 768px) {
  /* Başlık alanları */
  h1, .title {
    font-size: clamp(20px, 5vw, 30px) !important;
    word-break: break-word;
  }

  /* Üst navigasyon linklerini gizle (mobile_nav kullanılacak) */
  .btsk-desktop-nav {
    display: none !important;
  }
}

/* ── 6. FORM ELEMANLARI MOBİL OPTİMİZASYON ───────────────── */
@media (max-width: 768px) {
  /* Form grid'leri tek sütuna */
  .form-grid,
  .contact-grid {
    grid-template-columns: 1fr !important;
  }
  .form-grid > .full,
  .contact-grid > .full {
    grid-column: 1 / -1;
  }

  /* Filter panelleri stack */
  .filters {
    flex-direction: column !important;
  }
  .filter-box {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* Input/Select tam genişlik */
  input,
  select,
  textarea {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Butonlar tam genişlik */
  .form-btn-row {
    flex-direction: column !important;
    gap: 8px !important;
  }
  .form-btn-row .btn {
    width: 100% !important;
  }
}

/* ── 7. MOBİL TABLO → CARD DÖNÜŞÜMÜ ──────────────────────── */
@media (max-width: 768px) {
  .btsk-responsive-table {
    border: none !important;
  }
  .btsk-responsive-table thead {
    display: none !important;
  }
  .btsk-responsive-table tbody {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
  }
  .btsk-responsive-table tr {
    display: flex !important;
    flex-direction: column !important;
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 14px !important;
    padding: 12px !important;
    gap: 6px !important;
  }
  .btsk-responsive-table td {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 6px 0 !important;
    border: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
    text-align: right !important;
    gap: 10px;
  }
  .btsk-responsive-table td:last-child {
    border-bottom: none !important;
  }
  .btsk-responsive-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: rgba(234, 240, 255, 0.65);
    font-size: 12px;
    text-align: left;
    flex-shrink: 0;
    min-width: 90px;
  }
}

/* ── 8. MOBİL MODAL SİSTEMİ ──────────────────────────────── */
@media (max-width: 640px) {
  /* Standart modal → bottom sheet */
  .modal-overlay {
    /* Bottom nav'ın arkasına girmesin — overlay bottom nav üstünde biter */
    bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
    align-items: flex-end !important;
    padding: 0 !important;
  }
  .modal-box,
  .modal-card {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92dvh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    border-radius: 20px 20px 0 0 !important;
    margin: 0 !important;
    animation: btsk-slide-up 0.3s ease-out;
  }
  .modal-box::before,
  .modal-card::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 2px;
    margin: 8px auto 12px;
  }
  /* Confirm box da bottom sheet olsun */
  .confirm-box {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    transform: none !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: 80dvh !important;
    width: 100% !important;
    animation: btsk-slide-up 0.3s ease-out;
  }
}

@keyframes btsk-slide-up {
  from {
    transform: translateY(100%);
    opacity: 0.5;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ── 9. MOBİL KARTlar ve PANELler ─────────────────────────── */
@media (max-width: 768px) {
  /* Grid kartlar tek sütuna */
  .main {
    grid-template-columns: 1fr !important;
  }

  /* Quick links 2 sütun */
  .quick-links {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  /* Stat grid 2 sütun */
  .grid:not(form) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  /* Stats bar sarmalansın */
  .stats {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }
  .stat {
    font-size: 12px !important;
    padding: 6px 10px !important;
  }

  /* Panel padding azalt */
  .panel {
    padding: 10px !important;
  }

  /* Card padding */
  .card {
    padding: 12px !important;
  }

  /* Bottom panels tek sütun */
  .bottom-panels {
    grid-template-columns: 1fr !important;
  }

  /* Kasa wrap stack */
  .kasa-wrap {
    flex-direction: column !important;
  }
}

@media (max-width: 480px) {
  /* Çok küçük ekranlar */
  .quick-links {
    grid-template-columns: 1fr !important;
  }
  .grid:not(form) {
    grid-template-columns: 1fr !important;
  }
}

/* ── 10. MOBİL NAVİGASYON: HAMBURGER MENÜ ────────────────── */
.btsk-hamburger {
  display: none;
  position: fixed;
  top: 12px;
  right: 12px;
  right: max(12px, env(safe-area-inset-right, 12px));
  z-index: 9999;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(99, 102, 241, 0.35);
  background: rgba(11, 27, 61, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
  padding: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s, background 0.2s;
}
.btsk-hamburger:active {
  transform: scale(0.92);
}
.btsk-hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: #eaf0ff;
  border-radius: 2px;
  transition: transform 0.3s, opacity 0.2s;
}
.btsk-hamburger.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.btsk-hamburger.open span:nth-child(2) {
  opacity: 0;
}
.btsk-hamburger.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

@media (max-width: 768px) {
  .btsk-hamburger {
    display: flex;
  }
}

/* Modal açıkken hamburger butonu gizle (modal içeriğiyle çakışmasın) */
body:has(.modal-overlay.open) .btsk-hamburger {
  display: none !important;
}

/* ── 11. SLIDE-OUT MENÜ ───────────────────────────────────── */
.btsk-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(3, 8, 20, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9990;
  opacity: 0;
  transition: opacity 0.3s;
}
.btsk-nav-overlay.open {
  display: block;
  opacity: 1;
}

.btsk-slide-nav {
  position: fixed;
  top: 0;
  right: 0;
  width: min(320px, 85vw);
  height: 100%;
  height: 100dvh;
  background: linear-gradient(180deg, #0b1b3d 0%, #061228 100%);
  border-left: 1px solid rgba(99, 102, 241, 0.2);
  z-index: 9995;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 70px 16px 100px;
  padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.btsk-slide-nav.open {
  transform: translateX(0);
}

.btsk-slide-nav a,
.btsk-slide-nav button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: #b6c5ea;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  min-height: 48px;
}
.btsk-slide-nav a:hover,
.btsk-slide-nav a:focus,
.btsk-slide-nav button:hover {
  background: rgba(99, 102, 241, 0.15);
  color: #eaf0ff;
}
.btsk-slide-nav a.active,
.btsk-slide-nav button.active {
  background: rgba(99, 102, 241, 0.22);
  color: #fff;
  font-weight: 700;
  border: 1px solid rgba(99, 102, 241, 0.3);
}
.btsk-slide-nav .nav-icon {
  font-size: 20px;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}
.btsk-slide-nav .nav-section {
  padding: 8px 16px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(182, 197, 234, 0.45);
  margin-top: 8px;
}
.btsk-slide-nav .nav-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  margin: 8px 0;
}

/* ── 12. BOTTOM NAVİGASYON BAR ────────────────────────────── */
.btsk-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9980;
  background: linear-gradient(180deg, rgba(11, 27, 61, 0.95) 0%, rgba(6, 18, 43, 0.98) 100%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(99, 102, 241, 0.18);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.35);
}

.btsk-bottom-nav-inner {
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  max-width: 480px;
  margin: 0 auto;
  padding: 0;
}

.btsk-bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1;
  min-height: 56px;
  padding: 6px 4px 8px;
  text-decoration: none;
  color: rgba(182, 197, 234, 0.6);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
  transition: color 0.15s, transform 0.15s;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.btsk-bottom-nav a .bnav-icon {
  font-size: 22px;
  line-height: 1;
  transition: transform 0.2s;
}
.btsk-bottom-nav a:active {
  transform: scale(0.92);
}
.btsk-bottom-nav a:active .bnav-icon {
  transform: scale(1.1);
}
.btsk-bottom-nav a.active {
  color: #818cf8;
}
.btsk-bottom-nav a.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  background: #818cf8;
  border-radius: 0 0 3px 3px;
}
.btsk-bottom-nav a.active .bnav-icon {
  filter: drop-shadow(0 0 6px rgba(129, 140, 248, 0.4));
}

@media (max-width: 768px) {
  .btsk-bottom-nav {
    display: block;
  }
  /* Bottom nav için body altına boşluk */
  body {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* ── 13. MOBİL SCROLL-TO-TOP ──────────────────────────────── */
@media (max-width: 768px) {
  #scrollTopBtn,
  .back-to-top {
    bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
    right: 14px !important;
    width: 44px !important;
    height: 44px !important;
    font-size: 18px !important;
  }
}

/* ── 14. MOBİL SCHEDULE/TAKVİM GRİDLERİ ──────────────────── */
@media (max-width: 768px) {
  .compact-schedule-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .athlete-calendar-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 480px) {
  .compact-schedule-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ── 15. MOBİL TAB SİSTEMİ ────────────────────────────────── */
@media (max-width: 768px) {
  /* Tab butonları scroll edilebilir */
  .tabs {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap !important;
    gap: 6px !important;
    padding-bottom: 4px;
  }
  .tabs::-webkit-scrollbar {
    display: none;
  }
  .tab-btn {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    font-size: 13px !important;
    padding: 10px 16px !important;
  }
}

/* ── 16. GENEL MOBİL İYİLEŞTİRMELER ──────────────────────── */
@media (max-width: 768px) {
  /* Avatarlar */
  .avatar-thumb {
    width: 36px !important;
    height: 36px !important;
    flex-shrink: 0;
  }

  /* Accordion/Collapsible headers daha büyük */
  .accordion-header,
  .collapsible-header {
    padding: 14px 12px !important;
    font-size: 14px !important;
  }

  /* Badge'ler */
  .badge {
    font-size: 11px !important;
    padding: 4px 8px !important;
    white-space: nowrap;
  }

  /* Muted text */
  .muted, .sub {
    font-size: 13px !important;
  }

  /* Pill */
  .pill {
    font-size: 12px !important;
  }

  /* Actions/Chips flex-wrap */
  .actions {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  /* Profile trigger tam genişlik */
  .profile-trigger {
    width: 100% !important;
  }

  /* Account switcher tam genişlik */
  .header-account-switch,
  .account-switcher-inline {
    width: 100% !important;
  }

  /* Top header stack */
  .top {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }
  .top-actions {
    width: 100% !important;
    flex-wrap: wrap !important;
  }

  /* Header wrap */
  .header-wrap {
    flex-direction: column !important;
    gap: 8px !important;
  }

  /* Top actions linkler tam genişlik */
  .top-actions a.link,
  .top-actions .btn {
    flex: 1 1 auto !important;
    text-align: center !important;
    justify-content: center !important;
  }
}

/* ── 17. LANDSCAPE MOD İYİLEŞTİRME ───────────────────────── */
@media (max-width: 768px) and (orientation: landscape) {
  .btsk-bottom-nav {
    padding-bottom: 0;
  }
  body {
    padding-bottom: 56px !important;
  }
  .btsk-slide-nav {
    padding-top: 50px;
  }
  .modal-box,
  .modal-card {
    max-height: 85dvh !important;
  }
}

/* ── 18. PRINT MEDYA ──────────────────────────────────────── */
@media print {
  .btsk-hamburger,
  .btsk-nav-overlay,
  .btsk-slide-nav,
  .btsk-bottom-nav,
  #scrollTopBtn,
  .back-to-top {
    display: none !important;
  }
  body {
    padding-bottom: 0 !important;
  }
}

/* ── 19. YÜKLEME ANİMASYONU ──────────────────────────────── */
@keyframes btsk-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.btsk-animate-in {
  animation: btsk-fade-in 0.35s ease-out both;
}

/* ── 20. FONKSİYONEL SCROLLBAR ────────────────────────────── */
@media (max-width: 768px) {
  /* Yatay scroll barları gizle ama scroll yap */
  .table-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  .table-wrap::-webkit-scrollbar {
    height: 4px;
  }
  .table-wrap::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 2px;
  }
  .table-wrap::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 2px;
  }
}

/* ============================================================
   BTSK mobile hardening layer.
   Sayfa-spesifik CSS'lere dokunmadan dar ekran tasma sorunlarini
   toparlayan koruyucu katman.
   ============================================================ */

html.btsk-mobile-ready {
  min-width: 0;
}

img,
video,
canvas,
svg {
  max-width: 100%;
  height: auto;
}

@media (max-width: 1024px) {
  .wrap,
  .container,
  .page,
  .page-wrap,
  .main-wrap,
  .dashboard,
  .dashboard-wrap {
    width: 100% !important;
    max-width: 100% !important;
  }

  [style*="max-width:1100px"],
  [style*="max-width: 1100px"],
  [style*="max-width:1240px"],
  [style*="max-width: 1240px"],
  [style*="max-width:1240px"],
  [style*="max-width: 1240px"],
  [style*="max-width:1280px"],
  [style*="max-width: 1280px"] {
    max-width: calc(100vw - 20px) !important;
  }
}

@media (max-width: 768px) {
  body {
    width: 100%;
  }

  body,
  .wrap,
  .container,
  .page,
  .panel,
  .card,
  .box,
  .modal-box,
  .modal-card {
    min-width: 0 !important;
  }

  .panel,
  .card,
  .box,
  .section,
  .summary-card,
  .stat-card,
  .rowCard,
  .student-card,
  .athlete-card,
  .request-card {
    overflow-wrap: anywhere;
  }

  .main,
  .content-grid,
  .dashboard-grid,
  .bottom-panels,
  .two-col,
  .three-col,
  .settings-grid,
  .summary-grid,
  .stats-grid,
  .cards-grid,
  .grid.cards,
  .kpi-grid {
    grid-template-columns: 1fr !important;
  }

  .grid,
  form.grid,
  .filter-grid,
  .filters-grid,
  .toolbar,
  .toolbar-row,
  .topbar,
  .header,
  .header-row,
  .head-row,
  .page-head,
  .page-header,
  .rowMain,
  .rowActions,
  .actions,
  .button-row,
  .btn-row,
  .nav-links {
    max-width: 100%;
    flex-wrap: wrap !important;
  }

  .grid > *,
  form.grid > *,
  .filter-grid > *,
  .filters-grid > * {
    min-width: 0 !important;
  }

  .sticky {
    position: static !important;
    top: auto !important;
  }

  .quick-links,
  .quick-actions,
  .shortcut-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  .quick-links a,
  .quick-actions a,
  .shortcut-grid a,
  .link,
  .btn,
  button {
    align-items: center;
    justify-content: center;
  }

  .link,
  .btn,
  button,
  input[type="submit"],
  input[type="button"] {
    min-height: 44px !important;
    white-space: normal !important;
  }

  .seg,
  .segment,
  .segmented,
  .toggle-group {
    width: 100% !important;
    display: flex !important;
  }

  .seg label,
  .segment label,
  .segmented label,
  .toggle-group label {
    flex: 1 1 0 !important;
    min-width: 0 !important;
  }

  .seg label span,
  .segment label span,
  .segmented label span,
  .toggle-group label span {
    width: 100% !important;
    min-height: 48px !important;
    justify-content: center !important;
    text-align: center !important;
  }

  .table-wrap,
  .table-responsive,
  .overflow-x,
  .scroll-x {
    width: 100% !important;
    max-width: 100vw !important;
  }

  .btsk-responsive-table {
    width: 100% !important;
  }

  .btsk-responsive-table td {
    min-width: 0 !important;
  }

  .btsk-responsive-table td > * {
    max-width: 100%;
  }

  .modal-overlay,
  .modal,
  .dialog-overlay,
  .popup-overlay {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  .modal-box,
  .modal-card,
  .dialog,
  .popup,
  .sheet,
  .drawer {
    width: min(100%, 100vw) !important;
  }

  .modal-body,
  .modal-content,
  .dialog-body {
    max-height: calc(92dvh - 80px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .desktop-nav,
  .top-nav,
  .nav-links,
  .header-links {
    gap: 8px !important;
  }
}

@media (max-width: 480px) {
  .wrap,
  .container,
  .page,
  .page-wrap {
    padding-left: max(10px, env(safe-area-inset-left, 10px)) !important;
    padding-right: max(10px, env(safe-area-inset-right, 10px)) !important;
  }

  .quick-links,
  .quick-actions,
  .shortcut-grid {
    grid-template-columns: 1fr !important;
  }

  .stats,
  .stat-row,
  .summary-row {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }

  .btsk-responsive-table tr {
    border-radius: 12px !important;
  }

  .btsk-responsive-table td {
    align-items: flex-start !important;
    flex-direction: column !important;
    text-align: left !important;
  }

  .btsk-responsive-table td::before {
    min-width: 0;
  }
}

/* ── 21. FİLTRE GRİDLERİ (çok sütunlu) ──────────────────────── */
@media (max-width: 900px) {
  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}
@media (max-width: 560px) {
  .filters {
    grid-template-columns: 1fr !important;
  }
}

/* ── 22. RESPONSIVE TABLE — TABLE-WRAP ile ────────────────────── */
@media (max-width: 768px) {
  /* table-wrap olmayan tablolar overflow-x scroll alır */
  table:not(.btsk-no-card-table):not(.btsk-responsive-table) {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
}

/* ── 23. FORGOT PASSWORD MODALİ — BOTTOM SHEET ────────────────── */
@media (max-width: 640px) {
  #forgotModal {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  #forgotModal .modal-card {
    width: 100% !important;
    max-width: 100% !important;
    max-height: calc(92dvh - 64px - env(safe-area-inset-bottom, 0px)) !important;
    border-radius: 20px 20px 0 0 !important;
    margin: 0 !important;
    padding: 16px !important;
    animation: btsk-slide-up 0.3s ease-out;
  }
  #forgotModal .modal-card::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 2px;
    margin: 0 auto 14px;
  }
}

/* ── 24. GENEL TABLO MOBİL İYİLEŞTİRME ───────────────────────── */
@media (max-width: 768px) {
  /* Tablo header font küçült */
  th {
    font-size: 11px !important;
  }
  /* Tablo hücre padding azalt */
  td, th {
    padding: 7px 5px !important;
  }
}

/* ── 25. FORM STEPPERLERİ MOBİL ──────────────────────────────── */
@media (max-width: 600px) {
  .stepper {
    flex-direction: column !important;
    gap: 6px !important;
  }
  .step-pill {
    min-width: 0 !important;
    font-size: 12px !important;
    padding: 9px 10px !important;
  }
}

/* ── 26. KART BAŞLIĞI (head) MOBİL ──────────────────────────── */
@media (max-width: 640px) {
  .head {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
  }
  .head-left {
    gap: 10px !important;
  }
  .logo {
    width: 48px !important;
    height: 48px !important;
  }
  .title {
    font-size: 20px !important;
  }
  .subtitle {
    font-size: 12px !important;
  }
}

/* ── 27. MODAL-OPEN BODY LOCK ─────────────────────────────────── */
body.modal-open {
  overflow: hidden;
  height: 100dvh;
}

@media (max-width: 768px) {
  body.modal-open .profile-trigger,
  body.confirm-modal-open .profile-trigger,
  body:has(.modal-overlay.open) .profile-trigger,
  body:has(.modal-overlay.active) .profile-trigger,
  body.modal-open .floating-role-logo,
  body.confirm-modal-open .floating-role-logo,
  body:has(.modal-overlay.open) .floating-role-logo,
  body:has(.modal-overlay.active) .floating-role-logo,
  body.modal-open .head .logo,
  body.confirm-modal-open .head .logo,
  body:has(.modal-overlay.open) .head .logo,
  body:has(.modal-overlay.active) .head .logo {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
}

/* ── 28. OVERSCROLL BEHAVIOR ──────────────────────────────────── */
.modal-overlay,
.btsk-slide-nav {
  overscroll-behavior: contain;
}

/* ── 29. FOCUS VISİBLE ERİŞİLEBİLİRLİK ──────────────────────── */
@media (max-width: 768px) {
  :focus-visible {
    outline: 2px solid rgba(129, 140, 248, 0.7);
    outline-offset: 2px;
  }
}

/* ── 30. GRID ITEM MIN-WIDTH FIX ─────────────────────────────── */
.grid > *,
.stats > *,
.filters > * {
  min-width: 0;
}

/* ── 31. WRAP — PADDİNG SAFE AREA ────────────────────────────── */
@media (max-width: 480px) {
  .head, .panel, .card, .box {
    border-radius: 12px !important;
  }
}

/* ── 32. IOS PWA STATUS BAR PADDING ──────────────────────────── */
@supports (padding-top: env(safe-area-inset-top)) {
  .page-header-sticky,
  .sticky-top {
    padding-top: calc(env(safe-area-inset-top, 0px) + 12px) !important;
  }
}

/* ── 33. HESAP EKSTRESİ / DEVAMSIZLIK filtre grid ────────────── */
@media (max-width: 768px) {
  .head {
    padding: 10px 12px !important;
  }
  .panel {
    margin-top: 8px !important;
  }
}

/* ── 34. BUTON ROW MOBİL ─────────────────────────────────────── */
@media (max-width: 640px) {
  .nav-row {
    flex-direction: column !important;
    gap: 8px !important;
  }
  .nav-row .left,
  .nav-row .right {
    width: 100% !important;
    flex-direction: column !important;
  }
  .nav-row button,
  .nav-row .btn {
    width: 100% !important;
  }
}

/* ── 35. RESPONSIVE STATS GRID ────────────────────────────────── */
@media (max-width: 640px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}
@media (max-width: 400px) {
  .stats {
    grid-template-columns: 1fr !important;
  }
}

/* ── 36. TOAST / SNACKBAR (mobil bildirim) ───────────────────── */
.btsk-toast {
  position: fixed;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px) + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(0);
  z-index: 9999;
  background: rgba(17, 35, 80, 0.96);
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: #eaf0ff;
  padding: 12px 18px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  white-space: normal;
  text-align: center;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  animation: btsk-toast-in 0.3s ease-out;
  pointer-events: none;
}
.btsk-toast.ok {
  border-color: rgba(46, 204, 113, 0.5);
  background: rgba(6, 50, 28, 0.97);
}
.btsk-toast.err {
  border-color: rgba(231, 76, 60, 0.5);
  background: rgba(60, 10, 10, 0.97);
}
@keyframes btsk-toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0);    }
}

/* ── 37. PULL-TO-REFRESH ENGELİ ─────────────────────────────── */
@supports (-webkit-overflow-scrolling: touch) {
  body {
    overscroll-behavior-y: none;
  }
}

/* ── 38. TOUCH-ACTION: MANIPULATION (tüm interaktif öğeler) ──── */
a, button, [role="button"], [onclick], label {
  touch-action: manipulation;
}

/* ── 39. SELECT APPEARANCE MOBİL ─────────────────────────────── */
@media (max-width: 768px) {
  select {
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23818cf8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px !important;
  }
}

/* ── 40. CARD HOVER ETKİSİ (dokunmatik cihazlarda kaldır) ──── */
@media (hover: none) {
  .card:hover,
  .panel:hover,
  .link:hover {
    transform: none;
    box-shadow: none;
  }
}

/* ── 41. TOOLBAR / SCHEDULE / FİLTRE BUTON SATIRLARI ─────────── */

/* Genel kural: toolbar içindeki butonlar wrap yapar ama tek satırda */
@media (max-width: 860px) {

  /* Schedule toolbar (athlete_panel, role_panel) */
  .schedule-toolbar,
  .compact-calendar-toolbar,
  .manager-toolbar,
  .sort-toolbar,
  .chip-toolbar,
  .filter-toolbar {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 6px !important;
  }

  /* Toolbar içindeki quick-link / chip / btn — sıkışmadan yan yana */
  .schedule-toolbar > a,
  .schedule-toolbar > button,
  .schedule-toolbar > label,
  .compact-calendar-toolbar > a,
  .compact-calendar-toolbar > button,
  .compact-calendar-toolbar > label {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    min-height: 34px !important;
    display: inline-flex !important;
    align-items: center !important;
    padding: 6px 10px !important;
    font-size: 12px !important;
  }

  /* Checkbox + metin çifti tek satırda */
  .schedule-toolbar label,
  .compact-calendar-toolbar label {
    gap: 5px !important;
    cursor: pointer !important;
  }
  .schedule-toolbar label input[type="checkbox"],
  .compact-calendar-toolbar label input[type="checkbox"] {
    flex-shrink: 0 !important;
    width: 14px !important;
    min-width: 14px !important;
    height: 14px !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Tarih aralığı metni — tam genişlik, kendi satırında */
  .schedule-range {
    flex-basis: 100% !important;
    font-size: 12px !important;
    margin-top: 2px !important;
  }
}

/* ── 42. FILTER (input/select) GRUPLARI — WRAP DEĞİL, 2 KOLON ─ */
@media (max-width: 768px) {
  /* Genel filter satırları 2 sütuna düş */
  .filter-row,
  .filter-bar,
  #athleteFilterForm {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
    align-items: end !important;
  }
}
@media (max-width: 480px) {
  .filter-row,
  .filter-bar,
  #athleteFilterForm {
    grid-template-columns: 1fr !important;
  }
}

/* ── 43. CHECKBOX / RADIO LABEL KAYMALARI ────────────────────── */
/* Flex içinde checkbox+metin çifti asla ortadan bölünmesin       */
label:has(> input[type="checkbox"]),
label:has(> input[type="radio"]) {
  white-space: nowrap !important;
  flex-shrink: 0 !important;
}

/* Form grid hücresi içindeki checkbox label'ları: checkbox solda */
.form-grid label:has(> input[type="checkbox"]),
.profile-edit-grid label:has(> input[type="checkbox"]),
.form-grid label:has(> input[type="radio"]),
.profile-edit-grid label:has(> input[type="radio"]) {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  white-space: normal !important;
  flex-shrink: 1 !important;
  width: 100% !important;
  gap: 8px !important;
}
.form-grid label:has(> input[type="checkbox"]) > input[type="checkbox"],
.form-grid label:has(> input[type="radio"]) > input[type="radio"],
.profile-edit-grid label:has(> input[type="checkbox"]) > input[type="checkbox"],
.profile-edit-grid label:has(> input[type="radio"]) > input[type="radio"] {
  flex-shrink: 0 !important;
  width: auto !important;
  padding: 0 !important;
}

/* Flex container'ı olan label — iç metin kırılmasın              */
label[style*="flex"],
label.quick-link,
label.compact-calendar-chip,
label.chip,
label.tag {
  white-space: nowrap !important;
}

/* Genel form label'ları (tek satır) kırılmamalı;                 */
/* çok satır gereken durumlarda label'a .wrap-label ekle          */
.form-label,
.field-label {
  white-space: normal; /* form alanı açıklamaları wrap olabilir   */
}

/* ── 44. UZUN ONAY METİNLERİ (sözleşme, izin vb.) ─────────────*/
/* Checkbox sonrası uzun metin wrap olabilmeli — <span> içindeyse */
label:has(> input[type="checkbox"]) > span,
label:has(> input[type="radio"]) > span {
  white-space: normal !important;
  flex-shrink: 1 !important;
}
/* Ama kısa etiket metinleri (text node) kırılmasın:               */
/* text node white-space:nowrap label'dan inherit eder             */

/* ── 45. KART MODUNDA BUTON SATIRLARI ──────────────────────────*/
/* 640px altında btsk-responsive-table td → flex-direction:column */
/* Bu yüzden td içindeki quick-link/btn dikey yığılıyor.          */
/* Çözüm: buton içeren td'leri yatay (row+wrap) yap.             */

@media (max-width: 640px) {
  /* Buton içeren td: yatay wrap */
  .btsk-responsive-table td:has(.quick-link),
  .btsk-responsive-table td:has(.btn) {
    flex-direction: row !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    align-items: center !important;
    justify-content: flex-start !important;
  }
  /* Butonların kendisi inline kalmalı */
  .btsk-responsive-table td .quick-link,
  .btsk-responsive-table td .btn {
    display: inline-flex !important;
    align-items: center !important;
    width: auto !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }
}

/* Genel: quick-link display:block olduğu için flex container'da  */
/* tam genişlik alabilir. Özel wrapper'lar için inline-flex yap.  */
td .quick-link,
td .btn,
.card-actions .quick-link,
.card-actions .btn,
.action-group .quick-link,
.action-group .btn,
.btn-row .quick-link,
.btn-row .btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: auto !important;
  white-space: nowrap !important;
}
