/* Chatterfy 1-to-1 Mobile Adaptation (<= 768px) — App Shell, Dashboard (#channels), Campaigns, Flow & All Pages */

/* Mobile header, Flow FAB & Channels mobile filter button hidden on desktop */
.mobile-header,
.flow-mobile-fab,
.channels-mobile-filter-btn {
  display: none;
}

/* Bottom-sheet modal for mobile Channels Filters */
.ch-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 190;
  background: rgba(0, 0, 0, 0.56);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 8px;
}

.ch-sheet {
  width: 100%;
  max-width: 420px;
  border-radius: 18px;
  background: #0f1b2b;
  border: 1px solid #ffffff26;
  box-shadow: 0 0 1px 0 #ffffff4d inset, 0 -10px 36px rgba(0, 0, 0, 0.65);
  padding: 18px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ch-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

/* ==================== Left Slide-Over Navigation Drawer (331px / 85vw) ==================== */
.mobile-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 180;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: flex-start;
  animation: mob-fade-in 220ms ease;
}

.mobile-drawer-backdrop.closing {
  animation: mob-fade-out 180ms ease forwards;
}

.mobile-drawer {
  width: min(332px, 85vw);
  height: 100dvh;
  background: linear-gradient(180deg, #0d1c33 0%, #070e1a 100%);
  border-right: 1px solid #ffffff20;
  box-shadow: 12px 0 40px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #ecedee;
  animation: mob-slide-in 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

.mobile-drawer-backdrop.closing .mobile-drawer {
  animation: mob-slide-out 180ms ease forwards;
}

@keyframes mob-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes mob-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes mob-slide-in { from { transform: translateX(-100%); } to { transform: translateX(0); } }
@keyframes mob-slide-out { from { transform: translateX(0); } to { transform: translateX(-100%); } }

.mobile-drawer-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid #ffffff16;
}

.mobile-drawer-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
}

.mobile-drawer-brand img {
  width: 30px;
  height: 30px;
}

.mobile-drawer-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #a1a1aa;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.mobile-drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mobile-drawer-section {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mobile-drawer-label {
  padding: 4px 10px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #71717a;
}

.mobile-drawer-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  color: #ecedee;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background-color 140ms ease;
}

.mobile-drawer-link svg {
  color: #a1a1aa;
  flex: none;
}

.mobile-drawer-link:hover,
.mobile-drawer-link[aria-current="page"] {
  background: #2c3554;
  color: #fff;
}

.mobile-drawer-link[aria-current="page"] svg {
  color: #fff;
}

.mobile-drawer-foot {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid #ffffff16;
  background: rgba(0, 0, 0, 0.25);
}

.mobile-drawer-profile {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: #ecedee;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 6px;
  border-radius: 8px;
  cursor: pointer;
}

.mobile-drawer-foot-acts {
  display: inline-flex;
  gap: 6px;
}

