/*!
 * Mobile Responsive Fix v1.0
 * Professional CakePHP Panel - Mobile First
 * Copyright 2024
 */

/* ============================================
   MOBILE SIDEBAR - ESTRUTURA PERFEITA
   ============================================ */

/* Mobile: max-width 992px */
@media (max-width: 992px) {
  
  /* ========================================
     SIDEBAR PRINCIPAL - VERSÃO ELEGANTE
     ======================================== */
  .left-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: -100% !important;
    width: 280px !important;
    max-width: 75% !important;
    height: 100vh !important;
    height: 100dvh !important; /* Dynamic viewport height */
    z-index: 1050 !important;
    transition: left 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.95), -2px 0 0 rgba(59, 130, 246, 0.1) inset !important;
    background: linear-gradient(180deg, #1a2332 0%, #1e2a3a 50%, #162028 100%) !important;
    border-right: 2px solid rgba(59, 130, 246, 0.2) !important;
  }

  /* Sidebar aberto */
  #main-wrapper.show-sidebar .left-sidebar {
    left: 0 !important;
  }
  
  /* Animação suave ao abrir */
  #main-wrapper.show-sidebar .left-sidebar {
    animation: sidebarSlideIn 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
  }
  
  @keyframes sidebarSlideIn {
    from {
      left: -100% !important;
      opacity: 0.8;
    }
    to {
      left: 0 !important;
      opacity: 1;
    }
  }

  /* Overlay removido - não é mais necessário */

  /* ========================================
     BODY COM SIDEBAR ABERTO
     ======================================== */
  body.sidebar-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100vh !important;
  }

  /* ========================================
     HEADER MOBILE
     ======================================== */
  .app-header {
    position: sticky !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    z-index: 1030 !important;
    background: var(--dark-blue-primary) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3) !important;
  }

  .app-header .navbar {
    padding: 0.75rem 1rem !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }

  /* Garantir que navbar não empurre conteúdo */
  .body-wrapper {
    padding-top: 0 !important;
  }

  /* ========================================
     BOTÃO TOGGLE SIDEBAR - SEMPRE VISÍVEL
     ======================================== */
  .sidebartoggler,
  #headerCollapse,
  .nav-link.sidebartoggler {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 0.5rem !important;
    background: var(--dark-blue-accent) !important;
    border-radius: 8px !important;
    transition: all 0.3s ease !important;
    cursor: pointer !important;
    border: none !important;
    outline: none !important;
  }

  .sidebartoggler:hover,
  #headerCollapse:hover {
    background: var(--blue-bright) !important;
    box-shadow: 0 0 15px var(--blue-glow) !important;
    transform: scale(1.05) !important;
  }

  .sidebartoggler i,
  #headerCollapse i {
    color: var(--text-primary) !important;
    font-size: 1.5rem !important;
    line-height: 1 !important;
  }

  /* ========================================
     BOTÃO NAVBAR TOGGLER COM PERFIL
     ======================================== */
  .navbar-toggler {
    border: 2px solid var(--border-dark) !important;
    border-radius: 50% !important;
    padding: 0 !important;
    width: 44px !important;
    height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s ease !important;
    background: transparent !important;
    overflow: hidden !important;
  }

  .navbar-toggler:hover {
    border-color: var(--blue-bright) !important;
    box-shadow: 0 0 15px var(--blue-glow) !important;
    transform: scale(1.05) !important;
  }

  .navbar-toggler .user-profile-img {
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .navbar-toggler .user-profile-img img {
    width: 40px !important;
    height: 40px !important;
    object-fit: cover !important;
    border: 2px solid var(--border-dark) !important;
    transition: all 0.3s ease !important;
  }

  .navbar-toggler:hover .user-profile-img img {
    border-color: var(--blue-bright) !important;
    box-shadow: 0 0 10px var(--blue-glow) !important;
  }

  /* ========================================
     BOTÃO FECHAR SIDEBAR - VERSÃO MELHORADA
     ======================================== */
  .close-btn,
  #sidebarCollapse {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    background: rgba(255, 255, 255, 0.1) !important;
    border: 2px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 50% !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
  }

  .close-btn:hover,
  #sidebarCollapse:hover {
    background: rgba(220, 53, 69, 0.2) !important;
    border-color: rgba(220, 53, 69, 0.5) !important;
    transform: scale(1.1) rotate(90deg) !important;
    box-shadow: 0 0 15px rgba(220, 53, 69, 0.4) !important;
  }
  
  .close-btn:active,
  #sidebarCollapse:active {
    transform: scale(0.95) rotate(90deg) !important;
  }

  .close-btn i,
  #sidebarCollapse i {
    color: var(--text-primary) !important;
    font-size: 1.5rem !important;
    transition: transform 0.3s ease !important;
  }
  
  .close-btn:hover i,
  #sidebarCollapse:hover i {
    transform: rotate(180deg) !important;
  }

  /* ========================================
     BRAND LOGO NO SIDEBAR - VERSÃO MELHORADA
     ======================================== */
  .brand-logo {
    min-height: 75px !important;
    padding: 1.25rem 1rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    background: linear-gradient(135deg, #2d4a6b 0%, #1e2a3a 70%, #162028 100%) !important;
    border-bottom: 2px solid rgba(59, 130, 246, 0.3) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3) !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
  }

  .brand-logo img {
    max-width: 180px !important;
    height: auto !important;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3)) !important;
  }
  
  /* Botão fechar mais visível */
  .brand-logo .close-btn,
  .brand-logo #sidebarCollapse {
    width: 42px !important;
    height: 42px !important;
    background: rgba(255, 255, 255, 0.1) !important;
    border: 2px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s ease !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
  }
  
  .brand-logo .close-btn:hover,
  .brand-logo #sidebarCollapse:hover {
    background: rgba(220, 53, 69, 0.2) !important;
    border-color: rgba(220, 53, 69, 0.5) !important;
    transform: scale(1.1) rotate(90deg) !important;
    box-shadow: 0 0 15px rgba(220, 53, 69, 0.4) !important;
  }
  
  .brand-logo .close-btn i,
  .brand-logo #sidebarCollapse i {
    color: var(--text-primary) !important;
    font-size: 1.5rem !important;
    transition: transform 0.3s ease !important;
  }

  /* ========================================
     NAVEGAÇÃO DO SIDEBAR - VERSÃO ELEGANTE
     ======================================== */
  .sidebar-nav,
  .left-sidebar .scroll-sidebar {
    padding: 1.5rem 1rem !important;
    height: calc(100vh - 80px) !important;
    height: calc(100dvh - 80px) !important; /* Dynamic viewport height */
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    scroll-behavior: smooth !important;
  }

  .sidebar-nav ul,
  .left-sidebar .scroll-sidebar ul {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .sidebar-nav ul li,
  .left-sidebar .scroll-sidebar ul li {
    margin-bottom: 0.4rem !important;
  }

  .sidebar-nav ul li a,
  .left-sidebar .scroll-sidebar ul li a {
    padding: 1.1rem 1.35rem !important;
    font-size: 0.95rem !important;
    font-weight: 500 !important;
    border-radius: 12px !important;
    display: flex !important;
    align-items: center !important;
    gap: 1.1rem !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    color: rgba(255, 255, 255, 0.88) !important;
    background: rgba(255, 255, 255, 0.02) !important;
    border-left: 3px solid transparent !important;
    position: relative !important;
    text-decoration: none !important;
    margin-bottom: 0.25rem !important;
    border: 1px solid transparent !important;
  }
  
  /* Efeito hover elegante */
  .sidebar-nav ul li a:hover,
  .left-sidebar .scroll-sidebar ul li a:hover {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.2) 0%, rgba(59, 130, 246, 0.08) 50%, transparent 100%) !important;
    color: var(--blue-bright) !important;
    border-left-color: var(--blue-bright) !important;
    border-color: rgba(59, 130, 246, 0.2) !important;
    transform: translateX(6px) !important;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25), 0 0 0 1px rgba(59, 130, 246, 0.1) inset !important;
  }

  /* Link ativo elegante */
  .sidebar-nav ul li a.active,
  .left-sidebar .scroll-sidebar ul li a.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.3) 0%, rgba(59, 130, 246, 0.15) 50%, rgba(59, 130, 246, 0.05) 100%) !important;
    color: var(--blue-bright) !important;
    border-left-color: var(--blue-bright) !important;
    border-color: rgba(59, 130, 246, 0.3) !important;
    font-weight: 600 !important;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.35), 0 0 0 1px rgba(59, 130, 246, 0.2) inset !important;
    text-shadow: 0 0 10px rgba(59, 130, 246, 0.3) !important;
  }
  
  /* Ícones elegantes */
  .sidebar-nav ul li a .animated-icon,
  .left-sidebar .scroll-sidebar ul li a .animated-icon,
  .sidebar-nav ul li a i,
  .left-sidebar .scroll-sidebar ul li a i {
    font-size: 1.35rem !important;
    width: 30px !important;
    min-width: 30px !important;
    text-align: center !important;
    flex-shrink: 0 !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    color: rgba(255, 255, 255, 0.7) !important;
  }
  
  .sidebar-nav ul li a:hover .animated-icon,
  .left-sidebar .scroll-sidebar ul li a:hover .animated-icon,
  .sidebar-nav ul li a:hover i,
  .left-sidebar .scroll-sidebar ul li a:hover i {
    transform: scale(1.15) translateX(2px) !important;
    color: var(--blue-bright) !important;
    filter: drop-shadow(0 0 6px rgba(59, 130, 246, 0.5)) !important;
  }
  
  .sidebar-nav ul li a.active .animated-icon,
  .left-sidebar .scroll-sidebar ul li a.active .animated-icon,
  .sidebar-nav ul li a.active i,
  .left-sidebar .scroll-sidebar ul li a.active i {
    color: var(--blue-bright) !important;
    filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.6)) !important;
  }
  
  /* Badges e labels nos itens do menu */
  .sidebar-nav ul li a .badge,
  .left-sidebar .scroll-sidebar ul li a .badge {
    margin-left: auto !important;
    font-size: 0.75rem !important;
    padding: 0.25rem 0.5rem !important;
  }

  /* ========================================
     MAIN CONTENT
     ======================================== */
  .page-wrapper {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  .body-wrapper {
    padding: 0.75rem !important;
    margin-top: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  .body-wrapper > .container-fluid {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
    max-width: 100% !important;
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* Garantir que mw-100 não cause overflow */
  .container-fluid.mw-100 {
    max-width: 100% !important;
    width: 100% !important;
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }

  /* ========================================
     CARDS MOBILE
     ======================================== */
  .card {
    margin-bottom: 1rem !important;
    border-radius: 12px !important;
  }

  .card-body {
    padding: 1.25rem !important;
  }

  .card-header {
    padding: 1rem !important;
  }

  /* ========================================
     BOTÕES MOBILE
     ======================================== */
  .btn {
    padding: 0.75rem 1.25rem !important;
    font-size: 0.95rem !important;
    min-height: 44px !important;
    border-radius: 8px !important;
  }

  /* ========================================
     FORMULÁRIOS MOBILE
     ======================================== */
  .form-control,
  .form-select {
    font-size: 16px !important; /* Previne zoom no iOS */
    padding: 0.75rem 1rem !important;
    min-height: 44px !important;
    border-radius: 8px !important;
  }

  .form-label {
    font-size: 0.9rem !important;
    margin-bottom: 0.5rem !important;
  }

  /* ========================================
     TABELAS MOBILE
     ======================================== */
  .table-responsive {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    border-radius: 8px !important;
  }

  .table {
    min-width: 600px !important;
    font-size: 0.9rem !important;
  }

  .table th,
  .table td {
    padding: 0.75rem !important;
    white-space: nowrap !important;
  }

  /* ========================================
     MODAIS MOBILE
     ======================================== */
  .modal-dialog {
    margin: 0.5rem !important;
    max-width: calc(100% - 1rem) !important;
  }

  .modal-content {
    border-radius: 12px !important;
  }

  .modal-header {
    padding: 1.25rem !important;
  }

  .modal-body {
    padding: 1.25rem !important;
    max-height: calc(100vh - 200px) !important;
    overflow-y: auto !important;
  }

  .modal-footer {
    padding: 1rem !important;
    flex-direction: column !important;
    gap: 0.5rem !important;
  }

  .modal-footer .btn {
    width: 100% !important;
  }

  /* ========================================
     DROPDOWNS MOBILE
     ======================================== */
  .dropdown-menu {
    max-width: calc(100vw - 2rem) !important;
    max-height: calc(100vh - 100px) !important;
    overflow-y: auto !important;
    border-radius: 12px !important;
  }

  /* ========================================
     NAVBAR COLLAPSE MOBILE
     ======================================== */
  .navbar-collapse {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    background: var(--dark-blue-primary) !important;
    border-top: 1px solid var(--border-dark) !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6) !important;
    max-height: calc(100vh - 70px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    z-index: 1029 !important;
  }

  .navbar-collapse.show {
    display: block !important;
  }

  .navbar-collapse .navbar-nav {
    padding: 1rem !important;
  }

  .navbar-collapse .nav-item {
    margin-bottom: 0.5rem !important;
  }

  /* ========================================
     SCROLLBAR MOBILE
     ======================================== */
  /* Scrollbar melhorada */
  .left-sidebar::-webkit-scrollbar,
  .sidebar-nav::-webkit-scrollbar,
  .left-sidebar .scroll-sidebar::-webkit-scrollbar,
  .modal-body::-webkit-scrollbar {
    width: 8px;
  }

  .left-sidebar::-webkit-scrollbar-track,
  .sidebar-nav::-webkit-scrollbar-track,
  .left-sidebar .scroll-sidebar::-webkit-scrollbar-track,
  .modal-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
  }

  .left-sidebar::-webkit-scrollbar-thumb,
  .sidebar-nav::-webkit-scrollbar-thumb,
  .left-sidebar .scroll-sidebar::-webkit-scrollbar-thumb,
  .modal-body::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.5) 0%, rgba(59, 130, 246, 0.3) 100%);
    border-radius: 10px;
    border: 2px solid rgba(0, 0, 0, 0.1);
  }

  .left-sidebar::-webkit-scrollbar-thumb:hover,
  .sidebar-nav::-webkit-scrollbar-thumb:hover,
  .left-sidebar .scroll-sidebar::-webkit-scrollbar-thumb:hover,
  .modal-body::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--blue-bright) 0%, rgba(59, 130, 246, 0.8) 100%);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
  }

  /* ========================================
     UTILITÁRIOS MOBILE
     ======================================== */
  
  /* Prevenir zoom no iOS */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  input[type="url"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px !important;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
  }

  /* Melhorar touch targets */
  a,
  button,
  .btn,
  input[type="submit"],
  input[type="button"] {
    min-height: 44px !important;
    min-width: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Prevenir seleção de texto em botões */
  button,
  .btn {
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
  }

  /* Scroll suave */
  * {
    -webkit-overflow-scrolling: touch !important;
  }

  /* Imagens responsivas */
  img {
    max-width: 100% !important;
    height: auto !important;
  }
}

