/* Duke AI Design System - Mobile App Experience */
/* ── Bottom Sheet ── */
.duke-bottom-sheet-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: var(--z-overlay); opacity: 0; visibility: hidden;
  transition: opacity .25s ease, visibility .25s;
  -webkit-tap-highlight-color: transparent;
}
.duke-bottom-sheet-overlay.show { opacity: 1; visibility: visible; }

.duke-bottom-sheet {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-card); backdrop-filter: blur(40px);
  border-radius: var(--space-4) var(--space-4) 0 0;
  border: var(--glass-border); border-bottom: none;
  z-index: var(--z-bottom-sheet);
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.32,.72,0,1);
  max-height: 92vh; overflow: hidden;
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
body.light .duke-bottom-sheet { background: #fff; border: 1px solid #e5e7eb; border-bottom: none; backdrop-filter: none; }
.duke-bottom-sheet.show { transform: translateY(0); }

.duke-bottom-sheet-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--gray-400); margin: var(--space-2) auto var(--space-3);
  flex-shrink: 0;
}

.duke-bottom-sheet-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--space-5) var(--space-3);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.duke-bottom-sheet-header h3 {
  font-size: var(--text-xl); font-weight: var(--font-semibold); color: var(--text-heading);
}
.duke-bottom-sheet-close {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--gray-100); border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--gray-500); transition: all .15s;
}
.duke-bottom-sheet-close:hover { background: var(--gray-200); color: var(--text-heading); }
.duke-bottom-sheet-close svg { width: 18px; height: 18px; }

.duke-bottom-sheet-body {
  flex: 1; overflow-y: auto; padding: var(--space-5);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.duke-bottom-sheet-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

/* ── Action Sheet (iOS-style) ── */
.duke-action-sheet {
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: var(--z-bottom-sheet); padding: 0 var(--space-2);
  padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom, 0px));
  transform: translateY(110%);
  transition: transform .3s cubic-bezier(.32,.72,0,1);
}
.duke-action-sheet.show { transform: translateY(0); }

.duke-action-group {
  background: var(--bg-card); backdrop-filter: blur(40px);
  border-radius: var(--space-3); overflow: hidden;
  margin-bottom: var(--space-2);
}
body.light .duke-action-group { background: #fff; }

.duke-action-item {
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-4); font-size: var(--text-lg);
  font-weight: var(--font-medium); color: var(--primary);
  border-bottom: 1px solid var(--border-color);
  cursor: pointer; transition: background .15s;
  min-height: var(--tap-min);
  -webkit-tap-highlight-color: transparent;
}
.duke-action-item:last-child { border-bottom: none; }
.duke-action-item:active { background: var(--gray-100); }
.duke-action-item.destructive { color: var(--danger); }
.duke-action-item.cancel { font-weight: var(--font-semibold); }

/* ── Slide Animations ── */
@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes slideDown {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(100%); opacity: 0; }
}
.duke-slide-up { animation: slideUp .3s cubic-bezier(.32,.72,0,1) forwards; }
.duke-slide-down { animation: slideDown .25s ease-in forwards; }

