/* ============================================================
   Niox UIKit — Dashboard Layout
   WordPress-style: sidebar (left) + topbar (top) + main (center)
   ============================================================ */

/* ── Shell ── */
.tf-dash {
  display: flex;
  min-height: 100vh;
  background: var(--dark);
  color: var(--text);
  font-family: var(--font-body);
}

/* ── Sidebar ── */
.tf-sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 200;
  transition: width var(--transition), transform var(--transition);
  overflow: hidden;
}

.tf-sidebar.collapsed {
  width: var(--sidebar-collapsed-w);
}

/* Sidebar brand */
.tf-sidebar__brand {
  padding: 0 var(--space-4);
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: .75rem;
  border-bottom: 1px solid var(--border-muted);
  text-decoration: none;
  flex-shrink: 0;
}

.tf-sidebar__brand-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
}

.tf-sidebar__brand-name {
  font-family: var(--font-head);
  font-size: .95rem;
  font-weight: 700;
  color: var(--gold-light);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition);
}

.tf-sidebar.collapsed .tf-sidebar__brand-name { opacity: 0; pointer-events: none; }

/* Sidebar nav */
.tf-sidebar__nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-3) 0;
  scrollbar-width: thin;
  scrollbar-color: var(--dark-4) transparent;
}

.tf-sidebar__nav::-webkit-scrollbar { width: 4px; }
.tf-sidebar__nav::-webkit-scrollbar-track { background: transparent; }
.tf-sidebar__nav::-webkit-scrollbar-thumb { background: var(--dark-4); border-radius: 2px; }

/* Nav group label */
.tf-nav-group-label {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: var(--space-3) var(--space-4) var(--space-2);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition);
}

.tf-sidebar.collapsed .tf-nav-group-label { opacity: 0; }

/* Nav item */
.tf-nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem var(--space-4);
  color: var(--text-muted);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  transition: all var(--transition-sm);
  cursor: pointer;
  border-left: 3px solid transparent;
  white-space: nowrap;
  overflow: hidden;
}

.tf-nav-item:hover {
  color: var(--text);
  background: rgba(255,255,255,0.04);
  border-left-color: var(--border-muted);
}

.tf-nav-item.active {
  color: var(--gold-light);
  background: var(--gold-subtle);
  border-left-color: var(--gold);
}

.tf-nav-item .icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tf-nav-item .label {
  transition: opacity var(--transition);
}

/* display:none (no solo opacity:0): si el label sigue en el flujo flex,
   su ancho descentra el icono con justify-content:center y lo saca del
   viewport (queda invisible, ver issue del sidebar colapsado). */
.tf-sidebar.collapsed .tf-nav-item .label { display: none; }
.tf-sidebar.collapsed .tf-nav-item { justify-content: center; padding: .6rem; }

.tf-nav-item .badge {
  margin-left: auto;
  transition: opacity var(--transition);
}
.tf-sidebar.collapsed .tf-nav-item .badge { display: none; }

/* Sidebar footer */
.tf-sidebar__footer {
  border-top: 1px solid var(--border-muted);
  padding: var(--space-3) 0;
  flex-shrink: 0;
}

/* ── Topbar ── */
.tf-topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-5);
  gap: var(--space-4);
  z-index: 100;
  transition: left var(--transition);
}

.tf-dash.sidebar-collapsed .tf-topbar {
  left: var(--sidebar-collapsed-w);
}

.tf-topbar__toggle {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  transition: all var(--transition-sm);
  flex-shrink: 0;
}
.tf-topbar__toggle:hover { background: var(--dark-4); color: var(--text); }

.tf-topbar__breadcrumb {
  flex: 1;
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .875rem;
  color: var(--text-muted);
  overflow: hidden;
}

.tf-topbar__breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--transition-sm);
}
.tf-topbar__breadcrumb a:hover { color: var(--gold-light); }
.tf-topbar__breadcrumb .sep { color: var(--text-dim); }
.tf-topbar__breadcrumb .current { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tf-topbar__right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* User avatar button */
.tf-user-btn {
  display: flex;
  align-items: center;
  gap: .6rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: .35rem .6rem;
  cursor: pointer;
  color: var(--text);
  transition: all var(--transition-sm);
  text-decoration: none;
}
.tf-user-btn:hover {
  background: var(--dark-4);
  border-color: var(--border-muted);
  color: var(--text);
}

.tf-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--dark-4);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: var(--gold-light);
  flex-shrink: 0;
  overflow: hidden;
}

.tf-avatar img { width: 100%; height: 100%; object-fit: cover; }

.tf-user-name {
  font-size: .8rem;
  font-weight: 600;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Dropdown */
.tf-dropdown {
  position: relative;
}

.tf-dropdown-menu {
  position: absolute;
  top: calc(100% + .5rem);
  right: 0;
  background: var(--dark-3);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  min-width: 180px;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  display: none;
  overflow: hidden;
}

.tf-dropdown.open .tf-dropdown-menu { display: block; animation: tf-fade-in .15s ease; }

.tf-dropdown-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem var(--space-4);
  color: var(--text-muted);
  font-size: .875rem;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-sm);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.tf-dropdown-item:hover { background: var(--dark-4); color: var(--text); }
.tf-dropdown-item.danger { color: var(--danger-light); }
.tf-dropdown-item.danger:hover { background: rgba(217, 80, 80, 0.08); color: var(--danger-light); }
.tf-dropdown-divider { border: none; border-top: 1px solid var(--border-muted); margin: .25rem 0; }

/* ── Main content area ── */
.tf-main {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  flex: 1;
  min-width: 0;
  transition: margin-left var(--transition);
  min-height: calc(100vh - var(--topbar-height));
}

.tf-dash.sidebar-collapsed .tf-main {
  margin-left: var(--sidebar-collapsed-w);
}

.tf-page {
  padding: var(--space-6);
  max-width: 1400px;
}

.tf-page-header {
  margin-bottom: var(--space-6);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.tf-page-title {
  font-family: var(--font-head);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 .25rem;
}

.tf-page-subtitle {
  font-size: .875rem;
  color: var(--text-muted);
  margin: 0;
}

.tf-page-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* ── Toolbar (above tables) ── */
.tf-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-muted);
  flex-wrap: wrap;
}

.tf-toolbar__left  { display: flex; align-items: center; gap: var(--space-3); flex: 1; }
.tf-toolbar__right { display: flex; align-items: center; gap: var(--space-3); flex-shrink: 0; }

/* ── Stats row ── */
.tf-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .tf-sidebar {
    transform: translateX(-100%);
  }
  .tf-sidebar.mobile-open {
    transform: translateX(0);
  }
  .tf-topbar {
    left: 0;
  }
  .tf-main {
    margin-left: 0;
  }
  .tf-page {
    padding: var(--space-4);
  }
}
