/* ═══════════════════════════════════════════════════
   LARISI MOBILE — mobile.css
   Semua override responsif untuk layar ≤ 768px
   Desktop tidak terpengaruh sama sekali
   ═══════════════════════════════════════════════════ */

@media (max-width: 768px) {

  /* ─── Reset body layout ─── */
  body {
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
  }

  /* ─── Sidebar desktop → sembunyikan ─── */
  .sidebar {
    display: none;
  }

  /* ─── Main area ambil full width ─── */
  .main {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  /* ─── Header mobile ─── */
  .header {
    height: 52px;
    padding: 0 16px;
  }
  .header-title { font-size: 14px; }
  .header-sub { display: none; }
  .search-bar { display: none; }
  .notif-btn { width: 36px; height: 36px; }
  #user-info-text { display: none !important; }

  /* ─── Content area ─── */
  .content {
    padding: 0;
    gap: 0;
    overflow: hidden;
    flex: 1;
  }

  /* ─── Panels: 3-kolom → 1 kolom scroll ─── */
  .panels {
    display: flex;
    flex-direction: column;
    grid-template-columns: unset;
    gap: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    padding-bottom: 72px; /* ruang untuk bottom tab bar */
  }

  /* ─── Semua panel: full width ─── */
  .panel-left,
  .panel-map,
  .panel-right {
    width: 100%;
    min-width: unset;
    max-width: unset;
    height: auto;
    border-radius: 0;
    border-right: none;
    border-left: none;
  }

  /* ─── Panel Map: sembunyikan di mobile (ganti modal) ─── */
  .panel-map {
    display: none;
  }

  /* ─── Panel kiri (upload/persona) ─── */
  .panel-left {
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
  }

  /* ─── Panel kanan (caption/preview): tampil di Screen B ─── */
  .panel-right {
    display: none; /* dikontrol JS saat user pindah ke Screen B */
  }
  .panel-right.mobile-visible {
    display: flex;
    flex-direction: column;
  }

  /* ─── Phone preview: sederhanakan di mobile ─── */
  .phone-wrap {
    width: 100% !important;
    max-width: 280px;
    margin: 0 auto;
  }

  /* ─── Touch targets minimum 44px ─── */
  .btn,
  .btn-primary,
  .btn-secondary,
  .sb-icon,
  .chip,
  .tab-btn,
  .notif-btn,
  .mobile-tab-item {
    min-height: 44px;
  }

  /* ─── Font penyesuaian ─── */
  .panel-title { font-size: 13px; }
  label { font-size: 13px; }

}

/* ═══════════════════════════════════════════════════
   BOTTOM TAB BAR
   ═══════════════════════════════════════════════════ */

.mobile-tab-bar {
  display: none; /* hidden di desktop */
}

@media (max-width: 768px) {
  .mobile-tab-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--white);
    border-top: 1px solid var(--border);
    z-index: 900;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
  }

  .mobile-tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: pointer;
    color: var(--secondary);
    font-size: 10px;
    font-weight: 500;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    padding: 6px 0;
  }

  .mobile-tab-item svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
    flex-shrink: 0;
  }

  .mobile-tab-item.active {
    color: var(--primary, #6d28d9);
  }

  .mobile-tab-item.active svg {
    stroke-width: 2;
  }
}

/* ═══════════════════════════════════════════════════
   INSTALL BANNER
   ═══════════════════════════════════════════════════ */

.mobile-install-banner {
  display: none;
}

@media (max-width: 768px) {
  .mobile-install-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f5f3ff;
    border-bottom: 1px solid #ddd6fe;
    padding: 10px 16px;
    font-size: 12px;
    color: #4c1d95;
    position: relative;
  }

  .mobile-install-banner.hidden {
    display: none;
  }

  .mobile-install-banner-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    flex-shrink: 0;
    object-fit: contain;
  }

  .mobile-install-banner-text {
    flex: 1;
    line-height: 1.3;
  }

  .mobile-install-banner-text strong {
    display: block;
    font-size: 12px;
    margin-bottom: 1px;
  }

  .mobile-install-banner-btn {
    background: #6d28d9;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    min-height: 36px;
  }

  .mobile-install-banner-close {
    background: none;
    border: none;
    color: #7c3aed;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    min-height: 36px;
    display: flex;
    align-items: center;
  }
}

/* ═══════════════════════════════════════════════════
   SCREEN A → SCREEN B NAVIGATION
   ═══════════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* Tombol Lanjut di Screen A */
  .mobile-screen-a-cta {
    display: flex;
    position: sticky;
    bottom: 72px;
    left: 0;
    right: 0;
    padding: 12px 16px;
    background: var(--white);
    border-top: 1px solid var(--border);
    z-index: 10;
  }

  .mobile-screen-a-cta .btn-primary {
    width: 100%;
    height: 48px;
    font-size: 15px;
    font-weight: 600;
  }

  /* Header Screen B dengan back button */
  .mobile-screen-b-header {
    display: none; /* tampil hanya di mobile Screen B */
  }
}

