/* ============================================================
   components.css — Componentes reutilizáveis
   Sidebar, topbar, avatar, botões, cards, formulários,
   badges, progress bar, tabela, stat card.
   ============================================================ */

/* ── Botões ────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t);
  white-space: nowrap;
  font-family: inherit;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: var(--shadow-primary);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(108, 99, 255, 0.4);
  color: #fff;
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
}
.btn-accent:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}
.btn-ghost:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--primary);
}

.btn-full { width: 100%; justify-content: center; padding: 0.8rem; }
.btn-sm   { padding: 0.4rem 0.85rem; font-size: 0.82rem; }

/* ── Cards ─────────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  transition: border-color var(--t), box-shadow var(--t), transform var(--t);
}

.card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow);
}

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

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Badges ─────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.22rem 0.65rem;
  border-radius: 20px;
  font-size: 0.73rem;
  font-weight: 500;
}

.badge-primary { background: var(--primary-glow);           color: var(--primary-light); }
.badge-success { background: rgba(16, 185, 129, 0.13);      color: var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.13);      color: var(--warning); }
.badge-danger  { background: rgba(239, 68, 68, 0.13);       color: var(--danger); }
.badge-muted   { background: var(--border);                  color: var(--text-secondary); }

/* ── Progress bar ───────────────────────────────────────────── */

.progress-wrap { margin-top: 0.75rem; }

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 3px;
  transition: width 0.7s ease;
}

/* ── Formulários ────────────────────────────────────────────── */

.form-group { margin-bottom: 1.25rem; }

.form-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.form-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.form-icon {
  position: absolute;
  left: 0.85rem;
  color: var(--text-muted);
  pointer-events: none;
  flex-shrink: 0;
}

.form-input {
  width: 100%;
  padding: 0.75rem 0.85rem 0.75rem 2.6rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--t), box-shadow var(--t);
}

.form-input::placeholder { color: var(--text-muted); }

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.toggle-pwd {
  position: absolute;
  right: 0.85rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  transition: color var(--t);
  line-height: 0;
}
.toggle-pwd:hover { color: var(--text-primary); }

/* ── Sidebar ─────────────────────────────────────────────────── */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--t-slow);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.1rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  flex-shrink: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.78rem;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: -0.5px;
}

.sidebar-brand-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem;
}

.nav-section-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  padding: 0.9rem 0.5rem 0.35rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.62rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
  margin-bottom: 2px;
}

.nav-item svg { flex-shrink: 0; }

.nav-item:hover {
  background: var(--primary-glow);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--primary-glow);
  color: var(--primary-light);
  border-left: 3px solid var(--primary);
  padding-left: calc(0.75rem - 3px);
}

.nav-item.nav-logout { color: var(--danger); }
.nav-item.nav-logout:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

/* ── Topbar ──────────────────────────────────────────────────── */

.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 90;
}

.topbar-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ── Avatar + Dropdown ───────────────────────────────────────── */

.avatar-wrap { position: relative; }

.avatar-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.8rem 0.4rem 0.4rem;
  cursor: pointer;
  transition: border-color var(--t);
  color: var(--text-primary);
}
.avatar-btn:hover { border-color: var(--primary); }

.avatar-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.82rem;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar-name {
  font-size: 0.84rem;
  font-weight: 500;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar-chevron {
  color: var(--text-muted);
  transition: transform var(--t);
}
.avatar-wrap.open .avatar-chevron { transform: rotate(180deg); }

.avatar-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  min-width: 185px;
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 200;
}
.avatar-wrap.open .avatar-dropdown { display: block; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 1rem;
  color: var(--text-secondary);
  font-size: 0.86rem;
  cursor: pointer;
  transition: background var(--t);
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  font-family: inherit;
}
.dropdown-item:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 0.2rem 0;
}

/* ── Layout de app (páginas internas) ───────────────────────── */

.app-layout {
  margin-left: var(--sidebar-w);
  padding-top: var(--topbar-h);
  min-height: 100vh;
}

.page-content {
  padding: 2rem 1.75rem;
  max-width: 1280px;
}

/* ── Seções com troca por JS ─────────────────────────────────── */

.section         { display: none; }
.section.active  { display: block; }

.section-title {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.section-subtitle {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-bottom: 1.75rem;
}

/* ── Grids ───────────────────────────────────────────────────── */

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 1.25rem;
}

/* ── Tabela ──────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }

thead tr { background: var(--bg-surface); border-bottom: 1px solid var(--border); }

th {
  padding: 0.85rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

td {
  padding: 0.9rem 1rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-card-hover); }

/* ── Status dot (online/offline) ─────────────────────────────── */

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
}
.status-dot::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  display: block;
  flex-shrink: 0;
}
.status-dot.online  { color: var(--success); }
.status-dot.online::before  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { color: var(--text-muted); }

/* ── Stat card ───────────────────────────────────────────────── */

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  transition: border-color var(--t), transform var(--t);
}
.stat-card:hover { border-color: var(--border-light); transform: translateY(-2px); }

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.2rem;
}

.stat-icon.purple { background: var(--primary-glow);            color: var(--primary-light); }
.stat-icon.blue   { background: var(--accent-glow);             color: var(--accent); }
.stat-icon.green  { background: rgba(16, 185, 129, 0.12);       color: var(--success); }
.stat-icon.yellow { background: rgba(245, 158, 11, 0.12);       color: var(--warning); }

.stat-value {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.stat-label {
  font-size: 0.81rem;
  color: var(--text-secondary);
}

/* ── Botão hamburguer (mobile) ───────────────────────────────── */

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.3rem;
  line-height: 0;
}

/* ── Overlay mobile ──────────────────────────────────────────── */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ── Responsivo ──────────────────────────────────────────────── */

@media (max-width: 768px) {
  .menu-toggle { display: flex; }

  .sidebar { transform: translateX(-100%); }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 40px rgba(0, 0, 0, 0.7);
  }

  .app-layout { margin-left: 0; }
  .topbar     { left: 0; }

  .grid-3, .grid-4 { grid-template-columns: 1fr; }

  .page-content { padding: 1.25rem 1rem; }

  .avatar-name { display: none; }
}
