/**
 * Shuttle Call - Responsive Fix
 * Yatay scroll sorununu çözen optimizasyonlar
 * Powered by Erkan ERDEM
 */

/* ==================== GLOBAL FIX ==================== */
* {
  box-sizing: border-box;
}

html, body {
  overflow-x: hidden;
  max-width: 100vw;
  position: relative;
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
}

/* Container'ları sınırla */
.container,
.container-fluid {
  max-width: 100%;
  overflow-x: hidden;
  padding-left: 1rem;
  padding-right: 1rem;
}

/* Grid sistemini responsive yap */
.grid,
.grid-2,
.grid-3,
.grid-4 {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

/* ==================== HEADER FIX ==================== */
.header {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

.header-content {
  width: 100%;
  max-width: 100%;
  padding: 0 1rem;
}

/* ==================== TABLE FIX ==================== */
.table-responsive {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0;
}

.table {
  min-width: 600px; /* Minimum genişlik */
  width: 100%;
}

/* ==================== CARD FIX ==================== */
.card,
.stat-card,
.request-card {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.card-body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  padding: 1rem;
}

/* ==================== BUTTON FIX ==================== */
.btn {
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==================== MOBILE RESPONSIVE ==================== */
@media (max-width: 768px) {
  /* Container padding azalt */
  .container,
  .container-fluid {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  /* Grid'i tek sütun yap */
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }

  /* Header optimize et */
  .header {
    padding: 0.75rem 0;
  }

  .header-content {
    padding: 0 0.75rem;
    gap: 0.5rem;
  }

  .logo-image {
    height: 40px;
  }

  /* Table scroll */
  .table-responsive {
    margin: 0 -0.75rem;
    padding: 0 0.75rem;
  }

  .table th,
  .table td {
    padding: 0.5rem;
    font-size: 0.875rem;
    white-space: nowrap;
  }

  /* Card padding azalt */
  .card-body {
    padding: 0.75rem;
  }

  /* Stat card optimize */
  .stat-card {
    padding: 1rem;
  }

  .stat-value {
    font-size: 1.75rem;
  }

  .stat-label {
    font-size: 0.75rem;
  }

  /* Button tam genişlik */
  .btn-block,
  .btn-lg {
    width: 100%;
    padding: 0.75rem 1rem;
  }

  /* Form optimize */
  .form-control {
    font-size: 16px; /* iOS zoom engellemek için */
  }

  /* Modal optimize */
  .modal-content {
    margin: 0.5rem;
    max-width: calc(100vw - 1rem);
  }
}

@media (max-width: 480px) {
  /* Daha küçük ekranlar için */
  .container,
  .container-fluid {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .header-content {
    padding: 0 0.5rem;
  }

  .logo-image {
    height: 36px;
  }

  .header-title {
    font-size: 1.25rem;
  }

  /* Table daha kompakt */
  .table th,
  .table td {
    padding: 0.375rem;
    font-size: 0.8125rem;
  }

  /* Card daha kompakt */
  .card-body {
    padding: 0.5rem;
  }

  .stat-card {
    padding: 0.75rem;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .stat-icon {
    width: 48px;
    height: 48px;
    font-size: 1.25rem;
  }

  /* Button küçült */
  .btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
  }

  .btn-sm {
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
  }

  /* Badge küçült */
  .badge {
    padding: 0.25rem 0.5rem;
    font-size: 0.625rem;
  }
}

/* ==================== LANDSCAPE MODE ==================== */
@media (max-width: 768px) and (orientation: landscape) {
  .header {
    padding: 0.5rem 0;
  }

  .logo-image {
    height: 32px;
  }

  .header-title {
    font-size: 1rem;
  }

  .stat-card {
    padding: 0.75rem;
  }

  .stat-value {
    font-size: 1.5rem;
  }
}

/* ==================== PRINT FIX ==================== */
@media print {
  html, body {
    overflow: visible;
    max-width: none;
  }

  .no-print {
    display: none !important;
  }

  .table {
    min-width: auto;
  }
}

/* ==================== FLEX FIX ==================== */
.d-flex,
.flex-wrap {
  flex-wrap: wrap;
  max-width: 100%;
}

.justify-between {
  gap: 0.5rem;
}

/* ==================== IMAGE FIX ==================== */
img {
  max-width: 100%;
  height: auto;
}

/* ==================== OVERFLOW FIX ==================== */
.overflow-hidden {
  overflow: hidden;
}

.overflow-x-hidden {
  overflow-x: hidden;
}

.overflow-y-auto {
  overflow-y: auto;
}

/* ==================== SAFE AREA (iOS) ==================== */
@supports (padding: max(0px)) {
  body {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }

  .header {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }

  .mobile-navbar {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}

/* ==================== SCROLL BAR STYLE ==================== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #1BA5A8, #158B8E);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #158B8E, #1BA5A8);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: #1BA5A8 #f1f5f9;
}

/* ==================== TOUCH OPTIMIZATION ==================== */
@media (hover: none) and (pointer: coarse) {
  /* Touch cihazlar için */
  .btn,
  .nav-link,
  .mobile-nav-item {
    min-height: 44px; /* Apple HIG minimum */
    min-width: 44px;
  }

  /* Tap highlight kaldır */
  * {
    -webkit-tap-highlight-color: transparent;
  }

  /* Smooth scroll */
  html {
    -webkit-overflow-scrolling: touch;
  }
}

/* ==================== ADMIN PAGES FIX ==================== */
@media (max-width: 768px) {
  /* Buggies table */
  #buggies-table td:nth-child(3),
  #buggies-table th:nth-child(3) {
    display: none; /* Plaka sütununu gizle */
  }

  /* Locations table */
  #locations-table td:nth-child(3),
  #locations-table th:nth-child(3) {
    display: none; /* Açıklama sütununu gizle */
  }

  /* Dashboard stats */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75rem;
  }

  /* Request list */
  #active-requests-list,
  #buggy-status-list {
    max-height: 350px;
  }
}

@media (max-width: 480px) {
  /* Dashboard stats tek sütun */
  .stats-grid {
    grid-template-columns: 1fr !important;
  }

  /* Table daha da kompakt */
  #buggies-table td:nth-child(4),
  #buggies-table th:nth-child(4),
  #buggies-table td:nth-child(5),
  #buggies-table th:nth-child(5) {
    display: none; /* Sürücü ve lokasyon sütunlarını gizle */
  }

  /* Action buttons stack */
  .request-actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  .request-actions .btn {
    width: 100%;
  }
}

