/* CRM V88 mobile shell matched to the desktop CRM visual system.
   Desktop and laptop layouts are unchanged. */

@media (max-width: 767px) {
  :root {
    --crm-v88-shell: #565c65;
    --crm-v88-shell-dark: #4d535b;
    --crm-v88-border: #686f79;
    --crm-v88-orange: #ff7a45;
    --crm-v88-surface: #ffffff;
    --crm-v88-page: #f4f7fb;
    --crm-v88-text: #1f2f43;
    --crm-v88-muted: #64748b;
  }

  body,
  #main {
    background: var(--crm-v88-page) !important;
  }

  /* Desktop-style mobile top bar */
  #topbar {
    position: sticky !important;
    top: 0 !important;
    z-index: 520 !important;
    width: 100% !important;
    height: 60px !important;
    min-height: 60px !important;
    padding: 8px !important;
    margin: 0 !important;
    display: grid !important;
    grid-template-columns: 42px minmax(92px, 1fr) 42px 42px 42px 42px !important;
    grid-template-rows: 42px !important;
    align-items: center !important;
    gap: 6px !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: var(--crm-v88-shell) !important;
    box-shadow: 0 3px 14px rgba(15, 23, 42, .18) !important;
    backdrop-filter: none !important;
    overflow: visible !important;
  }

  #topbar .page-title,
  #page-title-text {
    display: none !important;
  }

  #hamburger-btn {
    grid-column: 1 !important;
    grid-row: 1 !important;
  }

  #topbar .search-wrap,
  #topbar .hubspot-search {
    grid-column: 2 !important;
    grid-row: 1 !important;
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 42px !important;
    margin: 0 !important;
  }

  #topbar .search-wrap input,
  #topbar .hubspot-search input {
    width: 100% !important;
    height: 42px !important;
    min-height: 42px !important;
    padding: 0 12px 0 38px !important;
    border: 1px solid rgba(255, 255, 255, .22) !important;
    border-radius: 12px !important;
    background: rgba(255, 255, 255, .08) !important;
    color: #fff !important;
    font-family: 'DM Sans', 'Inter', Arial, sans-serif !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    box-shadow: none !important;
  }

  #topbar .search-wrap input::placeholder,
  #topbar .hubspot-search input::placeholder {
    color: #edf1f6 !important;
    opacity: .86 !important;
  }

  #topbar .search-icon {
    left: 13px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    color: var(--crm-v88-orange) !important;
    opacity: 1 !important;
    font-size: 0 !important;
  }

  #topbar .search-icon::before {
    content: '' !important;
    display: block !important;
    width: 18px !important;
    height: 18px !important;
    border: 2px solid currentColor !important;
    border-radius: 50% !important;
    box-sizing: border-box !important;
  }

  #topbar .search-icon::after {
    content: '' !important;
    position: absolute !important;
    width: 7px !important;
    height: 2px !important;
    right: -3px !important;
    bottom: 0 !important;
    border-radius: 2px !important;
    background: currentColor !important;
    transform: rotate(45deg) !important;
    transform-origin: center !important;
  }

  #topbar .topbar-actions {
    display: contents !important;
  }

  #topbar .topbar-utility-icons,
  #topbar .hub-assistant-chip,
  #topbar .hub-inline-btn {
    display: none !important;
  }

  #topbar .hub-quick-add {
    grid-column: 3 !important;
    grid-row: 1 !important;
  }

  #topbar #crm-refresh-btn {
    grid-column: 4 !important;
    grid-row: 1 !important;
  }

  #topbar .notif-btn,
  #topbar .hub-notif-btn {
    grid-column: 5 !important;
    grid-row: 1 !important;
  }

  #topbar .hub-account-chip {
    grid-column: 6 !important;
    grid-row: 1 !important;
  }

  #topbar #hamburger-btn,
  #topbar .hub-quick-add,
  #topbar #crm-refresh-btn,
  #topbar .notif-btn,
  #topbar .hub-notif-btn,
  #topbar .hub-account-chip {
    width: 42px !important;
    min-width: 42px !important;
    max-width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;
    margin: 0 !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: 1px solid rgba(255, 255, 255, .18) !important;
    border-radius: 12px !important;
    background: rgba(255, 255, 255, .06) !important;
    color: var(--crm-v88-orange) !important;
    box-shadow: none !important;
    font-size: 0 !important;
  }

  #topbar #hamburger-btn:hover,
  #topbar .hub-quick-add:hover,
  #topbar #crm-refresh-btn:hover,
  #topbar .hub-notif-btn:hover {
    background: rgba(255, 255, 255, .13) !important;
    color: #ff9a72 !important;
  }

  #topbar .hub-quick-add::before,
  #topbar .hub-quick-add::after {
    content: none !important;
    display: none !important;
  }

  #topbar #hamburger-btn svg,
  #topbar .hub-quick-add svg,
  #topbar #crm-refresh-btn svg,
  #topbar .hub-notif-btn svg {
    width: 19px !important;
    height: 19px !important;
    display: block !important;
    fill: none !important;
    stroke: currentColor !important;
    stroke-width: 1.8 !important;
    stroke-linecap: round !important;
    stroke-linejoin: round !important;
  }

  #topbar .hub-account-name,
  #topbar .hub-account-caret {
    display: none !important;
  }

  #topbar .hub-account-avatar {
    width: 32px !important;
    min-width: 32px !important;
    height: 32px !important;
    margin: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 10px !important;
    background: #fff !important;
    color: var(--crm-v88-shell-dark) !important;
    font-family: 'DM Sans', 'Inter', Arial, sans-serif !important;
    font-size: 12px !important;
    font-weight: 900 !important;
  }

  #topbar .search-results {
    top: calc(100% + 7px) !important;
    left: 0 !important;
    right: 0 !important;
    width: min(330px, calc(100vw - 16px)) !important;
    max-height: min(56vh, 380px) !important;
    border-radius: 14px !important;
  }

  #content {
    padding-top: 10px !important;
  }

  /* Use desktop typography on mobile */
  #content .section-title,
  #content .card-title,
  #content .metric-val,
  #content .stat-block-val,
  #dashboard-greeting,
  #content h1,
  #content h2,
  #content h3 {
    font-family: 'DM Sans', 'Inter', Arial, sans-serif !important;
    font-weight: 900 !important;
    letter-spacing: -.02em !important;
  }

  #content .section-sub,
  #content .card-subtitle,
  #content .metric-label,
  #content .stat-block-label,
  #dash-date {
    font-family: 'DM Sans', 'Inter', Arial, sans-serif !important;
  }

  /* Cleaner dashboard command header */
  #page-dashboard > .section-header {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 44px !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 14px !important;
    background: linear-gradient(100deg, #fff 0%, #fbfdff 68%, #fff7f3 100%) !important;
    border: 1px solid #dbe4ef !important;
    border-radius: 16px !important;
    box-shadow: 0 7px 20px rgba(15, 23, 42, .04) !important;
  }

  #page-dashboard > .section-header > div:first-child {
    min-width: 0 !important;
  }

  #page-dashboard > .section-header #dashboard-greeting {
    font-size: 21px !important;
    line-height: 1.18 !important;
    color: var(--crm-v88-text) !important;
  }

  #page-dashboard > .section-header #dash-date {
    margin-top: 4px !important;
    color: var(--crm-v88-muted) !important;
    font-size: 10.5px !important;
    font-weight: 700 !important;
  }

  #page-dashboard > .section-header > button {
    grid-column: 2 !important;
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
    border: 1px solid #d6e0ec !important;
    border-radius: 12px !important;
    background: #fff !important;
    color: var(--crm-v88-orange) !important;
    font-size: 0 !important;
    box-shadow: none !important;
  }

  #page-dashboard > .section-header > button svg {
    width: 19px !important;
    height: 19px !important;
    fill: none !important;
    stroke: currentColor !important;
    stroke-width: 1.8 !important;
    stroke-linecap: round !important;
    stroke-linejoin: round !important;
  }

  #page-dashboard .metric-card {
    background: #fff !important;
    border: 1px solid #dbe4ef !important;
    box-shadow: 0 7px 20px rgba(15, 23, 42, .035) !important;
  }

  #page-dashboard .metric-icon {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    border-radius: 11px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 17px !important;
  }

  /* Desktop sidebar colors and icons in mobile bottom navigation */
  #mobile-bottom-nav {
    height: calc(66px + env(safe-area-inset-bottom)) !important;
    padding: 0 6px env(safe-area-inset-bottom) !important;
    border-top: 1px solid var(--crm-v88-border) !important;
    background: rgba(86, 92, 101, .99) !important;
    box-shadow: 0 -8px 28px rgba(15, 23, 42, .18) !important;
  }

  #mobile-bottom-nav .mbn-inner {
    height: 66px !important;
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: 4px !important;
    align-items: center !important;
  }

  #mobile-bottom-nav .mbn-item {
    min-width: 0 !important;
    height: 56px !important;
    padding: 5px 2px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    border: 0 !important;
    border-radius: 12px !important;
    background: transparent !important;
    color: #eef2f7 !important;
    font-family: 'DM Sans', 'Inter', Arial, sans-serif !important;
    font-size: 9px !important;
    font-weight: 800 !important;
  }

  #mobile-bottom-nav .mbn-item.active {
    background: rgba(255, 255, 255, .12) !important;
    box-shadow: inset 0 3px 0 var(--crm-v88-orange) !important;
    color: #fff !important;
  }

  #mobile-bottom-nav .mbn-icon {
    width: 23px !important;
    height: 23px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: var(--crm-v88-orange) !important;
    font-size: 0 !important;
  }

  #mobile-bottom-nav .mbn-icon svg {
    width: 22px !important;
    height: 22px !important;
    fill: none !important;
    stroke: currentColor !important;
    stroke-width: 1.8 !important;
    stroke-linecap: round !important;
    stroke-linejoin: round !important;
  }

  /* More sheet follows the desktop sidebar style */
  #mobile-more-sheet {
    padding: 14px !important;
    border: 1px solid var(--crm-v88-border) !important;
    background: var(--crm-v88-shell) !important;
    box-shadow: 0 18px 50px rgba(15, 23, 42, .28) !important;
  }

  #mobile-more-sheet button {
    min-height: 82px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 7px !important;
    border: 1px solid rgba(255, 255, 255, .13) !important;
    border-radius: 12px !important;
    background: rgba(255, 255, 255, .07) !important;
    color: #fff !important;
    font-family: 'DM Sans', 'Inter', Arial, sans-serif !important;
    font-weight: 800 !important;
  }

  #mobile-more-sheet button:hover,
  #mobile-more-sheet button:active {
    background: rgba(255, 255, 255, .14) !important;
  }

  #mobile-more-sheet .crm-v88-more-icon {
    width: 24px !important;
    height: 24px !important;
    display: inline-flex !important;
    color: var(--crm-v88-orange) !important;
  }

  #mobile-more-sheet .crm-v88-more-icon svg {
    width: 24px !important;
    height: 24px !important;
    fill: none !important;
    stroke: currentColor !important;
    stroke-width: 1.8 !important;
    stroke-linecap: round !important;
    stroke-linejoin: round !important;
  }

  #mobile-more-sheet .crm-v88-more-label {
    font-size: 10px !important;
    line-height: 1.2 !important;
    text-align: center !important;
  }
}

@media (max-width: 390px) {
  #topbar {
    grid-template-columns: 38px minmax(78px, 1fr) 38px 38px 38px 38px !important;
    padding: 7px !important;
    gap: 4px !important;
  }

  #topbar #hamburger-btn,
  #topbar .hub-quick-add,
  #topbar #crm-refresh-btn,
  #topbar .notif-btn,
  #topbar .hub-notif-btn,
  #topbar .hub-account-chip {
    width: 38px !important;
    min-width: 38px !important;
    max-width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
    border-radius: 10px !important;
  }

  #topbar .search-wrap,
  #topbar .hubspot-search,
  #topbar .search-wrap input,
  #topbar .hubspot-search input {
    height: 38px !important;
    min-height: 38px !important;
  }

  #topbar .hub-account-avatar {
    width: 29px !important;
    min-width: 29px !important;
    height: 29px !important;
  }
}