/* ==================== <= 768px Mobile Breakpoint (390x844 verified 1-to-1) ==================== */
@media (max-width: 768px) {
  /* App Shell: Hide desktop rail & desktop header, show exact 80px mobile header */
  .app-shell {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: 64px minmax(0, 1fr) !important;
  }

  .app-rail,
  .app-header {
    display: none !important;
  }

  .mobile-header {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    height: 64px;
    padding: 0 12px;
    background: transparent;
    z-index: 30;
  }

  .mobile-hdr-btn {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #ecedee;
    display: grid;
    place-items: center;
    cursor: pointer;
  }

  .mobile-hdr-btn:hover {
    background: rgba(255, 255, 255, 0.08);
  }

  .mobile-hdr-brand {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #fff;
    text-decoration: none;
  }

  .mobile-hdr-brand img {
    width: 26px;
    height: 26px;
  }

  .mobile-hdr-right {
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }

  .workspace {
    grid-column: 1 !important;
    grid-row: 2 !important;
    border-radius: 0 !important;
    border: 0 !important;
    background: transparent !important;
    min-width: 0;
    overflow: hidden;
  }

  /* ===== 1. Main Dashboard / Bots Page (#channels — 1-to-1 with original /bots at 390x844) ===== */
  .channels-page {
    display: flex !important;
    flex-direction: column !important;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden !important;
  }

  /* Spaces sidebar hidden on mobile (moved inside Open drawer, 1-to-1 with original) */
  .channels-nav,
  .channels-stats,
  .channels-filters .channel-filter-desktop {
    display: none !important;
  }

  .channels-content {
    padding: 12px 16px 24px !important;
    min-width: 0;
  }

  .channels-filters {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    margin-bottom: 14px !important;
  }

  .channels-filters .search-box {
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
  }

  .channels-mobile-filter-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    flex: 0 0 80px;
    width: 80px;
    height: 40px;
    border-radius: 14px;
    border: 1px solid #ffffff26;
    background: #1c2236;
    color: #ecedee;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
  }

  .channels-mobile-filter-btn:hover {
    background: #2c3554;
  }

  .channel-groups {
    padding-inline: 0 !important;
  }

  .channel-group-heading {
    padding: 14px 16px !important;
  }

  .channel-group-body {
    padding: 0 12px 12px !important;
  }

  .mobile-hdr-create-bot {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 8px;
    background: #0384f6;
    color: #fff;
    display: inline-grid;
    place-items: center;
    cursor: pointer;
    flex: none;
  }

  .tc-two-col {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .tc-info-two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  .tc-param-top {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  /* ===== 2. Tracker Campaigns (#tracker/campaigns) ===== */
  .pa-page,
  .pa-page.pa-tracker-shell {
    display: block !important;
    height: 100%;
  }

  .pa-sidebar {
    display: none !important;
  }

  .pa-content,
  .pa-tracker-shell .pa-content {
    padding: 16px !important;
    height: 100%;
    overflow-y: auto;
  }

  .tc-header h1 {
    font-size: 22px;
  }

  .tc-filters {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .tc-search,
  .tc-filter-select,
  .tc-w-invite,
  .tc-w-dm,
  .tc-w-buyer,
  .tc-w-status,
  .tc-w-domain,
  .tc-w-land {
    width: 100% !important;
    flex: 0 0 auto !important;
  }

  .tc-search input {
    height: 36px;
  }

  .tc-cards-grid {
    grid-template-columns: 1fr !important;
    gap: 14px;
  }

  .tc-card-head,
  .tc-kv-list {
    padding: 16px;
  }

  .tc-funnel-band {
    padding: 14px 10px;
    gap: 8px;
  }

  .tc-funnel-stage {
    min-width: 44px;
  }

  .tc-funnel-val {
    font-size: 16px;
  }

  .tc-card-footer {
    padding: 12px 16px 14px;
  }

  /* Create/Edit Campaign modal on mobile: 378x832 (6px margin all around, rounded-14) */
  .tc-drawer-backdrop {
    padding: 6px;
    align-items: stretch;
    justify-content: center;
  }

  .tc-drawer {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    border-radius: 14px !important;
  }

  .tc-drawer-head {
    padding: 16px 16px 10px;
  }

  .tc-tabs-scroll {
    padding: 4px 16px 12px;
    scrollbar-width: none;
  }

  .tc-tabs-scroll::-webkit-scrollbar {
    display: none;
  }

  .tc-drawer-body {
    padding: 4px 16px 20px;
  }

  .tc-drawer-footer {
    padding: 12px 16px;
  }

  .tc-info-two-col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  /* ===== 3. Flow Editor (#flows) ===== */
  .flow-page,
  .flow-page.flow-collapsed {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .flow-palette {
    display: none !important;
  }

  /* Bottom-left 32x32 primary FAB for Flow settings (exact original size) */
  .flow-mobile-fab {
    display: inline-grid;
    place-items: center;
    position: fixed;
    left: 14px;
    bottom: 14px;
    z-index: 45;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 8px;
    background: #0384f6;
    color: #fff;
    box-shadow: 0 4px 12px rgba(3, 132, 246, 0.35);
    cursor: pointer;
  }

  .flow-toolbar {
    top: 12px;
    left: 20px;
    right: 16px;
    gap: 10px 8px;
    flex-wrap: wrap !important;
  }

  .flow-divider {
    height: 20px;
    opacity: 0.65;
  }

  .flow-select {
    width: 196px !important;
    flex: 0 0 196px !important;
  }

  .flow-search {
    width: 196px !important;
    flex: 0 0 196px !important;
  }

  /* Full-screen right drawers on mobile */
  .flow-drawer {
    width: 100vw !important;
    max-width: 100vw !important;
    border-radius: 0 !important;
  }

  .flow-drawer-header,
  .flow-stepper,
  .flow-drawer-body,
  .flow-drawer-footer {
    padding-inline: 16px !important;
  }

  .flow-stepper-label {
    font-size: 13px;
  }

  .flow-stepper-circle {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .flow-stepper-line {
    margin: 0 8px;
  }

  /* ===== 4. All Other Pages (Chats, Settings, Tables, Analytics, Tasks, Funnels) ===== */
  .chats-page {
    grid-template-columns: 1fr !important;
  }

  .chat-nav,
  .chat-preview {
    display: none;
  }

  .settings-page {
    display: flex !important;
    flex-direction: column !important;
  }

  .settings-nav {
    border-right: 0 !important;
    border-bottom: 1px solid #ffffff1c;
    overflow-x: auto;
    flex-direction: row !important;
    padding: 10px 12px !important;
  }

  .standard-page,
  .records-page,
  .ops-page {
    padding: 14px !important;
  }

  .pa-titlebar {
    flex-direction: column;
    align-items: stretch;
  }

  .pa-filters > * {
    width: 100% !important;
    flex: 1 1 100% !important;
  }

  .dialog {
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
    margin: auto !important;
  }
}
