/* ============================================================
   Moho CRM — Responsive
   ============================================================ */

/* Tablet & below */
@media (max-width: 991.98px) {
  .crm-sidebar {
    transform: translateX(-100%);
  }

  .crm-sidebar.show {
    transform: translateX(0);
  }

  .crm-main {
    margin-left: 0;
  }

  .crm-content {
    padding: 12px 14px 20px;
  }

  .page-title {
    font-size: 16px;
  }

  .kpi-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .kpi-value {
    font-size: 14px;
  }

  .chart-wrap {
    height: 240px;
  }

  .offcanvas-crm {
    width: 100% !important;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .payment-summary-box {
    grid-template-columns: 1fr 1fr;
  }
}

/* Mobile */
@media (max-width: 575.98px) {
  html {
    font-size: 14px;
  }

  .crm-navbar {
    padding: 6px 10px;
  }

  .crm-content {
    padding: 10px 10px 18px;
  }

  .kpi-card {
    padding: 10px 12px;
  }

  .kpi-value {
    font-size: 14px;
  }

  .kpi-label {
    font-size: 10px;
  }

  .filters-bar .form-control,
  .filters-bar .form-select {
    min-width: 100%;
    width: 100%;
  }

  .filters-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filters-bar-compact .filter-search,
  .filters-bar-compact .filter-sm,
  .filters-bar-compact .filter-city,
  .filters-bar-compact .filter-date,
  .filters-bar-compact .filter-per-page {
    flex: 1 1 100%;
    width: 100%;
    max-width: 100%;
  }

  .auth-card {
    padding: 22px 18px;
  }

  .notification-menu {
    width: calc(100vw - 16px);
    position: fixed !important;
    top: var(--navbar-height) !important;
    left: 8px !important;
    right: 8px !important;
    transform: none !important;
  }

  .btn {
    min-height: 38px;
  }

  .btn-sm {
    min-height: 32px;
  }

  .table-desktop {
    display: none !important;
  }

  .clients-mobile {
    display: block !important;
  }

  .payment-summary-box {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 576px) {
  .clients-mobile {
    display: none !important;
  }
}

/* Prevent horizontal overflow */
.crm-wrapper,
.crm-main,
.crm-content {
  max-width: 100%;
}

img,
canvas,
svg,
table {
  max-width: 100%;
}

.mobile-header-brand {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--primary, #47040A);
  white-space: nowrap;
}

.contact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cc-contact a {
  word-break: break-word;
}

.download-app-icon {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  object-fit: cover;
  margin-bottom: 12px;
}

.download-app-hero {
  text-align: center;
}

.download-app-hero h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary, #47040A);
  margin-bottom: 8px;
}

.download-apk-link {
  display: block;
  word-break: break-all;
  font-size: 13px;
  font-weight: 600;
}

.mobile-bottom-nav {
  display: none;
}

.more-nav-sheet .more-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 4px;
  min-height: 44px;
  color: var(--text, #334155);
  font-weight: 500;
  border-bottom: 1px solid var(--border, #E2E8F0);
}

.more-nav-sheet .more-nav-item:last-child {
  border-bottom: 0;
}

.more-nav-sheet .more-nav-item i {
  width: 20px;
  color: var(--muted, #64748B);
}

body.sidebar-open {
  overflow: hidden;
}

@media (max-width: 991.98px) {
  .crm-navbar {
    padding-top: calc(6px + env(safe-area-inset-top, 0px));
    padding-left: 10px;
    padding-right: 10px;
  }

  .btn-icon {
    width: 44px;
    height: 44px;
  }

  .invoice-action {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .invoice-action i {
    font-size: 22px;
  }

  .crm-content {
    padding-bottom: calc(28px + 56px + env(safe-area-inset-bottom, 0px));
  }

  .crm-footer {
    padding-bottom: calc(12px + 56px + env(safe-area-inset-bottom, 0px));
  }

  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #fff;
    border-top: 1px solid var(--border, #E2E8F0);
    justify-content: space-around;
    align-items: stretch;
  }

  .mobile-bottom-nav a,
  .mobile-bottom-nav button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: 0;
    background: transparent;
    color: var(--muted, #64748B);
    font-size: 11px;
    font-weight: 500;
    min-height: 48px;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-bottom-nav i {
    font-size: 18px;
    line-height: 1;
  }

  .mobile-bottom-nav a.active,
  .mobile-bottom-nav button.active,
  .mobile-bottom-nav a:hover,
  .mobile-bottom-nav button:hover {
    color: var(--primary, #47040A);
  }

  #toastContainer {
    bottom: calc(56px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .form-control,
  .form-select {
    min-height: 44px;
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  textarea.form-control {
    min-height: 88px;
  }

  .btn:not(.btn-icon):not(.btn-close) {
    min-height: 44px;
  }

  .page-header,
  .d-flex.gap-2.flex-wrap {
    row-gap: 8px;
  }

  .chart-wrap {
    width: 100%;
    max-width: 100%;
  }

  .more-nav-sheet {
    height: auto !important;
    max-height: 80vh;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
  }

  .cal-cell {
    min-height: 48px;
    padding: 4px;
  }
  .cal-alarm-actions .btn {
    flex: 1 1 100%;
  }
}

@media (max-width: 767.98px) {
  .bill-toolbar > div:first-child {
    width: 100%;
  }

  .bill-actions {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px !important;
    width: 100%;
  }

  .bill-actions .btn:not(.btn-icon):not(.btn-close) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 34px;
    padding: 4px 6px;
    font-size: 12px;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: 8px;
  }

  .bill-actions--wide-save #btnSaveBill {
    grid-column: 1 / -1;
    order: -1;
  }

  .bill-actions--list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bill-actions--list .btn:last-child {
    grid-column: 1 / -1;
  }
}

@media (display-mode: standalone) {
  .crm-navbar {
    padding-top: calc(8px + env(safe-area-inset-top, 0px));
  }
}
