/**
 * PACKDOOR — Mobil / Capacitor WebView UX
 * body.pd-mobile-app = native kabuk içinden açıldı
 */

:root {
  --pd-safe-top: env(safe-area-inset-top, 0px);
  --pd-safe-bottom: env(safe-area-inset-bottom, 0px);
  --pd-touch: 44px;
}

body.pd-mobile-app {
  padding-top: var(--pd-safe-top);
  padding-bottom: var(--pd-safe-bottom);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

body.pd-mobile-app .header-toggle-hide,
body.pd-mobile-app .header-toggle-show {
  display: none !important;
}

@media (max-width: 768px) {
  .modern-header {
    margin-bottom: 8px;
  }

  .header-top-bar {
    padding: 10px 12px !important;
  }

  .header-logo img {
    height: 36px !important;
    padding: 4px 8px !important;
  }

  .header-user-info {
    gap: 6px !important;
  }

  .header-btn {
    min-height: var(--pd-touch);
    padding: 8px 10px !important;
    font-size: 12px !important;
  }

  .header-nav {
    display: flex;
    gap: 0;
    padding: 0 8px !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .header-nav::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    flex: 0 0 auto;
    min-height: var(--pd-touch);
    min-width: var(--pd-touch);
    justify-content: center;
    padding: 12px 14px !important;
  }

  /* Takvim */
  .fc,
  .calendar-wrap,
  #calendar {
    font-size: 13px;
  }

  .fc .fc-toolbar {
    flex-direction: column;
    gap: 8px;
    align-items: stretch !important;
  }

  .fc .fc-toolbar-chunk {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
  }

  .fc .fc-button {
    min-height: 40px;
    padding: 6px 10px !important;
  }

  /* Hatırlatmalar / keşif listeleri */
  .reminder-card,
  .kesif-card,
  .list-card,
  table.responsive-cards tbody tr {
    border-radius: 10px;
  }

  /* Sadece native app kabuğunda büyüt / stack et — masaüstü dar panelde bozma */
  body.pd-mobile-app .btn,
  body.pd-mobile-app button.btn,
  body.pd-mobile-app a.btn {
    min-height: 40px;
  }

  body.pd-mobile-app .filter-row,
  body.pd-mobile-app .search-form {
    gap: 8px;
  }

  body.pd-mobile-app .filter-group {
    min-width: 100% !important;
    flex: 1 1 100% !important;
  }

  html.pd-force-desktop body.pd-mobile-app .filter-group,
  html.pd-force-desktop .filter-group {
    min-width: 0 !important;
    flex: 1 1 0 !important;
    width: auto !important;
  }

  /* Geniş tablolar: yatay kaydır */
  .table-responsive,
  .data-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table.data-table,
  table.kesif-table {
    min-width: 640px;
  }
}

/* Capacitor: masaüstü yoğun panelleri sadeleştir */
@media (max-width: 768px) {
  body.pd-mobile-app .desktop-only {
    display: none !important;
  }

  body.pd-mobile-app .export-buttons {
    flex-wrap: wrap;
  }

  /* —— Takvim —— */
  body.calendar-page .calendar-container,
  .calendar-container {
    padding: 12px !important;
    margin-top: 8px !important;
    border-radius: 10px !important;
  }

  .calendar-header {
    flex-direction: column;
    align-items: stretch !important;
    gap: 10px;
  }

  .calendar-header h2 {
    font-size: 15px !important;
  }

  .calendar-view-buttons {
    display: flex;
    width: 100%;
  }

  .calendar-view-btn {
    flex: 1;
    min-height: 40px;
    font-size: 12px !important;
    padding: 8px 6px !important;
  }

  .calendar-filters {
    flex-direction: column;
    align-items: stretch !important;
  }

  .calendar-filters select {
    min-width: 0 !important;
    width: 100%;
  }

  .calendar-stats-bar {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .calendar-stats-bar .cal-stats-period {
    grid-column: 1 / -1;
  }

  .cal-stat-bubble {
    padding: 10px !important;
  }

  #calendar {
    min-height: 420px;
  }

  /* —— Hatırlatmalar —— */
  .reminders-page-header {
    margin: 12px 0 16px !important;
  }

  .reminders-page-header h1 {
    font-size: 1.25rem !important;
  }

  .reminder-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px !important;
    margin-bottom: 10px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  }

  .reminder-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px;
  }

  .reminder-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-start !important;
    max-width: 100% !important;
  }

  .reminder-actions .btn,
  .reminder-actions .btn-sm {
    min-height: 40px;
    flex: 1 1 calc(50% - 6px);
    justify-content: center;
  }

  .reminder-actions .calendar-picker {
    flex: 1 1 100%;
    display: flex;
    gap: 6px;
  }

  /* —— Keşif listesi —— */
  .kesif-listesi-page .filter-row,
  body.pd-mobile-app .filter-row {
    flex-direction: column;
  }

  html.pd-force-desktop .kesif-listesi-page .filter-row,
  html.pd-force-desktop body.pd-mobile-app .filter-row,
  html.pd-force-desktop .filter-row {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
  }
}