/* ── Pull/Sticky Header ── */
.duke-pull-header {
  position: sticky; top: 0; z-index: var(--z-sticky);
  background: var(--bg-topbar); backdrop-filter: blur(20px);
  border-bottom: var(--glass-border);
  padding: var(--space-3) var(--space-4);
  display: flex; align-items: center; justify-content: space-between;
}
body.light .duke-pull-header { background: rgba(255,255,255,.92); border-bottom: 1px solid #e5e7eb; }

/* ═══════════════════════════════════════════════════════════════════
   MOBILE OVERRIDES — App Experience
   ═══════════════════════════════════════════════════════════════════ */

/* Disable hover on touch devices */
@media (hover: none) {
  .card:hover, .stat-card:hover, .duke-metric:hover, .duke-card:hover,
  .duke-list-item:hover, .kpi-card:hover, .dash-kpi:hover,
  .module-pill:hover, .perf-card:hover {
    transform: none !important;
    box-shadow: var(--card-inset) !important;
  }
  body.light .card:hover, body.light .stat-card:hover, body.light .duke-metric:hover {
    box-shadow: none !important;
  }
}

@media (max-width: 768px) {
  /* Convert modals to bottom sheets on mobile */
  .modal-overlay.show {
    align-items: flex-end !important;
    padding: 0 !important;
    backdrop-filter: blur(4px);
  }
  .modal-overlay .modal {
    max-width: 100% !important; width: 100% !important;
    border-radius: var(--space-4) var(--space-4) 0 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    max-height: 90vh;
    animation: slideUp .3s cubic-bezier(.32,.72,0,1);
    display: flex; flex-direction: column;
  }
  .modal-overlay .modal::before {
    content: ''; display: block;
    width: 36px; height: 4px; border-radius: 2px;
    background: var(--gray-400); margin: var(--space-2) auto var(--space-3);
    flex-shrink: 0;
  }
  .modal-overlay .modal h3 { padding: 0 var(--space-5); }
  .modal-overlay .modal .modal-desc { padding: 0 var(--space-5); }
  .modal-overlay .modal .form-row { padding: 0 var(--space-5); }
  .modal-overlay .modal-actions {
    padding: var(--space-3) var(--space-5);
    padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border-color);
    margin-top: auto;
  }

  /* Buttons — touch-friendly sizing */
  .btn {
    min-height: var(--tap-min);
    padding: var(--space-3) var(--space-5) !important;
    font-size: var(--text-md) !important;
  }
  .btn-sm {
    min-height: 36px;
    padding: var(--space-2) var(--space-4) !important;
    font-size: var(--text-base) !important;
  }

  /* Full-width buttons in card contexts */
  .modal-actions .btn { flex: 1; justify-content: center; }
  .duke-bottom-sheet-footer .btn { width: 100%; justify-content: center; }

  /* Cards — tighter on mobile */
  .duke-card { padding: var(--space-4); margin-bottom: var(--space-3); }

  /* Grids collapse */
  .duke-grid-2 { grid-template-columns: 1fr; }
  .duke-grid-3 { grid-template-columns: 1fr; }
  .duke-grid-4 { grid-template-columns: repeat(2, 1fr); }

  /* Touch-friendly list items */
  .duke-list-item {
    padding: var(--space-3) var(--space-4);
    min-height: var(--tap-min);
  }

  /* Filter tabs scroll */
  .filter-tabs {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: var(--space-1);
  }
  .filter-tabs::-webkit-scrollbar { display: none; }
  .filter-tab {
    flex-shrink: 0;
    min-height: 36px;
    padding: var(--space-2) var(--space-4);
  }

  /* Toggle — bigger tap target */
  .toggle { width: 52px; height: 28px; }
  .toggle::after { width: 24px; height: 24px; }
  .toggle.active::after { transform: translateX(24px); }

  /* Setting rows — stack on mobile */
  .setting-row { flex-wrap: wrap; gap: var(--space-3); }

  /* Smooth scrolling everywhere */
  .duke-bottom-sheet-body,
  .main-content,
  .dash-card-body,
  .notification-dropdown-list {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  /* Hide scrollbars on mobile */
  ::-webkit-scrollbar { width: 0; height: 0; }

  /* ═══ MEER MENU PAGES — Mobile Responsive ═══ */

  /* All page sections: contain width but don't clip visible content */
  .page-section {
    max-width: 100vw;
    box-sizing: border-box;
  }

  /* Integraties: CMS platform tabs 4-col → 2x2 */
  #cms-platform-tabs {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
  #cms-platform-tabs > button,
  #cms-platform-tabs > div {
    padding: 16px 10px !important;
    font-size: 12px !important;
  }
  #cms-platform-tabs svg {
    width: 32px !important;
    height: 32px !important;
  }

  /* Integraties: Chatbot kanalen + Agenda grid 4-col → 2x2 */
  #section-channels .duke-grid-4 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
  #section-channels .duke-grid-4 > div {
    padding: 16px 10px !important;
    font-size: 12px !important;
  }
  #section-channels .duke-grid-4 svg {
    width: 32px !important;
    height: 32px !important;
  }

  /* Integraties: Connected sites — stack layout on mobile */
  #wp-connections-list .flex.items-center.justify-between,
  #wp-connections-list > div {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
  }
  #wp-connections-list .flex.gap-sm,
  #wp-connections-list > div > div:last-child {
    width: 100% !important;
    display: flex !important;
    gap: 8px !important;
  }
  #wp-connections-list .btn,
  #wp-connections-list button {
    min-height: 44px;
    font-size: 13px !important;
    padding: 10px 16px !important;
    flex: 1 !important;
    justify-content: center !important;
  }

  /* Profile: avatar + name row — stack on narrow screens */
  #section-profile .card > div[style*="display:flex"][style*="align-items:center"][style*="gap:20px"] {
    flex-direction: column !important;
    text-align: center;
  }

  /* Profile: form grids 2-col → 1-col */
  #section-profile div[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Profile: 2FA row — stack */
  #section-profile div[style*="display:flex"][style*="justify-content:space-between"] {
    flex-direction: column !important;
    gap: 12px !important;
    align-items: flex-start !important;
  }

  /* Team: invite form — stack if 2-col */
  #section-team div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
  /* Team: member cards — full width */
  #section-team .card {
    overflow-x: hidden;
  }

  /* Subscription: plan cards grid → stack */
  #section-subscription .duke-grid-3,
  #section-subscription .duke-grid-4 {
    grid-template-columns: 1fr !important;
  }

  /* Analytics: property selectors 3-col → 1-col */
  #section-analytics div[style*="grid-template-columns:1fr 1fr 1fr"],
  #section-analytics div[style*="grid-template-columns: 1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Analytics: GSC tables 2-col → 1-col */
  #section-analytics div[style*="grid-template-columns:1fr 1fr"],
  #section-analytics div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Analytics: stat grids → 2-col or stack */
  #section-analytics .duke-grid-4,
  #section-analytics .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  #section-analytics .duke-grid-3 {
    grid-template-columns: 1fr !important;
  }

  /* Analytics: date range buttons — scroll horizontal */
  #section-analytics div[style*="justify-content:flex-end"] {
    justify-content: flex-start !important;
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
  }

  /* Analytics: tables — horizontal scroll */
  #section-analytics .table-container {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  #section-analytics .data-table {
    min-width: 500px;
  }

  /* Analytics: Google connected row — stack button under text */
  #google-connected div[style*="display:flex"][style*="align-items:center"][style*="gap:16px"] {
    flex-wrap: wrap !important;
  }
  #google-connected div[style*="display:flex"][style*="align-items:center"][style*="gap:16px"] .btn {
    width: 100% !important;
    justify-content: center;
  }

  /* Reviews: cards full width */
  #section-reviews .duke-grid-3,
  #section-reviews .duke-grid-4 {
    grid-template-columns: 1fr !important;
  }

  /* Team: flex bar — stack if needed */
  #section-team .duke-flex-bar {
    flex-wrap: wrap !important;
    gap: 12px !important;
  }

  /* Subscription: plan cards — ensure stack */
  #sub-plan-cards {
    grid-template-columns: 1fr !important;
  }
  #sub-module-cards {
    grid-template-columns: 1fr !important;
  }

  /* All cards in meer pages: full width, compact padding */
  #section-channels .card,
  #section-profile .card,
  #section-team .card,
  #section-subscription .card,
  #section-analytics .card,
  #section-reviews .card {
    padding: 16px !important;
    margin-bottom: 12px !important;
  }

  /* All buttons in meer pages: touch-friendly */
  #section-channels .btn,
  #section-profile .btn,
  #section-team .btn,
  #section-subscription .btn,
  #section-analytics .btn,
  #section-reviews .btn {
    min-height: 44px;
  }

  /* All inline 2-col/3-col grids in meer pages → 1-col */
  #section-profile div[style*="grid-template-columns"],
  #section-team div[style*="grid-template-columns"],
  #section-channels div[style*="grid-template-columns:1fr 1fr"],
  #section-subscription div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }

  /* All inline flex rows with justify-between → wrap */
  .page-section div[style*="display:flex"][style*="justify-content:space-between"] {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  /* Setting rows with buttons — stack */
  .setting-row {
    flex-wrap: wrap !important;
    gap: 12px !important;
  }

  /* ICS feed input — full width, smaller text */
  #section-channels input[type="text"],
  #section-channels input[type="password"] {
    font-size: 14px !important;
  }

  /* Badge corner — slightly smaller on mobile */
  .duke-badge-corner {
    font-size: 8px !important;
    padding: 2px 6px !important;
  }

  /* Portfolio tabs — scroll horizontally */
  #section-portfolio-overview .duke-flex-gap {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #section-portfolio-overview .duke-flex-gap::-webkit-scrollbar { display: none; }
  #section-portfolio-overview .duke-flex-gap .btn {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
  }
}

