/* ==========================================================================
   LAYOUT CSS — SHELL, SIDEBAR, TOPBAR, MOBILE DRAWER, RESPONSIVE
   Multi-Tenant 2.0 Responsive Engine
   ========================================================================== */

#app { display: flex; min-height: 100vh; position: relative; }

/* Mobile Top Header (Visivel apenas <= 900px) */
.mobile-header-bar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 60px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--card-border);
  padding: 0 16px;
  align-items: center;
  justify-content: space-between;
  z-index: 40;
  backdrop-filter: blur(12px);
}

.mobile-menu-btn {
  background: rgba(197, 160, 89, 0.1);
  border: 1px solid var(--card-border);
  color: var(--gold-primary);
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}
.mobile-menu-btn:active {
  transform: scale(0.95);
  background: var(--gold-subtle);
}

.mobile-brand-wrap {
  display: flex; align-items: center; gap: 8px;
}
.mobile-brand-title {
  font-size: 14px; font-weight: 800; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 170px;
}

select#mobileTenantSelect {
  background: rgba(0, 0, 0, 0.5);
  color: var(--gold-light);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 700;
  padding: 6px 10px;
  outline: none;
  max-width: 130px;
}

/* Sidebar Backdrop */
.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 45;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* Sidebar Universal */
aside.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 50;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.brand-logo {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  background: var(--gold-gradient);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 15px var(--gold-glow);
  flex-shrink: 0;
}

.brand-text h1 {
  font-size: 15px; font-weight: 800; letter-spacing: -0.5px;
  background: var(--gold-gradient);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.brand-text span {
  font-size: 10.5px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1px;
}

.sidebar-nav {
  flex: 1; padding: 16px 12px;
  overflow-y: auto; display: flex; flex-direction: column; gap: 3px;
}

.nav-section-title {
  font-size: 9.5px; text-transform: uppercase; color: var(--gold-primary);
  letter-spacing: 1.3px; font-weight: 800; padding: 14px 10px 4px;
}

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--radius-md);
  color: var(--text-secondary); text-decoration: none;
  font-size: 13px; font-weight: 600; transition: var(--transition);
  position: relative;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary); transform: translateX(3px);
}

.nav-item.active {
  background: rgba(197, 160, 89, 0.12);
  color: var(--gold-light); font-weight: 800;
  border: 1px solid var(--card-border);
}

.nav-item.active::before {
  content: ''; position: absolute;
  left: 0; top: 20%; bottom: 20%; width: 3px;
  background: var(--gold-gradient); border-radius: 0 4px 4px 0;
}

.nav-icon { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-footer {
  padding: 12px 14px; border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.25);
}

.master-switcher-wrapper {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--card-border); padding: 8px 10px;
  border-radius: var(--radius-md); transition: var(--transition);
}

.master-switcher-wrapper:hover { border-color: var(--card-border-hover); }

.master-switcher-label {
  font-size: 10px; font-weight: 800; color: var(--gold-light);
  text-transform: uppercase; letter-spacing: 0.5px;
  display: flex; align-items: center; gap: 6px;
}

select#tenantSelect {
  width: 100%; background: rgba(0, 0, 0, 0.4); color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.08); border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600; cursor: pointer;
  outline: none; padding: 6px 8px; transition: var(--transition);
}

select#tenantSelect:hover, select#tenantSelect:focus {
  border-color: var(--gold-primary);
}

select#tenantSelect option { background: #151720; color: #ffffff; padding: 8px; }

/* Main Content Area */
main.main-viewport {
  margin-left: var(--sidebar-width);
  flex: 1; display: flex; flex-direction: column; min-height: 100vh;
  width: calc(100% - var(--sidebar-width));
}

.content-body {
  padding: 28px;
  flex: 1;
  max-width: 1600px;
  width: 100%;
  box-sizing: border-box;
}

/* Mobile Bottom Navigation (Visivel apenas <= 900px) */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 62px;
  background: var(--bg-surface);
  border-top: 1px solid var(--card-border);
  z-index: 40;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.mobile-bottom-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 10px;
  font-weight: 700;
  transition: var(--transition);
}

.mobile-bottom-item.active {
  color: var(--gold-primary);
}

.mobile-bottom-item i {
  width: 18px; height: 18px;
}

/* Badges e Status */
.status-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  border-radius: 20px; font-size: 11px; font-weight: 600;
  background: rgba(16, 185, 129, 0.1); color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.pulse-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--success); box-shadow: 0 0 8px var(--success);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Date Pills Universal */
.date-pill {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}
.date-pill:hover { color: var(--text-primary); }
.date-pill.active {
  background: var(--gold-gradient);
  color: #08080a;
  box-shadow: 0 2px 8px var(--gold-glow);
}

/* Responsividade Mobile e Tablet */
@media (max-width: 900px) {
  .mobile-header-bar { display: flex; }
  .mobile-bottom-nav { display: flex; }

  aside.sidebar {
    width: 290px;
    max-width: 85vw;
    transform: translateX(-100%);
    box-shadow: none;
  }
  aside.sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.9);
  }

  main.main-viewport {
    margin-left: 0 !important;
    width: 100% !important;
    padding-top: 60px;
    padding-bottom: 66px;
  }

  .content-body {
    padding: 16px 14px;
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr !important;
  }
  .content-body {
    padding: 12px 10px;
  }
}
