/* OniLink — smartphone / tablet */

@media (max-width: 768px) {
  .login-card {
    margin: 3vh 0.85rem 2rem;
    padding: 1.35rem 1.1rem;
    max-width: none;
  }

  .login-logo {
    height: 110px;
  }

  .login-card .btn,
  .login-card input {
    font-size: 16px;
    min-height: 44px;
  }

  #app-screen {
    height: 100dvh;
    max-height: 100dvh;
  }

  .app-shell {
    padding-bottom: calc(3.65rem + env(safe-area-inset-bottom, 0px));
  }

  .topbar {
    padding: 0.65rem 0.75rem;
    gap: 0.5rem;
  }

  .topbar-left {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.35rem;
  }

  .view-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar-center {
    order: 3;
    flex: 1 1 100%;
    max-width: none;
    min-width: 0;
  }

  .search-box input {
    font-size: 16px;
    min-height: 44px;
  }

  .topbar-right {
    gap: 0.35rem;
  }

  .topbar-right .btn-add {
    padding: 0.5rem 0.75rem;
    font-size: 0.82rem;
    min-height: 40px;
    width: auto;
  }

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

  .user-chip {
    display: none;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem;
    padding: 0 0.65rem;
  }

  .stat-card {
    min-height: 0;
    padding: 0.45rem 0.6rem;
  }

  .stat-body .stat-value {
    font-size: 1.15rem;
  }

  .dashboard-body {
    min-height: 0;
  }

  .main-column {
    min-height: 0;
  }

  .content-card.views-area {
    padding: 0.65rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .view-lead {
    font-size: 0.88rem;
    margin-bottom: 0.65rem;
  }

  .filter-bar,
  .filter-bar-2,
  .users-toolbar,
  .activity-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .filter-bar select,
  .users-toolbar .btn {
    width: 100%;
    min-height: 44px;
    font-size: 16px;
  }

  .users-toolbar {
    flex-direction: column;
  }

  .breadcrumb-bar,
  .computers-head {
    margin-bottom: 0.5rem;
  }

  .computers-head {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }

  .computers-title {
    font-size: 1.15rem;
  }

  .computers-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .computers-select,
  .btn-computers-refresh {
    width: 100%;
    min-height: 44px;
    font-size: 16px;
  }

  .computers-table-foot {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .computers-pagination {
    justify-content: center;
  }

  .table-wrap {
    -webkit-overflow-scrolling: touch;
    border-radius: 10px;
  }

  table.mobile-table:not(.mobile-table-cards) {
    min-width: 640px;
  }

  table.mobile-table.mobile-table-cards {
    min-width: 0;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.65rem;
  }

  table.mobile-table.mobile-table-cards thead {
    display: none;
  }

  table.mobile-table.mobile-table-cards tbody tr {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.35rem 0;
    margin-bottom: 0;
    box-shadow: var(--shadow-sm);
  }

  table.mobile-table.mobile-table-cards tbody tr.clickable-row:active {
    background: var(--surface2);
  }

  table.mobile-table.mobile-table-cards tbody tr.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.2);
  }

  table.mobile-table.mobile-table-cards td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.55rem 0.85rem;
    border: none;
    font-size: 0.9rem;
    text-align: right;
  }

  table.mobile-table.mobile-table-cards td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    text-align: left;
    flex-shrink: 0;
    max-width: 42%;
    padding-top: 0.1rem;
  }

  table.mobile-table.mobile-table-cards td[data-label=""]::before,
  table.mobile-table.mobile-table-cards td:not([data-label])::before {
    display: none;
  }

  table.mobile-table.mobile-table-cards td[colspan] {
    display: block;
    text-align: center;
  }

  table.mobile-table.mobile-table-cards td[colspan]::before {
    display: none;
  }

  table.mobile-table.mobile-table-cards .row-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  table.mobile-table.mobile-table-cards .row-actions .btn {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }

  .btn-sm {
    min-height: 40px;
    padding: 0.5rem 0.75rem;
  }

  .connect-box {
    padding: 0.85rem;
  }

  .connect-actions {
    flex-direction: column;
  }

  .connect-actions .btn {
    width: 100%;
    min-height: 44px;
  }

  .modal {
    max-width: 100vw;
    width: 100vw;
    margin: 0;
    border-radius: 0;
  }

  .modal-drawer {
    margin: auto 0 0 0;
    max-width: 100%;
    width: 100%;
    height: auto;
    max-height: min(92dvh, 100%);
    border-left: none;
    border-radius: 16px 16px 0 0;
    animation: drawer-up 0.22s ease;
  }

  @keyframes drawer-up {
    from { transform: translateY(100%); opacity: 0.7; }
    to { transform: translateY(0); opacity: 1; }
  }

  .modal-body input,
  .modal-body select,
  .modal-body textarea {
    font-size: 16px;
    min-height: 44px;
  }

  .modal-footer {
    flex-direction: column-reverse;
    gap: 0.5rem;
  }

  .modal-footer .btn {
    width: 100%;
    min-height: 44px;
    margin: 0;
  }

  .toast {
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
  }

  .sidebar {
    width: min(292px, 88vw);
    z-index: 300;
    padding-top: max(1rem, env(safe-area-inset-top));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }

  .sidebar-brand .panel-logo {
    height: 88px;
  }

  .nav-item {
    min-height: 48px;
    font-size: 0.95rem;
  }

  .sidebar-overlay {
    z-index: 250;
  }

  #view-computers .table-wrap.computers-table-scroll {
    max-height: none;
    flex: 1;
    min-height: 0;
  }

  .split-side {
    margin-top: 0.75rem;
  }

  .remote-viewer-modal {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
  }

  .installer-table {
    min-width: 0;
  }

  .installer-row {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 400px) {
  .stats-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Barra inferior — só celular */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 180;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 0.35rem 0.25rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.08);
    justify-content: space-around;
    align-items: stretch;
    gap: 0.15rem;
  }

  [data-theme="dark"] .mobile-bottom-nav {
    background: var(--surface);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.35);
  }

  .mobile-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-height: 52px;
    padding: 0.25rem 0.15rem;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 0.62rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 10px;
    position: relative;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-tab svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
  }

  .mobile-tab.active {
    color: var(--primary-dark);
    background: var(--primary-soft, #e0f2fe);
  }

  [data-theme="dark"] .mobile-tab.active {
    color: #7dd3fc;
    background: rgba(14, 165, 233, 0.15);
  }

  .mobile-tab-badge {
    position: absolute;
    top: 2px;
    right: calc(50% - 22px);
    background: var(--danger);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 1.1rem;
    height: 1.1rem;
    line-height: 1.1rem;
    padding: 0 0.2rem;
    border-radius: 999px;
    text-align: center;
  }

  .mobile-tab-badge.hidden {
    display: none;
  }
}

/* Banner instalar PWA */
.pwa-install-banner {
  position: fixed;
  left: 0.75rem;
  right: 0.75rem;
  bottom: calc(4.25rem + env(safe-area-inset-bottom, 0px));
  z-index: 190;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 0.75rem 0.85rem;
  animation: pwa-slide-up 0.28s ease;
}

@media (min-width: 769px) {
  .pwa-install-banner {
    bottom: 1.25rem;
    max-width: 420px;
    left: auto;
    right: 1.25rem;
  }
}

@keyframes pwa-slide-up {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.pwa-install-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.pwa-install-icon {
  border-radius: 12px;
  flex-shrink: 0;
}

.pwa-install-text {
  flex: 1;
  min-width: 0;
}

.pwa-install-text strong {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 0.15rem;
}

.pwa-install-text .hint {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.35;
}

.pwa-install-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.pwa-install-actions .btn-sm {
  min-height: 40px;
  width: auto;
  white-space: nowrap;
}

.pwa-install-close {
  min-width: 40px !important;
  padding: 0.35rem 0.5rem !important;
  font-size: 1.25rem;
  line-height: 1;
}

/* Modo app instalado */
@media (display-mode: standalone) {
  .pwa-install-banner {
    display: none !important;
  }
}