@media (max-width: 768px) {
  .mobile-screen-b-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    height: 52px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  .mobile-back-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-back-btn svg {
    width: 20px;
    height: 20px;
    stroke: var(--near-black);
    fill: none;
    stroke-width: 2;
  }

  .mobile-screen-b-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--near-black);
  }
}

/* ═══════════════════════════════════════════════════
   PLATFORM SELECTOR MOBILE (Opsi C: 2 level)
   ═══════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .mobile-platform-selector {
    padding: 12px 16px 0;
  }

  .mobile-platform-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
  }

  .mobile-platform-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
  }

  .mobile-platform-tabs::-webkit-scrollbar { display: none; }

  .mobile-platform-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1.5px solid var(--border);
    background: var(--white);
    cursor: pointer;
    white-space: nowrap;
    min-width: 64px;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
    font-size: 11px;
    font-weight: 500;
    color: var(--secondary);
  }

  .mobile-platform-tab.active {
    border-color: var(--primary, #6d28d9);
    background: #f5f3ff;
    color: var(--primary, #6d28d9);
  }

  .mobile-platform-tab svg {
    width: 20px;
    height: 20px;
  }

  /* Format pills — level 2 */
  .mobile-format-pills {
    display: flex;
    gap: 6px;
    padding: 10px 16px 0;
    flex-wrap: wrap;
  }

  .mobile-format-pill {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: var(--white);
    font-size: 12px;
    font-weight: 500;
    color: var(--secondary);
    cursor: pointer;
    transition: all 0.15s;
    min-height: 34px;
    display: flex;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-format-pill.active {
    border-color: var(--primary, #6d28d9);
    background: #f5f3ff;
    color: var(--primary, #6d28d9);
    font-weight: 600;
  }
}

/* ═══════════════════════════════════════════════════
   CAPTION — BOTTOM SHEET EDITOR
   ═══════════════════════════════════════════════════ */

.mobile-caption-sheet-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1100;
  opacity: 0;
  transition: opacity 0.25s;
}

.mobile-caption-sheet-overlay.open {
  opacity: 1;
}

.mobile-caption-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-radius: 20px 20px 0 0;
  padding: 0 0 env(safe-area-inset-bottom);
  z-index: 1101;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 85dvh;
  display: flex;
  flex-direction: column;
}

.mobile-caption-sheet.open {
  transform: translateY(0);
}

.mobile-caption-sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px auto 0;
  flex-shrink: 0;
}

.mobile-caption-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.mobile-caption-sheet-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--near-black);
}

.mobile-caption-sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mobile-caption-textarea {
  width: 100%;
  min-height: 160px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--near-black);
  resize: none;
  line-height: 1.5;
  outline: none;
}

.mobile-caption-textarea:focus {
  border-color: var(--primary, #6d28d9);
}

.mobile-caption-char-count {
  font-size: 11px;
  color: var(--secondary);
  text-align: right;
}

.mobile-caption-char-count.near-limit { color: #f59e0b; }
.mobile-caption-char-count.over-limit { color: #ef4444; }

.mobile-caption-sheet-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.mobile-caption-save-btn {
  width: 100%;
  height: 48px;
  background: var(--primary, #6d28d9);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.mobile-caption-regen-btn {
  width: 100%;
  height: 44px;
  background: var(--surface);
  color: var(--near-black);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* ═══════════════════════════════════════════════════
   MAP MODAL
   ═══════════════════════════════════════════════════ */

.mobile-map-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--white);
  z-index: 1200;
  flex-direction: column;
}

.mobile-map-modal-overlay.open {
  display: flex;
}

.mobile-map-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 52px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.mobile-map-modal-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--near-black);
}

.mobile-map-close-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--near-black);
  border-radius: 50%;
}

.mobile-map-container {
  flex: 1;
  position: relative;
}

.mobile-map-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
  background: var(--white);
}

.mobile-map-reach-text {
  font-size: 13px;
  color: var(--secondary);
  text-align: center;
}

.mobile-map-apply-btn {
  width: 100%;
  height: 48px;
  background: var(--primary, #6d28d9);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════
   SILARIS FAB
   ═══════════════════════════════════════════════════ */

.mobile-silaris-fab {
  display: none;
}

@media (max-width: 768px) {
  .mobile-silaris-fab {
    display: flex;
    position: fixed;
    bottom: 72px; /* di atas tab bar */
    right: 16px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #6d28d9;
    color: white;
    border: none;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(109,40,217,0.35);
    z-index: 800;
    font-size: 22px;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s, box-shadow 0.15s;
  }

  .mobile-silaris-fab:active {
    transform: scale(0.93);
    box-shadow: 0 2px 8px rgba(109,40,217,0.25);
  }
}

/* ═══════════════════════════════════════════════════
   SILARIS CHAT SCREEN (fullscreen di mobile)
   ═══════════════════════════════════════════════════ */

.mobile-silaris-screen {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--white);
  z-index: 1300;
  flex-direction: column;
}

.mobile-silaris-screen.open {
  display: flex;
}

.mobile-silaris-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  height: 52px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.mobile-silaris-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #6d28d9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.mobile-silaris-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--near-black);
  flex: 1;
}

