/* layout.css - Layout estrutural com sidebar lateral colapsável */

/* ===== ESTRUTURA BASE (FLEX - SEM HACKS) ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
}

.sidebar {
  width: 70px;
  min-width: 70px;
  flex-shrink: 0;
  transition: width 0.25s ease, min-width 0.25s ease;
  background: #fff;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ===== CONTAINERS DE CONTEÚDO ===== */
.layout-container {
  width: 100%;
  padding: 24px 32px;
}

@media (max-width: 768px) {
  .layout-container {
    padding: 12px 16px;
    padding-top: 56px;
  }
}

.layout-full {
  width: 100%;
  padding: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ===== SIDEBAR INTERNO ===== */
.sidebar__inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 70px;
}

.sidebar__logo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  box-sizing: border-box;
  padding: 14px 0;
  border-bottom: 1px solid #e5e7eb;
  overflow: hidden;
}

/* Logo/tema: ver theme-toggle.css (.sidebar__logo, .sidebar__theme) */

.sidebar__nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.sidebar__nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: #64748b;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
  min-height: 48px;
}

.sidebar__nav-link:hover {
  color: #10b981;
  background: #f0fdf4;
}

.sidebar__nav-link.active {
  color: #10b981;
  background: #f0fdf4;
  font-weight: 500;
}

.sidebar__nav-link i,
.sidebar__nav-link svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.sidebar__nav-link span {
  white-space: nowrap;
  overflow: hidden;
  opacity: 0;
  width: 0;
  max-width: 0;
  transition: opacity 0.2s ease, width 0.2s ease, max-width 0.2s ease;
}

/* User e More: spans ocultos quando colapsada (desktop/tablet) */
@media (min-width: 769px) {
  .sidebar .vg-header__more-btn span {
    opacity: 0;
    width: 0;
    max-width: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.2s ease, width 0.2s ease, max-width 0.2s ease;
  }

  .sidebar .sidebar__user-name {
    opacity: 0;
    width: 0;
    max-width: 0;
    overflow: hidden;
    white-space: nowrap;
    font-size: 0;
  }
}

.sidebar__user {
  padding: 12px 16px;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
  font-size: 13px;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar__user-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.2s ease, width 0.2s ease, max-width 0.2s ease;
}

/* ===== RESPONSIVIDADE ===== */

/* Desktop e Tablet (>768px): sidebar compacta, hover expande */
@media (min-width: 769px) {
  .sidebar {
    width: 70px;
    min-width: 70px;
  }

  .sidebar .sidebar__nav-link {
    justify-content: center;
    padding: 12px;
  }


  .sidebar:hover {
    width: 240px;
    min-width: 240px;
  }

  .sidebar:hover .sidebar__inner {
    min-width: 240px;
  }

  .sidebar:hover .sidebar__nav-link {
    justify-content: flex-start;
    padding: 12px 16px;
  }

  .sidebar:hover .sidebar__nav-link span {
    opacity: 1;
    width: auto;
    max-width: 200px;
  }

  /* More btn e User - spans visíveis no hover */
  .sidebar:hover .vg-header__more-btn span {
    opacity: 1;
    width: auto;
    max-width: 120px;
  }

  .sidebar:hover .sidebar__user {
    justify-content: flex-start;
  }

  .sidebar:hover .sidebar__user-name {
    opacity: 1;
    width: auto;
    max-width: 120px;
    font-size: 13px;
  }
}

/* Tablet touch (769–1024px): labels sempre visíveis — sem depender de :hover */
@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar {
    width: 240px;
    min-width: 240px;
  }

  .sidebar .sidebar__inner {
    min-width: 240px;
  }

  .sidebar .sidebar__nav-link {
    justify-content: flex-start;
    padding: 12px 16px;
  }

  .sidebar .sidebar__nav-link span {
    opacity: 1;
    width: auto;
    max-width: 200px;
  }

  .sidebar .vg-header__more-btn span {
    opacity: 1;
    width: auto;
    max-width: 120px;
  }

  .sidebar .sidebar__user {
    justify-content: flex-start;
  }

  .sidebar .sidebar__user-name {
    opacity: 1;
    width: auto;
    max-width: 120px;
    font-size: 13px;
  }
}

/* Mobile (<768px): sidebar overlay, sem hover */
@media (max-width: 768px) {
  .sidebar-toggle-mobile {
    display: flex !important;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    width: 280px;
    max-width: 85vw;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  }

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

  .sidebar__inner {
    min-width: 280px;
    align-items: stretch;
  }

  .sidebar__nav-link span {
    opacity: 1;
    width: auto;
    max-width: none;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 199;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s, visibility 0.25s;
  }

  .sidebar-overlay.mobile-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
}

