/* Spazio Hub — Design System & CSS Principal
   Paleta derivada da logo: roxo (#8B1CF5) → laranja (#FF5A00) sobre azul-marinho (#0C0A2A). */
:root {
  /* Azul-marinho do texto da logo */
  --primary-900: #0c0a2a;
  --primary-800: #1b1840;
  --primary-700: #2e2a5c;
  --primary-600: #4a4675;
  /* Roxo da marca (cor principal de ação) */
  --accent-700: #6a0dd8;
  --accent-600: #8b1cf5;
  --accent-500: #a24bfa;
  --accent-400: #c08bff;
  --accent-100: #ede0ff;
  --accent-50: #f6f0ff;
  /* Laranja da marca (destaques) */
  --brand-orange-600: #ff5a00;
  --brand-orange-500: #ff7a00;
  --brand-orange-400: #ff9a1a;
  --brand-orange-50: #fff3e8;
  --brand-gradient: linear-gradient(135deg, #8b1cf5 0%, #c2189e 50%, #ff5a00 100%);
  --brand-gradient-soft: linear-gradient(135deg, #8b1cf5 0%, #6a0dd8 100%);
  --success-600: #059669;
  --success-100: #d1fae5;
  --warning-600: #d97706;
  --warning-100: #fef3c7;
  --danger-600: #dc2626;
  --danger-100: #fee2e2;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--gray-50);
  color: var(--primary-900);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
}

/* Layout Geral */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Desktop */
.sidebar {
  width: 260px;
  background-color: var(--primary-900);
  color: #fff;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  transition: all 0.25s ease;
  z-index: 40;
}

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

.sidebar-logo {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.sidebar-logo img {
  display: block;
  height: 38px;
  width: auto;
}

.sidebar-logo .badge-logo {
  background: var(--brand-gradient);
  color: #fff;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 800;
}

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

.nav-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray-400);
  padding: 12px 10px 4px;
  font-weight: 600;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--gray-300);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-link.active {
  background: var(--brand-gradient-soft);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--brand-orange-500), 0 2px 6px rgba(139, 28, 245, 0.35);
}

.nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Área Principal */
.main-wrapper {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background-color: var(--gray-50);
}

/* Topbar Header */
.topbar {
  height: 64px;
  background-color: #fff;
  border-bottom: 1px solid var(--gray-200);
  background-image: var(--brand-gradient);
  background-size: 100% 2px;
  background-repeat: no-repeat;
  background-position: bottom;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.condo-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--gray-100);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  font-size: 0.875rem;
}

.condo-selector select {
  background: transparent;
  border: none;
  font-weight: 600;
  color: var(--primary-900);
  outline: none;
  cursor: pointer;
  max-width: 200px;
}

.user-profile-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--primary-800);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.user-profile-btn:hover {
  background-color: var(--gray-100);
}

.avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
}

/* Conteúdo */
.content-area {
  padding: 24px;
  flex-grow: 1;
}

/* Mobile Bottom Navigation */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #fff;
  border-top: 1px solid var(--gray-200);
  height: 60px;
  z-index: 50;
  justify-content: space-around;
  align-items: center;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--gray-500);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 500;
  gap: 3px;
  flex: 1;
  height: 100%;
}

.mobile-nav-item.active {
  color: var(--accent-600);
}

.mobile-nav-item svg {
  width: 20px;
  height: 20px;
}

/* Componentes de UI: Cards, Grids, Tabelas e Botões */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.card {
  background: #fff;
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-900);
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-top: 2px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--gray-100);
  color: var(--accent-600);
  flex-shrink: 0;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary-900);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--gray-500);
  font-weight: 500;
}

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--brand-gradient-soft);
  background-color: var(--accent-600);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-700);
}

.btn-secondary {
  background-color: var(--gray-100);
  color: var(--primary-800);
  border: 1px solid var(--gray-300);
}
.btn-secondary:hover {
  background-color: var(--gray-200);
}

.btn-danger {
  background-color: var(--danger-600);
  color: #fff;
}
.btn-danger:hover {
  background-color: #b91c1c;
}

.btn-success {
  background-color: var(--success-600);
  color: #fff;
}
.btn-success:hover {
  background-color: #047857;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.8rem;
}

/* Badges e Status */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success {
  background-color: var(--success-100);
  color: var(--success-600);
}
.badge-warning {
  background-color: var(--warning-100);
  color: var(--warning-600);
}
.badge-danger {
  background-color: var(--danger-100);
  color: var(--danger-600);
}
.badge-info {
  background-color: var(--accent-50);
  color: var(--accent-700);
}

/* Tabelas */
.table-responsive {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
  background: #fff;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.data-table th {
  background-color: var(--gray-50);
  padding: 12px 16px;
  font-weight: 600;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.5px;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
  color: var(--primary-800);
}

.data-table tbody tr:hover {
  background-color: #f8fafc;
}

/* Formulários */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--primary-800);
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--primary-900);
  background-color: #fff;
  outline: none;
  transition: border-color 0.15s;
}

.form-control:focus {
  border-color: var(--accent-600);
  box-shadow: 0 0 0 3px rgba(139, 28, 245, 0.18);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 24px;
}
.empty-state-icon {
  width: 64px;
  height: 64px;
  color: var(--gray-400);
  margin: 0 auto 16px;
}
.empty-state-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary-800);
  margin-bottom: 6px;
}
.empty-state-desc {
  font-size: 0.875rem;
  color: var(--gray-500);
  max-width: 420px;
  margin: 0 auto 20px;
}