.mobile-silaris-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

.mobile-silaris-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--near-black);
}

.mobile-silaris-bubble.ai {
  background: #f5f3ff;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}

.mobile-silaris-bubble.user {
  background: #6d28d9;
  color: white;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}

.mobile-silaris-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  flex-shrink: 0;
  background: var(--white);
}

.mobile-silaris-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  min-height: 44px;
  background: var(--surface);
}

.mobile-silaris-input:focus {
  border-color: var(--primary, #6d28d9);
  background: var(--white);
}

.mobile-silaris-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #6d28d9;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mobile-silaris-send-btn svg {
  width: 18px;
  height: 18px;
  stroke: white;
  fill: none;
  stroke-width: 2;
}

/* ═══════════════════════════════════════════════════
   TAYANGKAN — STICKY CTA di Screen B
   ═══════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .mobile-launch-bar {
    position: sticky;
    bottom: 60px; /* di atas tab bar */
    left: 0;
    right: 0;
    padding: 10px 16px;
    background: var(--white);
    border-top: 1px solid var(--border);
    z-index: 50;
  }

  .mobile-launch-bar .btn-primary {
    width: 100%;
    height: 48px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 12px;
  }
}

/* ═══════════════════════════════════════════════════
   KELOLA IKLAN — campaign cards mobile
   ═══════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .monitor-wrap {
    flex-direction: column;
    padding: 12px;
    gap: 12px;
    padding-bottom: 80px;
  }

  .campaign-card {
    width: 100%;
    cursor: pointer;
  }

  .campaign-card-thumb {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    flex-shrink: 0;
  }

  /* Sembunyikan tombol pause/play di mobile (belum ada API) */
  .campaign-pause-btn,
  .campaign-play-btn {
    display: none;
  }
}

/* ═══════════════════════════════════════════════════
   PERFORMA — analytics mobile
   ═══════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .an-stat-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 0 12px;
  }

  .an-stat-card {
    padding: 12px;
  }

  .an-content-wrap {
    padding: 12px;
    padding-bottom: 80px;
  }
}

/* ═══════════════════════════════════════════════════
   PANEL ID TARGETING — override class-based rules
   ═══════════════════════════════════════════════════ */

@media (max-width: 768px) {

  /* Semua panel: full width */
  #panel-upload,
  #panel-map-desktop,
  #panel-caption {
    width: 100%;
    min-width: unset;
    max-width: unset;
    height: auto;
    border-radius: 0;
  }

  /* Map panel: SELALU hidden di mobile (ganti modal) */
  #panel-map-desktop {
    display: none !important;
  }

  /* Caption panel: hidden di Screen A, visible di Screen B */
  #panel-caption {
    display: none;
  }
  #panel-caption.mobile-visible {
    display: flex;
    flex-direction: column;
  }

  /* Bottom bar: hidden di Screen A, visible di Screen B */
  .bottom-bar {
    display: none;
  }
  .bottom-bar.mobile-screen-b {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 16px;
    padding-bottom: calc(68px + env(safe-area-inset-bottom));
    height: auto;
    border-top: 1px solid var(--border);
    background: var(--white);
  }

  /* Tombol Lihat Peta (dalam bottom bar, Screen B) */
  .mobile-lihat-peta-btn {
    width: 100%;
    padding: 10px 16px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: var(--white);
    font-size: 13px;
    font-weight: 500;
    color: var(--near-black);
    cursor: pointer;
    text-align: left;
    min-height: 44px;
  }

  /* Lanjut bar (Screen A sticky CTA) */
  .mobile-lanjut-bar {
    padding: 10px 16px;
    background: var(--white);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
  }

  /* Kelola: panels-monitor stack vertikal */
  .panels-monitor {
    flex-direction: column !important;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
    gap: 12px;
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
  }

  .panels-monitor > .panel:last-child {
    width: 100% !important;
    flex-shrink: unset;
  }

  /* Sembunyikan SiLaris chat panel desktop di Kelola
     (diganti FAB + fullscreen chat) */
  .panels-monitor > .panel:last-child {
    display: none;
  }

  /* Campaign cards: full width, touch-friendly */
  .panels-monitor > .panel:first-child {
    overflow-y: visible;
  }
}

/* ═══════════════════════════════════════════════════
   SAFE AREA (iPhone notch & home indicator)
   ═══════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .mobile-tab-bar {
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(60px + env(safe-area-inset-bottom));
  }

  .panels {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }
}