/* Toggle mobile: fixo no canto para abrir sidebar */
.sidebar-toggle-mobile {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 198;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  color: #334155;
  cursor: pointer;
  transition: background 0.2s;
}

.sidebar-toggle-mobile:hover {
  background: #f1f5f9;
}

.sidebar-toggle-mobile svg,
.sidebar-toggle-mobile i {
  width: 24px;
  height: 24px;
}

@media (min-width: 769px) {
  .sidebar-toggle-mobile {
    display: none !important;
  }
}


.sidebar__more {
  position: relative;
}

/* Dropdown "Mais" à direita do botão */
.sidebar__more .vg-header__more-dropdown {
  left: 100%;
  top: 0;
  margin-left: 4px;
}

.vg-header__more--open .vg-header__more-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Permitir overflow quando dropdown aberto (evita corte) */
.sidebar:has(.vg-header__more--open) {
  overflow: visible;
}

.app-layout:has(.vg-header__more--open) {
  overflow-x: visible;
}

/* Classe opcional para centralização controlada - aplicar manualmente onde necessário */
.page-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* ===== USERS PAGE - SaaS Profissional ===== */
.users-page-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  padding: 24px;
  overflow: hidden;
}

.users-page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e5e7eb;
}

.users-page-title {
  font-size: 24px;
  font-weight: 600;
  color: #111827;
  margin: 0 0 4px 0;
}

.users-page-subtitle {
  font-size: 14px;
  color: #6b7280;
  margin: 0 0 8px 0;
}

.users-count-badge {
  font-size: 13px;
  color: #9ca3af;
  margin: 0;
}

.users-header-actions {
  flex-shrink: 0;
}

/* Filtros em linha única */
.users-filters-row {
  margin-bottom: 20px;
}

.users-filters-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.users-search-wrap {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.users-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: #9ca3af;
  pointer-events: none;
}

.users-search-input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.users-search-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.users-filter-select {
  min-width: 140px;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font-size: 14px;
  background: white;
  transition: border-color 0.2s;
}

.users-filter-select:focus {
  outline: none;
  border-color: #3b82f6;
}

.users-clear-filters {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: #6b7280;
  font-size: 13px;
  cursor: pointer;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}

.users-clear-filters:hover {
  color: #374151;
  background: #f3f4f6;
}

/* Tabela */
.users-table-wrap {
  margin: 0;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
}

.users-table th,
.users-table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid #f3f4f6;
}

.users-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  background: #fafafa;
}

.users-table tbody tr:hover {
  background: #f9fafb;
}

/* Avatar com gradiente */
.user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
  color: white;
  font-size: 16px;
  font-weight: 600;
  flex-shrink: 0;
}

.user-name-cell {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-name-primary {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  display: block;
}

.user-name-email {
  font-size: 13px;
  color: #9ca3af;
  margin-top: 2px;
}

/* Badges função e status */
.badge-role-admin { background: #dbeafe; color: #1e40af; }
.badge-role-superadmin { background: #ede9fe; color: #5b21b6; }
.badge-role-client { background: #dcfce7; color: #166534; }
.badge-role-default { background: #f3f4f6; color: #4b5563; }

.badge-status-active { background: #dcfce7; color: #166534; }
.badge-status-inactive { background: #f3f4f6; color: #6b7280; }

.user-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
}

/* Menu de ações */
.users-actions-menu {
  position: relative;
  display: inline-block;
}

.users-actions-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: 8px;
  color: #6b7280;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.users-actions-trigger:hover {
  background: #f3f4f6;
  color: #374151;
}

.users-actions-dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 4px;
  min-width: 200px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  z-index: 50;
  padding: 4px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}

.users-actions-menu.is-open .users-actions-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.users-actions-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 13px;
  color: #374151;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s;
}

.users-actions-item:hover {
  background: #f3f4f6;
}

.users-actions-item.users-actions-danger:hover {
  background: #fef2f2;
  color: #dc2626;
}

.users-actions-item i {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Pagination */
.users-pagination-row {
  padding: 16px 0 0;
  border-top: 1px solid #e5e7eb;
  margin-top: 16px;
}

.users-pagination-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.users-pagination-btns {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.users-pagination-info {
  font-size: 13px;
  color: #6b7280;
}

/* Messages */
.users-message {
  padding: 12px 20px;
  margin: 16px 0 0;
  border-radius: 8px;
}

.users-message-loading {
  text-align: center;
  color: #2563eb;
}

.users-message-success {
  background: #dcfce7;
  border-left: 4px solid #16a34a;
  color: #166534;
}

.users-message-error {
  background: #fef2f2;
  border-left: 4px solid #dc2626;
  color: #991b1b;
}

@media (max-width: 768px) {
  .users-filters-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .users-search-wrap {
    min-width: 100%;
  }

  .users-filter-select {
    min-width: 100%;
  }
}