/* Toasts / Mensagens */
.messages-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
}

.toast {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: slideIn 0.25s ease forwards;
}

.toast-success { background-color: var(--success-600); }
.toast-error { background-color: var(--danger-600); }
.toast-warning { background-color: var(--warning-600); }
.toast-info { background-color: var(--accent-600); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Responsividade Mobile */
@media (max-width: 768px) {
  .sidebar {
    display: flex;
  }
  .mobile-nav {
    display: flex;
  }
  .content-area {
    padding: 16px;
    padding-bottom: 80px;
  }
  .topbar {
    padding: 0 16px;
  }
}


/* Spazio Hub: menu completo em dispositivos móveis */
.mobile-menu-toggle,
.mobile-menu-overlay {
  display: none;
}

@media (max-width: 768px) {
  .topbar-left {
    min-width: 0;
    gap: 10px;
  }

  .mobile-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    padding: 8px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--primary-900);
    cursor: pointer;
  }

  .sidebar {
    display: flex;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(300px, 86vw);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    z-index: 60;
    box-shadow: 8px 0 28px rgba(0, 0, 0, 0.18);
  }

  .sidebar-nav {
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: 24px;
  }

  .mobile-menu-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(15, 23, 42, 0.48);
    z-index: 59;
    cursor: pointer;
  }

  body.mobile-menu-open {
    overflow: hidden;
  }

  body.mobile-menu-open .sidebar {
    transform: translateX(0);
  }

  body.mobile-menu-open .mobile-menu-overlay {
    display: block;
  }

  .topbar {
    gap: 8px;
  }

  .condo-selector select {
    max-width: 130px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }
}


/* Ajuste do cabeçalho e perfil no mobile */
.sidebar-user-footer {
  display: none;
}

@media (max-width: 768px) {
  .topbar {
    min-width: 0;
    height: 64px;
    padding: 0 10px;
    justify-content: flex-start;
  }

  .topbar-left {
    flex: 1;
    min-width: 0;
    gap: 8px;
  }

  .topbar-left .condo-selector {
    flex: 1;
    min-width: 0;
    max-width: none;
    overflow: hidden;
  }

  .topbar-left .condo-selector select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-left .badge {
    flex-shrink: 0;
  }

  .topbar-right {
    display: none !important;
  }

  .sidebar {
    flex-direction: column;
  }

  .sidebar-nav {
    flex: 1;
    min-height: 0;
    width: 100%;
  }

  .sidebar-user-footer {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    flex-shrink: 0;
    padding: 14px 16px calc(18px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--gray-200);
    background: #fff;
  }

  .sidebar-user-footer .user-profile-btn {
    min-width: 0;
    padding: 8px 4px;
  }

  .sidebar-user-footer .sidebar-user-name {
    overflow-wrap: anywhere;
    font-size: 0.9rem;
    font-weight: 600;
  }

  .sidebar-logout-form {
    display: block;
    width: 100%;
  }

  .sidebar-logout-form button {
    width: 100%;
    min-height: 40px;
  }
}


/* Mobile: cabeçalho somente com menu e condomínio */
@media (max-width: 768px) {
  .topbar .topbar-right {
    display: none !important;
  }

  .topbar-left > .badge,
  .topbar-left > .badge-info {
    display: none !important;
  }

  .topbar-left {
    flex: 1;
    width: 100%;
    min-width: 0;
  }

  .topbar-left .condo-selector {
    flex: 1;
    min-width: 0;
    max-width: none;
  }

  .topbar-left .condo-selector select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Correção definitiva: cabeçalho mobile sem perfil ou papel */
@media screen and (max-width: 768px) {
  header.topbar .topbar-right {
    display: none !important;
    visibility: hidden !important;
  }

  header.topbar .topbar-left > span.badge,
  header.topbar .topbar-left > span.badge-info {
    display: none !important;
  }

  header.topbar .topbar-left {
    display: flex;
    align-items: center;
    width: 100%;
    min-width: 0;
  }

  header.topbar .topbar-left .condo-selector {
    flex: 1;
    min-width: 0;
  }
}

/* Ajuste: manter o seletor de condomínio visível no mobile */
@media screen and (max-width: 768px) {
  header.topbar {
    display: flex !important;
    justify-content: flex-start !important;
    overflow: visible;
  }

  header.topbar .topbar-left {
    display: flex !important;
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
    overflow: visible;
  }

  header.topbar .topbar-left .condo-selector {
    display: flex !important;
    flex: 1 1 0 !important;
    width: 0;
    min-width: 0 !important;
    max-width: none !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  header.topbar .topbar-left .condo-selector select {
    display: block !important;
    flex: 1;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
}


/* Rodapé de créditos (Kirev One) */
.creditos-kirev {
  font-size: 0.75rem;
  color: var(--gray-400);
  text-align: center;
  padding: 16px 12px;
}

.creditos-kirev a {
  color: inherit;
  text-decoration: none;
  font-weight: 700;
}

.creditos-kirev .kirev { color: var(--primary-900); }
.creditos-kirev .one { color: var(--brand-orange-500); }

.sidebar .creditos-kirev {
  padding: 10px 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar .creditos-kirev .kirev { color: #fff; }

.content-area + .creditos-kirev { padding-bottom: 24px; }

@media (max-width: 768px) {
  .content-area + .creditos-kirev { padding-bottom: 80px; }
}