/* ============================================
   EXTRA SMALL DEVICES (max-width: 576px)
   ============================================ */
@media (max-width: 576px) {
  
  /* Sidebar com largura moderada em telas pequenas */
  .left-sidebar {
    width: 75% !important;
    max-width: 280px !important;
    min-width: 260px !important;
  }

  /* Ajustes de texto */
  h1 { font-size: 1.75rem !important; }
  h2 { font-size: 1.5rem !important; }
  h3 { font-size: 1.25rem !important; }
  h4 { font-size: 1.1rem !important; }
  h5 { font-size: 1rem !important; }
  h6 { font-size: 0.95rem !important; }

  /* Padding reduzido */
  .body-wrapper > .container-fluid {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  .container-fluid.mw-100 {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  .card-body {
    padding: 1rem !important;
  }

  /* Botões full width */
  .btn {
    width: 100% !important;
    margin-bottom: 0.5rem !important;
  }

  .btn-group .btn {
    width: auto !important;
  }
}

/* ============================================
   LANDSCAPE MOBILE (max-height: 500px)
   ============================================ */
@media (max-height: 500px) {
  
  /* Ajustes para landscape */
  .sidebar-nav,
  .left-sidebar .scroll-sidebar {
    height: calc(100vh - 65px) !important;
    height: calc(100dvh - 65px) !important;
    max-height: calc(100vh - 65px) !important;
  }

  .brand-logo {
    min-height: 65px !important;
    padding: 0.875rem 1rem !important;
  }

  .brand-logo img {
    max-width: 150px !important;
  }
}

/* ============================================
   TABLET (min-width: 769px) and (max-width: 992px)
   ============================================ */
@media (min-width: 769px) and (max-width: 992px) {
  
  /* Tablet: sidebar fixo */
  .left-sidebar {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    width: 270px !important;
    height: 100vh !important;
    z-index: 1040 !important;
  }

  /* Tablet: main content com margem */
  .page-wrapper {
    margin-left: 270px !important;
    width: calc(100% - 270px) !important;
    transition: margin-left 0.3s ease !important;
  }

  /* Tablet: body-wrapper */
  .body-wrapper {
    width: 100% !important;
    padding: 1rem !important;
  }

  /* Tablet: container-fluid */
  .body-wrapper > .container-fluid {
    max-width: 100% !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

}

/* ============================================
   DESKTOP (min-width: 993px)
   ============================================ */
@media (min-width: 993px) {
  
  /* Desktop: sidebar sempre visível - LARGURA FIXA */
  .left-sidebar {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    width: 270px !important;
    height: 100vh !important;
    z-index: 1040 !important;
  }

  /* Desktop: mini-sidebar */
  #main-wrapper.mini-sidebar .left-sidebar {
    width: 80px !important;
  }

  /* Desktop: main content com margem EXATA da sidebar (270px) */
  .page-wrapper {
    margin-left: 270px !important;
    width: calc(100% - 270px) !important;
    max-width: calc(100vw - 270px) !important;
    transition: margin-left 0.3s ease !important;
    padding: 0 !important;
    position: relative !important;
  }

  #main-wrapper.mini-sidebar .page-wrapper {
    margin-left: 80px !important;
    width: calc(100% - 80px) !important;
    max-width: calc(100vw - 80px) !important;
  }

  /* Desktop: body-wrapper - ocupa 100% do page-wrapper, SEM margem */
  .body-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    padding: 1.5rem !important;
    margin: 0 !important;
    position: relative !important;
  }

  /* Desktop: navbar dentro do body-wrapper - SEM margem extra */
  .body-wrapper > .app-header {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .body-wrapper > .app-header .navbar {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
  }

  /* Desktop: container-fluid - SEM max-width restritivo, ocupa 100% */
  .body-wrapper > .container-fluid {
    max-width: 100% !important;
    width: 100% !important;
    padding-left: 1.5rem !important;
    padding-right: 1.5rem !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* Garantir que mw-100 não quebre o layout - ocupa 100% */
  .container-fluid.mw-100 {
    max-width: 100% !important;
    width: 100% !important;
    padding-left: 1.5rem !important;
    padding-right: 1.5rem !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* Garantir que rows não tenham margem extra */
  .body-wrapper .row,
  .container-fluid .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* Garantir que cards não tenham margem extra */
  .body-wrapper .card,
  .container-fluid .card {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* SOBRESCREVER qualquer max-width do style.css que centralize */
  #main-wrapper[data-layout=vertical] .body-wrapper > .container-fluid {
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

}

/* ============================================
   ANIMAÇÕES
   ============================================ */

/* Animações removidas - overlay não é mais usado */

/* Animação de slide in para sidebar */
@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ============================================
   FIX PARA iOS
   ============================================ */
@supports (-webkit-touch-callout: none) {
  /* Fix para viewport height no iOS */
  .left-sidebar {
    height: -webkit-fill-available !important;
    min-height: -webkit-fill-available !important;
  }
  
  .sidebar-nav,
  .left-sidebar .scroll-sidebar {
    height: calc(-webkit-fill-available - 75px) !important;
    min-height: calc(-webkit-fill-available - 75px) !important;
  }

  .modal-body {
    max-height: -webkit-fill-available !important;
  }

  body.sidebar-open {
    height: -webkit-fill-available !important;
  }
}

/* ============================================
   GARANTIR VISIBILIDADE DOS ELEMENTOS
   ============================================ */

/* Garantir que o botão toggle sempre apareça no mobile */
@media (max-width: 992px) {
  .sidebartoggler,
  #headerCollapse {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }
}

/* ============================================
   PREVENIR OVERFLOW HORIZONTAL GLOBAL
   ============================================ */
html, body {
  overflow-x: hidden !important;
  max-width: 100vw !important;
}

#main-wrapper {
  overflow-x: hidden !important;
  max-width: 100vw !important;
}

/* ============================================
   FIXES ESPECÍFICOS PARA SAFARI iOS
   ============================================ */
@supports (-webkit-touch-callout: none) {
  /* Prevenir highlight de tap no iOS Safari */
  .sidebartoggler,
  #headerCollapse,
  #sidebarCollapse,
  #mobileProfileToggle,
  #closeMobileProfile,
  .close-btn,
  .navbar-toggler,
  .profile-toggle-btn {
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
    cursor: pointer !important;
    touch-action: manipulation !important;
  }
  
  /* Garantir que links funcionem corretamente no iOS Safari */
  a.sidebartoggler,
  a#headerCollapse {
    pointer-events: auto !important;
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent !important;
  }
  
  /* Garantir que botões funcionem corretamente no iOS Safari */
  button.navbar-toggler,
  button#mobileProfileToggle {
    pointer-events: auto !important;
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent !important;
    touch-action: manipulation !important;
  }
  
  /* Prevenir comportamento padrão de link no iOS Safari */
  a[href="javascript:void(0)"] {
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-callout: none !important;
    cursor: pointer !important;
  }
  
  /* Garantir que mobile-profile-overlay seja clicável no iOS Safari */
  .mobile-profile-overlay {
    -webkit-tap-highlight-color: transparent !important;
    touch-action: manipulation !important;
    cursor: pointer !important;
  }
  
  /* Prevenir zoom indesejado no iOS Safari ao tocar */
  @media (max-width: 992px) {
    .sidebartoggler,
    #headerCollapse,
    #mobileProfileToggle,
    .close-btn,
    #sidebarCollapse {
      touch-action: manipulation !important;
      -webkit-tap-highlight-color: transparent !important;
    }
  }
  
  /* Garantir que elementos com user-profile-img sejam clicáveis */
  .user-profile-img,
  .user-profile-img img {
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-callout: none !important;
    pointer-events: auto !important;
    cursor: pointer !important;
  }
  
  /* Garantir que o dropdown seja interativo no iOS Safari */
  .mobile-profile-dropdown {
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y !important;
  }
  
  /* Garantir que o sidebar seja interativo no iOS Safari */
  .left-sidebar {
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y !important;
  }
}