/* ==================== MODAL FIX ==================== */
@media (max-width: 768px) {
  .modal-dialog {
    margin: 0.5rem;
    max-width: calc(100vw - 1rem);
  }

  .modal-content {
    border-radius: 1rem;
  }

  .modal-body {
    padding: 1rem;
  }

  .modal-footer {
    flex-direction: column;
    gap: 0.5rem;
  }

  .modal-footer .btn {
    width: 100%;
  }
}

/* ==================== FORM FIX ==================== */
@media (max-width: 768px) {
  .form-group {
    margin-bottom: 1rem;
  }

  .form-control {
    padding: 0.75rem;
  }

  /* Grid form */
  .grid.grid-cols-2 {
    grid-template-columns: 1fr !important;
  }

  /* Inline form */
  .form-inline {
    flex-direction: column;
    align-items: stretch;
  }

  .form-inline .form-control,
  .form-inline .btn {
    width: 100%;
    margin-bottom: 0.5rem;
  }
}

/* ==================== ANIMATION PERFORMANCE ==================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==================== HIGH CONTRAST MODE ==================== */
@media (prefers-contrast: high) {
  .btn {
    border: 2px solid currentColor;
  }

  .card {
    border: 1px solid #000;
  }
}

/* ==================== DARK MODE SUPPORT ==================== */
@media (prefers-color-scheme: dark) {
  /* Gelecekte dark mode için hazır */
  :root {
    --bg-primary: #1f2937;
    --bg-secondary: #111827;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
  }
}
