/* ========================================
   DECLARUSHUB - MOBILE & PWA STYLES (REFINADO)
   Interface Mobile-First tipo App — PREMIUM DARK (FLAT)
   ======================================== */

/* ========================================
   MOBILE BASE / PWA
   ======================================== */

:root{
  --m-safe-top: env(safe-area-inset-top);
  --m-safe-bottom: env(safe-area-inset-bottom);
  --m-header-h: 60px;
  --m-bottomnav-h: 65px;

  /* Header mobile (mesma identidade da sidebar) */
  --m-header-bg: #101040;
  --m-header-border: rgba(255,255,255,0.10);

  /* Bottom nav sólido (não usar --bg-primary pois no global ele tem alpha) */
  --m-bottomnav-bg: #101040;
  --m-bottomnav-border: rgba(255,255,255,0.10);

  /* Hover branco no bottom nav */
  --m-bottomnav-hover-bg: rgba(255,255,255,0.03);
  --m-bottomnav-hover-text: rgba(255,255,255,0.94);
}

html{
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Evita zoom em inputs no iOS */
input, select, textarea{
  font-size: 16px;
}

.touch-target{
  min-height: 44px;
  min-width: 44px;
}

/* Prevent text selection + tap highlight */
.btn, button, .action-btn, a{
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

body{
  overscroll-behavior-y: contain;
}

/* ========================================
   MOBILE HEADER & NAVIGATION
   ======================================== */

/* Estrutura do header (não controla display aqui) */
.dashboard .mobile-header,
body .mobile-header,
.mobile-header{
  position: fixed;
  top: 0;
  left: 0;
  right: 0;

  /* ✅ cobre o safe-area do topo (resolve o “preto”) */
  height: calc(var(--m-header-h) + var(--m-safe-top));

  /* padding já inclui safe-area */
  padding:
    calc(var(--space-2) + var(--m-safe-top))
    var(--space-4)
    var(--space-2)
    var(--space-4);

  background-color: var(--m-header-bg) !important;
  background-image: none !important;
  border-bottom: 1px solid var(--m-header-border) !important;

  color: rgba(255,255,255,0.94) !important;

  z-index: 999;
  box-shadow: none !important;
  backdrop-filter: none !important;

  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.dashboard .mobile-header::before,
.dashboard .mobile-header::after,
.mobile-header::before,
.mobile-header::after{
  content: none !important;
  background: none !important;
  filter: none !important;
}

.mobile-header > *,
.mobile-header-left,
.mobile-header-right{
  background: transparent !important;
}

.mobile-header-left{
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.hamburger-btn{
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(255,255,255,0.10) !important;
  color: rgba(255,255,255,0.92) !important;

  cursor: pointer;
  padding: 0;
  width: 44px;
  height: 44px;

  border-radius: 14px;
  transition: var(--transition);

  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hamburger-btn:hover{
  background: rgba(255,255,255,0.10) !important;
  border-color: rgba(255,255,255,0.16) !important;
}

.hamburger-btn:active{
  transform: scale(0.98);
  background: rgba(255, 255, 255, 0.10) !important;
  border-color: rgba(255,255,255,0.16) !important;
}

.mobile-logo{
  height: 32px;
  width: auto;
}

.mobile-header-right{
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.mobile-user-btn{
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(255,255,255,0.10) !important;
  color: rgba(255,255,255,0.92) !important;

  padding: 10px 12px;
  border-radius: 14px;

  font-size: 0.85rem;
  font-weight: 700;

  cursor: pointer;
  white-space: nowrap;
  max-width: 150px;

  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar Overlay */
.sidebar-overlay{
  display: none;
  position: fixed;
  inset: 0;

  background: rgba(0, 0, 0, 0.55);
  z-index: 998;

  opacity: 0;
  transition: opacity var(--transition);
}

.sidebar-overlay.active{
  opacity: 1;
}

/* ========================================
   BOTTOM NAVIGATION (Mobile)
   ======================================== */

.bottom-nav{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;

  height: calc(var(--m-bottomnav-h) + var(--m-safe-bottom));
  padding-bottom: var(--m-safe-bottom);

  /* ✅ sólido (resolve o “transparente”) */
  background-color: var(--m-bottomnav-bg) !important;
  background-image: none !important;
  border-top: 1px solid var(--m-bottomnav-border) !important;

  z-index: 900;
  box-shadow: none !important;
  backdrop-filter: none !important;
}

.bottom-nav::before,
.bottom-nav::after{
  content: none !important;
  background: none !important;
}

.bottom-nav-container{
  display: flex;
  justify-content: space-around;
  align-items: center;

  height: var(--m-bottomnav-h);
  max-width: 680px;
  margin: 0 auto;
  padding: 0 var(--space-2);
}

.bottom-nav-item{
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  flex: 1;
  height: 100%;

  color: var(--text-secondary);
  text-decoration: none !important;

  font-size: 0.72rem;
  font-weight: 700;

  transition: var(--transition);
  position: relative;
}

.bottom-nav-item:active{
  background: rgba(255,255,255,0.04);
}

/* Hover do menu inferior: branco + sem underline */
.bottom-nav-item:hover,
.bottom-nav-item:focus,
.bottom-nav-item:focus-visible{
  color: var(--m-bottomnav-hover-text) !important;
  text-decoration: none !important;
  background: var(--m-bottomnav-hover-bg);
}

.bottom-nav-item:hover .bottom-nav-label,
.bottom-nav-item:hover .bottom-nav-icon,
.bottom-nav-item:focus .bottom-nav-label,
.bottom-nav-item:focus .bottom-nav-icon,
.bottom-nav-item:focus-visible .bottom-nav-label,
.bottom-nav-item:focus-visible .bottom-nav-icon{
  color: var(--m-bottomnav-hover-text) !important;
  text-decoration: none !important;
}

.bottom-nav-item.active{
  color: rgba(255,255,255,0.94);
}

.bottom-nav-item.active::before{
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);

  width: 42px;
  height: 3px;

  background: rgba(208,176,96,0.85);
  border-radius: 0 0 999px 999px;
}

.bottom-nav-icon{
  font-size: 1.35rem;
}

.bottom-nav-label{
  font-size: 0.68rem;
  letter-spacing: 0.02em;
}

/* ========================================
   MOBILE RESPONSIVE TABLES
   ======================================== */

.table-mobile-wrapper{
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;

  margin: 0 calc(var(--space-4) * -1);
  padding: 0 var(--space-4);

  border-radius: var(--radius-lg);
}

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

/* ========================================
   MOBILE CARDS & STATS
   ======================================== */

.stat-card-mobile{
  padding: var(--space-4);
  min-height: auto;
}

.stat-card-mobile .stat-card-value{
  font-size: 1.75rem;
}

/* ========================================
   MOBILE FORMS
   ======================================== */

.form-mobile-spacing{
  gap: var(--space-4);
}

.form-mobile-spacing .form-group{
  margin-bottom: var(--space-4);
}

.form-mobile-spacing input,
.form-mobile-spacing select,
.form-mobile-spacing textarea{
  padding: var(--space-3) var(--space-4);
  border-radius: 14px;
}

.form-mobile-spacing .btn{
  padding: 14px 16px;
  font-size: 1rem;
  min-height: 48px;
  border-radius: 14px;
}

/* ========================================
   MOBILE MODALS
   ======================================== */

.modal-mobile{
  align-items: flex-end;
}

.modal-mobile .modal-content{
  width: 100%;
  max-width: 100%;
  margin: 0;

  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  max-height: 90vh;
  animation: slideUp 0.25s ease-out;
}

@keyframes slideUp{
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* ========================================
   MOBILE ALERTS & NOTIFICATIONS
   ======================================== */

.alert-mobile{
  margin: 0 calc(var(--space-4) * -1);
  border-radius: 0;
  margin-bottom: var(--space-4);
}

/* ========================================
   MOBILE UTILITIES
   ======================================== */

.hide-mobile{ display: block; }
.show-mobile{ display: none; }
.mobile-only{ display: none; }
.desktop-only{ display: block; }

/* ========================================
   DESKTOP/TABLET: ESCONDE HEADER E BOTTOM NAV
   ======================================== */

@media (min-width: 769px){
  .dashboard .mobile-header,
  .mobile-header{
    display: none !important;
  }

  .bottom-nav{
    display: none !important;
  }
}

/* ========================================
   MOBILE RESPONSIVE (max-width: 768px)
   ======================================== */

@media (max-width: 768px){
  .dashboard .mobile-header,
  .mobile-header{
    display: flex !important;
  }

  .bottom-nav{
    display: block !important;
  }

  .hide-mobile{ display: none !important; }
  .show-mobile{ display: block; }
  .mobile-only{ display: block; }
  .desktop-only{ display: none !important; }

  .sidebar{
    transform: translateX(-100%);
    width: 280px;
    z-index: 1000;
  }

  .sidebar.active{
    transform: translateX(0);
  }

  .main-content{
    margin-left: 0;

    /* ✅ agora o padding-top acompanha a nova altura real do header */
    padding:
      calc(var(--m-header-h) + var(--m-safe-top) + var(--space-4))
      var(--space-4)
      calc(var(--m-bottomnav-h) + var(--m-safe-bottom) + var(--space-4))
      var(--space-4);

    min-height: 100vh;
  }

  .top-bar{
    display: none;
  }

  .stats-grid{
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .card{
    border-radius: var(--radius-lg);
  }

  .form-grid,
  .form-row{
    grid-template-columns: 1fr;
  }

  .btn-group{
    flex-direction: column;
    width: 100%;
  }

  .btn-group .btn{
    width: 100%;
  }

  .table-container table{
    display: none;
  }

  .table-mobile-cards{
    display: block;
  }

  .modal{
    align-items: flex-end;
  }

  .modal-content{
    width: 100%;
    max-width: 100%;
    margin: 0;

    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 90vh;
  }

  .login-page{
    padding: var(--space-4);
  }

  .login-box{
    padding: var(--space-6);
  }

  .login-header h1{
    font-size: 1.5rem;
  }
}

/* ========================================
   SMALL MOBILE (max-width: 480px)
   ======================================== */

@media (max-width: 480px){
  .main-content{
    padding:
      calc(var(--m-header-h) + var(--m-safe-top) + var(--space-3))
      var(--space-3)
      calc(var(--m-bottomnav-h) + var(--m-safe-bottom) + var(--space-3))
      var(--space-3);
  }

  .stat-card-value{
    font-size: 1.5rem;
  }

  .btn{
    padding: 12px 14px;
    font-size: 0.9rem;
  }

  .card-header h3{
    font-size: 1rem;
  }

  .bottom-nav-label{
    font-size: 0.64rem;
  }

  .bottom-nav-icon{
    font-size: 1.2rem;
  }
}

/* ========================================
   PWA & STANDALONE MODE
   ======================================== */

@media (display-mode: standalone){
  .mobile-header{
    padding-top: calc(var(--space-2) + var(--m-safe-top));
  }

  .bottom-nav{
    padding-bottom: var(--m-safe-bottom);
  }
}

/* ========================================
   LANDSCAPE MOBILE
   ======================================== */

@media (max-width: 768px) and (orientation: landscape){
  .bottom-nav{
    display: none !important;
  }

  .main-content{
    padding-bottom: var(--space-4);
  }

  .mobile-header{
    height: calc(50px + var(--m-safe-top));
  }

  .main-content{
    padding-top: calc(50px + var(--m-safe-top) + var(--space-4));
  }
}