/* Garantir que o sidebar tenha prioridade sobre outros elementos */
.left-sidebar {
  z-index: 1050 !important;
}

.app-header {
  z-index: 1030 !important;
}

/* Garantir que modais fiquem acima de tudo */
.modal {
  z-index: 1055 !important;
}

.modal-backdrop {
  z-index: 1054 !important;
}

/* ============================================
   CORREÇÕES ESPECÍFICAS PARA CONTAINER
   ============================================ */

/* Garantir que container-fluid.mw-100 funcione corretamente */
.container-fluid.mw-100 {
  max-width: 100% !important;
  width: 100% !important;
}

/* Mobile: container sem margens extras */
@media (max-width: 992px) {
  .container-fluid.mw-100 {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
}

/* Tablet: container com padding adequado */
@media (min-width: 769px) and (max-width: 992px) {
  .container-fluid.mw-100 {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
}

/* Desktop: container centralizado */
@media (min-width: 993px) {
  .container-fluid.mw-100 {
    padding-left: 1.5rem !important;
    padding-right: 1.5rem !important;
    max-width: 100% !important;
  }
}

/* ============================================
   GARANTIR QUE ELEMENTOS NÃO SEJAM CORTADOS
   ============================================ */

/* Prevenir que elementos saiam da tela */
* {
  box-sizing: border-box !important;
}

/* Garantir que imagens sejam responsivas */
img {
  max-width: 100% !important;
  height: auto !important;
}

/* Garantir que inputs não quebrem o layout */
@media (max-width: 576px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  input[type="url"],
  input[type="search"],
  select,
  textarea {
    max-width: 100% !important;
  }
}

/* Garantir que botões não quebrem em mobile */
@media (max-width: 576px) {
  .btn-group {
    flex-direction: column !important;
    width: 100% !important;
  }

  .btn-group .btn {
    width: 100% !important;
    margin-bottom: 0.5rem !important;
  }
}

/* ============================================
   DROPDOWN DO PERFIL NO MOBILE - MODAL STYLE
   ============================================ */

/* Overlay escuro quando dropdown está aberto - SEMPRE NA FRENTE */
.mobile-profile-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  background: rgba(0, 0, 0, 0.7) !important;
  z-index: 9998 !important;
  display: none !important;
  backdrop-filter: blur(4px) !important;
  -webkit-backdrop-filter: blur(4px) !important;
  animation: fadeIn 0.3s ease-out !important;
  margin: 0 !important;
  padding: 0 !important;
}

.mobile-profile-overlay.show {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Dropdown do perfil para mobile - estilo modal - SEMPRE NA FRENTE */
.mobile-profile-dropdown {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: calc(100% - 2rem) !important;
  max-width: 400px !important;
  max-height: 85vh !important;
  z-index: 9999 !important;
  display: none !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8) !important;
  border-radius: 16px !important;
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
  pointer-events: auto !important;
  background: var(--bg-modal-dark, #1e2a3a) !important;
  visibility: hidden !important;
  opacity: 0 !important;
}

.mobile-profile-dropdown.show {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  animation: modalSlideIn 0.3s ease-out !important;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translate(-50%, -45%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

/* Garantir que o dropdown não seja cortado em telas pequenas */
@media (max-width: 576px) {
  .mobile-profile-dropdown {
    width: calc(100% - 1rem) !important;
    max-width: none !important;
    max-height: 90vh !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
  }
}

/* Garantir scroll interno se necessário */
.mobile-profile-dropdown .profile-dropdown {
  max-height: 85vh !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

@media (max-width: 576px) {
  .mobile-profile-dropdown .profile-dropdown {
    max-height: 90vh !important;
  }
}

/* Garantir que nenhum elemento interfira no dropdown - z-index máximo */
body .mobile-profile-dropdown,
html .mobile-profile-dropdown,
* .mobile-profile-dropdown {
  z-index: 9999 !important;
}

body .mobile-profile-overlay,
html .mobile-profile-overlay,
* .mobile-profile-overlay {
  z-index: 9998 !important;
}

/* Forçar visibilidade e posicionamento correto quando show */
.mobile-profile-dropdown.show {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  z-index: 9999 !important;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* Botão de fechar no dropdown mobile */
.btn-close-mobile-profile {
  background: transparent !important;
  border: none !important;
  color: var(--text-primary, #ffffff) !important;
  font-size: 1.2rem !important;
  cursor: pointer !important;
  padding: 0.25rem 0.5rem !important;
  border-radius: 4px !important;
  transition: all 0.2s ease !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 28px !important;
  height: 28px !important;
  line-height: 1 !important;
}

.btn-close-mobile-profile:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  color: var(--blue-bright, #3b82f6) !important;
  transform: scale(1.1) !important;
}

.btn-close-mobile-profile:active {
  transform: scale(0.95) !important;
}

.btn-close-mobile-profile i {
  font-size: 1rem !important;
}

