/* ============================================================
   PETCARE IA — AJUSTES MOBILE
   Sobrescreve o app.css apenas em telas pequenas
   ============================================================ */

/* ========== BOTTOM NAV BAR (mobile only) ========== */
.bottom-nav {
  display: none;
}

@media (max-width: 900px) {

  /* ========== ESCONDE A SIDEBAR ========== */
  .sidebar { 
    transform: translateX(-100%);
    transition: transform .3s ease;
  }
  .sidebar.open { 
    transform: translateX(0);
    box-shadow: 0 0 60px rgba(0,0,0,0.3);
  }

  /* Overlay para fechar o menu lateral */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9;
    backdrop-filter: blur(2px);
  }
  .sidebar-overlay.show {
    display: block;
    animation: fadeIn .2s ease;
  }

  /* ========== CONTEÚDO PRINCIPAL ========== */
  .main-content {
    margin-left: 0;
    padding: 16px 16px 100px 16px; /* espaço pra bottom nav */
    max-width: 100%;
  }

  /* ========== TOPBAR MOBILE ========== */
  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 8;
    margin: -16px -16px 16px -16px;
  }
  .mobile-topbar .logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 17px;
    color: var(--primary);
  }
  .mobile-topbar .logo span:first-child { font-size: 22px; }
  .mobile-topbar .menu-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--bg);
    border: none;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* ========== BOTTOM NAV ========== */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid var(--border);
    padding: 8px 4px 12px;
    z-index: 20;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
  }
  .bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 4px;
    color: var(--text-soft);
    font-size: 10px;
    font-weight: 500;
    text-decoration: none;
    transition: color .2s;
    position: relative;
  }
  .bottom-nav a .ico {
    font-size: 22px;
    line-height: 1;
    transition: transform .2s;
  }
  .bottom-nav a.active {
    color: var(--primary);
  }
  .bottom-nav a.active .ico {
    transform: scale(1.15);
  }
  .bottom-nav a.active::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    background: var(--primary);
    border-radius: 100px;
  }

  /* ========== TIPOGRAFIA ========== */
  h1 { font-size: 22px; }
  h2 { font-size: 19px; }
  h3 { font-size: 16px; }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
  }
  .page-header .btn { width: 100%; }

  /* ========== CARDS ========== */
  .card { 
    padding: 18px;
    border-radius: 16px;
  }

  /* ========== GRIDS ========== */
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Ações rápidas continuam em 2 colunas no celular */
  .grid-4.quick-actions {
    grid-template-columns: repeat(2, 1fr);
  }

  /* ========== BOTÕES ========== */
  .btn { 
    padding: 14px 20px;
    font-size: 15px;
  }
  .btn-primary { width: 100%; }

  /* ========== CHAT ========== */
  .chat-wrapper {
    height: calc(100vh - 180px);
    border-radius: 16px;
  }
  .msg { max-width: 85%; font-size: 14px; }
  .chat-input input { font-size: 15px; }

  /* ========== FORMULÁRIOS ========== */
  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .form-control {
    font-size: 16px; /* evita zoom no iOS */
  }

  /* ========== MODAIS ========== */
  div[style*="position:fixed"][style*="inset:0"] > .card,
  #modal-new > .card,
  #modal-triage > .card {
    max-width: 100% !important;
    width: 100% !important;
    max-height: 95vh !important;
    border-radius: 20px 20px 0 0 !important;
    margin-top: auto;
    animation: slideUp .3s ease !important;
  }

  div[style*="position:fixed"][style*="inset:0"] {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  /* ========== TABELAS (admin) ========== */
  .table {
    font-size: 12px;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
  .table th, .table td {
    padding: 10px 8px;
  }

  /* ========== USER CARD DO DASHBOARD ========== */
  .card[style*="display:flex"][style*="align-items:center"] {
    flex-direction: column;
    text-align: center;
  }

  /* ========== LIST ITEMS ========== */
  .list-item {
    flex-wrap: wrap;
    padding: 14px;
  }
  .list-item .info { width: 100%; }
  .list-item .badge { margin-left: auto; }

}

/* Telas muito pequenas */
@media (max-width: 400px) {
  .grid-4.quick-actions { grid-template-columns: 1fr; }
  .bottom-nav a { font-size: 9px; }
  .bottom-nav a .ico { font-size: 20px; }
}

/* ========== ANIMAÇÕES ========== */
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ========== DESKTOP: esconde topbar e bottom nav ========== */
@media (min-width: 901px) {
  .mobile-topbar { display: none; }
  .sidebar-overlay { display: none !important; }
}

/* ============================================================
   AJUSTES DO SIDEBAR NO MOBILE
   ============================================================ */

@media (max-width: 900px) {

  /* Sidebar fica acima da bottom nav */
  .sidebar {
    z-index: 100 !important;
    padding-bottom: 90px !important; /* espaço para a bottom nav */
  }

  /* Overlay fica abaixo do sidebar, mas acima do resto */
  .sidebar-overlay {
    z-index: 99 !important;
  }

  /* Rodapé do sidebar (avatar + sair) ganha destaque */
  .sidebar-footer {
    position: sticky;
    bottom: 0;
    background: #fff;
    padding-top: 16px;
    padding-bottom: 8px;
    margin-top: auto;
  }

  /* Garante que o nav interno role se necessário */
  .sidebar-nav {
    overflow-y: auto;
    flex: 1;
    padding-bottom: 12px;
  }
}