/* NF Sistema - Global Layout & Reset */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  transition: background-color var(--transition), color var(--transition);
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
  font-family: inherit;
}

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

/* APP SHELL */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR */

.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  border-right: 1px solid #1f2937;
  box-shadow: 6px 0 18px rgba(0, 0, 0, 0.22);
  position: relative;
  z-index: 40;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  padding: 8px 10px;
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  color: white;
}

.sidebar-title {
  display: flex;
  flex-direction: column;
}

.sidebar-title span:first-child {
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9ca3af;
}

.sidebar-title span:last-child {
  font-weight: 600;
}

.sidebar-nav {
  flex: 1;
}

.sidebar-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: #6b7280;
  padding: 0 10px;
  margin: 12px 0 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  margin: 2px 0;
  color: #cbd5e1;
  font-size: 14px;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  border: 1px solid transparent;
  cursor: pointer;
}

.nav-item span.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 24px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 12px;
  font-weight: 700;
  color: inherit;
  letter-spacing: 0.05em;
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.06);
  color: #f9fafb;
  border-color: rgba(255, 255, 255, 0.08);
}

.nav-item.active .icon {
  background: rgba(255, 255, 255, 0.12);
}

.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: #e5e7eb;
  border-color: rgba(255, 255, 255, 0.08);
}

.sidebar-footer {
  padding: 12px 10px 4px;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: #6b7280;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.8);
  padding: 8px 11px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.theme-toggle button {
  border: none;
  background: transparent;
  color: #e5e7eb;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.user-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.user-tag {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: #6b7280;
}

.btn-logout {
  border-radius: 999px;
  border: 1px solid rgba(239, 68, 68, 0.5);
  background: rgba(127, 29, 29, 0.3);
  padding: 4px 9px;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
  color: #fecaca;
  transition: background var(--transition), border-color var(--transition);
}

.btn-logout:hover {
  background: rgba(127, 29, 29, 0.5);
  border-color: rgba(239, 68, 68, 0.8);
}

/* MAIN & TOPBAR */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 100%;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: color-mix(in srgb, var(--bg) 80%, transparent 20%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
}

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

.mobile-menu-btn {
  display: none;
  border: none;
  background: var(--bg-elevated);
  border-radius: 999px;
  padding: 6px 9px;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
}

.topbar-title {
  font-weight: 600;
  font-size: 15px;
}

.topbar-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

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

.company-switcher {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  column-gap: 8px;
}

.company-switcher label {
  grid-column: 1;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.company-switcher select {
  grid-column: 1;
  min-width: 210px;
  max-width: 300px;
  padding: 5px 28px 5px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text);
  font-size: 12px;
}

.company-switcher span {
  grid-column: 2;
  grid-row: 1 / span 2;
  padding: 4px 7px;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.content {
  padding: 16px 18px 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
}

/* Mobile sidebar */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 30;
  display: none;
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 50;
    max-height: 100vh;
    overflow-y: auto;
  }

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

  .sidebar-backdrop.show {
    display: block;
  }

  .mobile-menu-btn {
    display: inline-flex;
  }

  .company-switcher select {
    min-width: 130px;
    max-width: 180px;
  }

  .company-switcher label,
  .topbar-right > .badge {
    display: none;
  }
}
