/**
 * Mobile Web - Ajustes para experiência em celular
 * Breakpoint principal: 768px
 */

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

/* ===== VIEWPORT & SAFE AREA ===== */
@supports (padding: max(0px)) {
  .mobile-header {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  .content-body {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
}

/* ===== MOBILE LAYOUT ===== */
@media (max-width: 768px) {
  html {
    font-size: 15px;
    -webkit-text-size-adjust: 100%;
  }

  body {
    overflow-x: hidden;
    touch-action: manipulation;
  }

  .app-layout {
    overflow-x: hidden;
  }

  /* Main content - sem margens laterais, full width */
  .app-layout .main-content {
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 0;
    box-shadow: none;
  }

  .content-body {
    padding: 60px 16px 24px; /* espaço pro topbar fixo */
    min-height: calc(100vh - 56px);
  }

  .app-layout--authenticated .content-body {
    padding-bottom: calc(8px + 72px + env(safe-area-inset-bottom, 0px));
    min-height: calc(100vh - 128px - env(safe-area-inset-bottom, 0px));
  }

  .content-container {
    padding: 0;
    max-width: 100%;
    width: 100%;
  }

  /* Mobile header - fixo e visível */
  .mobile-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0;
    min-height: 0;
    border-bottom: none;
    background: transparent;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 120;
  }

  .mobile-menu-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border: none;
    background: transparent;
    color: var(--color-text-primary, #1d1d1f);
    cursor: pointer;
    font-size: 20px;
    border-radius: 10px;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-menu-toggle:active {
    background: rgba(0, 0, 0, 0.06);
  }

  .mobile-header-title {
    font-size: 18px;
    font-weight: 600;
    flex: 1;
  }

  /* Barra superior: hamburguer + scroll horizontal de telas */
  .mobile-header--app {
    display: block;
  }

  .mobile-topbar {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.98);
    border-bottom: 1px solid var(--color-border, #e5e7eb);
    backdrop-filter: saturate(160%) blur(6px);
    z-index: 121;
    transition: transform 0.24s ease, opacity 0.2s ease;
    will-change: transform, opacity;
  }

  .mobile-topbar.is-hidden {
    transform: translateY(-110%);
    opacity: 0.02;
    pointer-events: none;
  }

  .mobile-topbar-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 12px;
    border: 1px solid var(--color-border, #e2e8f0);
    background: #fff;
    color: var(--color-text-primary, #0f172a);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
  }

  .mobile-topbar-search {
    min-height: 44px;
    border-radius: 999px;
    border: 1px solid var(--color-border, #e2e8f0);
    background: #fff;
    color: #667085;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    width: 100%;
    text-align: left;
    font-size: 14px;
    font-weight: 500;
  }

  .mobile-topbar-search span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-topbar-profile {
    border-color: transparent;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
  }

  .mobile-topbar-avatar {
    color: #fff;
    font-size: 14px;
    font-weight: 700;
  }

  .app-floating-search,
  .app-floating-right {
    display: none !important;
  }

  .mobile-nav-scroll::-webkit-scrollbar {
    display: none;
    height: 0;
  }

  .mobile-nav-chip {
    flex: 0 0 auto;
    scroll-snap-align: start;
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--color-bg-secondary, #f1f5f9);
    color: var(--color-text-primary, #0f172a);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid var(--color-border, #e2e8f0);
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-nav-chip:active {
    opacity: 0.92;
    transform: scale(0.98);
  }

  .mobile-nav-chip.active {
    background: var(--color-primary, #2563eb);
    color: #fff;
    border-color: transparent;
  }

  /* Barra inferior fixa */
  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    padding: 10px 16px max(10px, env(safe-area-inset-bottom, 0px)) 16px;
    background: var(--color-bg-primary, #fff);
    border-top: 1px solid var(--color-border, #e5e7eb);
    box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.07);
  }

  .mobile-bottom-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 48px;
    text-decoration: none;
    color: var(--color-text-secondary, #64748b);
    font-size: 11px;
    font-weight: 600;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-bottom-nav__menu-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
  }

  .mobile-bottom-nav__item i {
    font-size: 20px;
  }

  .mobile-bottom-nav__item--side.is-active {
    color: var(--color-primary, #2563eb);
  }

  .mobile-bottom-nav__item--side:first-child {
    justify-self: start;
  }

  .mobile-bottom-nav__item--home {
    justify-self: center;
    width: 56px;
    height: 56px;
    margin-top: -22px;
    border-radius: 50%;
    background: var(--color-primary, #2563eb);
    color: #fff;
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.4);
    border: 3px solid var(--color-bg-primary, #fff);
  }

  .mobile-bottom-nav__item--home.is-active {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35), 0 6px 18px rgba(37, 99, 235, 0.45);
  }

  .mobile-bottom-nav__item--home .mobile-bottom-nav__logo {
    display: block;
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  }

  .mobile-bottom-nav__item--side:last-child {
    justify-self: end;
  }

  /* ===== HEADER SECTION ===== */
  .header-section {
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
    gap: 8px;
    min-height: auto;
    margin-bottom: 12px;
  }

  .header-section .header-left {
    min-width: 0;
  }

  .header-section .header-left ,
  .header-section .header-left h1 {
    font-size: 18px;
    line-height: 1.3;
  }

  .header-section .subtitle {
    font-size: 13px;
    margin-top: 4px;
  }

  .header-section .card-actions {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
  }

  .header-section .card-actions .btn-novo,
  .header-section .card-actions .action-btn,
  .header-section .card-actions a {
    min-height: 44px;
    padding: 10px 14px;
    font-size: 14px;
  }

  /* ===== FILTROS ===== */
  .page-filters-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 0;
    margin-bottom: 12px;
    gap: 10px;
  }

  .page-filters-bar .filters-search {
    max-width: none;
    min-width: 0;
  }

  .page-filters-bar .filters-controls {
    flex-wrap: wrap;
    gap: 8px;
  }

  .page-filters-bar .filters-controls select,
  .page-filters-bar .filters-controls input {
    min-height: 44px;
    font-size: 16px; /* Evita zoom no iOS */
  }

  .page-filters-bar .filters-clear {
    min-height: 44px;
    padding: 12px 16px;
  }

  /* ===== TABELAS ===== */
  .card-table {
    margin: 0 -16px 16px;
    border-radius: 0;
    border-left: none;
    border-right: none;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .card-table table {
    min-width: 600px;
  }

  .tabela-entregadores th,
  .tabela-entregadores td,
  .list-table th,
  .list-table td {
    padding: 12px 10px;
    font-size: 13px;
  }

  /* Botões de ação em tabelas - touch friendly */
  .btn-olho,
  .list-action-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* ===== BOTÕES GERAIS ===== */
  .btn-novo,
  .btn-primary,
  .action-btn,
  .btn-modern {
    min-height: 44px;
    padding: 12px 18px;
    font-size: 15px;
    -webkit-tap-highlight-color: transparent;
  }

  /* ===== PAGINAÇÃO ===== */
  .pagination {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    padding: 12px 0;
  }

  .pagination .btn-pag,
  .pagination-btn {
    min-height: 44px;
    padding: 10px 16px;
  }

  /* ===== CONTAINERS ===== */
  .entregadores-card,
  .franquia-container,
  .eligibility-container,
  .pix-admin-page,
  .perfil-wrapper,
  .mei-container {
    padding: 0;
    max-width: 100%;
  }

  .list-view {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ===== SIDEBAR MOBILE ===== */
  .sidebar-overlay {
    z-index: 99;
  }

  .app-layout .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.15);
  }

  .sidebar-nav-item {
    min-height: 48px;
    padding: 12px 16px;
    font-size: 15px;
  }

  .sidebar-user,
  .sidebar-logout-btn {
    min-height: 44px;
  }

  /* ===== MODAIS ===== */
  .modal,
  .help-modal-content,
  .config-modal-content {
    max-height: 90vh;
    overflow-y: auto;
  }

  .modal-content {
    margin: 16px;
    max-width: calc(100% - 32px);
  }

  /* ===== NOTIFICAÇÕES DROPDOWN ===== */
  .notifications-dropdown {
    position: fixed !important;
    top: 60px !important;
    left: 16px !important;
    right: 16px !important;
    width: auto !important;
    max-width: none !important;
    max-height: calc(100vh - 80px);
  }

  /* ===== TABS ===== */
  .tabs-container,
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding-bottom: 8px;
  }

  .tab-btn,
  .tab-button {
    padding: 12px 16px;
    font-size: 14px;
    white-space: nowrap;
  }

  /* ===== PÁGINAS DE LOGIN/AUTH ===== */
  .login-page,
  .login-container {
    padding: 16px;
    align-items: flex-start;
    padding-top: max(24px, env(safe-area-inset-top));
  }

  .login-card {
    width: 100%;
    max-width: 100%;
    padding: 24px 20px;
  }

  .login-card .form-input,
  .login-card input[type="text"],
  .login-card input[type="password"],
  .login-card input[type="email"] {
    font-size: 16px; /* Evita zoom no iOS */
    min-height: 48px;
  }

  .btn-login,
  .login-card button[type="submit"] {
    min-height: 48px;
    font-size: 16px;
  }
}

/* ===== MOBILE PEQUENO (< 400px) ===== */
@media (max-width: 400px) {
  .header-section .card-actions {
    flex-direction: column;
  }

  .header-section .card-actions .btn-novo,
  .header-section .card-actions .action-btn,
  .header-section .card-actions a {
    width: 100%;
    justify-content: center;
  }
}
