/* Оболочка приложения — только после авторизации */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  grid-template-areas:
    "sidebar header"
    "sidebar main";
  min-height: 100vh;
}

.app-sidebar {
  grid-area: sidebar;
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.45), rgba(15, 23, 42, 0.8));
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem;
  min-height: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.75rem 1.25rem;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}

.sidebar-brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background var(--transition), color var(--transition), transform var(--transition);
}

.sidebar-link:hover {
  background: var(--surface-hover);
  color: var(--text);
  text-decoration: none;
  transform: translateX(2px);
}

.sidebar-link.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.22), rgba(59, 130, 246, 0.15));
  color: #c7d2fe;
  font-weight: 500;
  border: 1px solid rgba(99, 102, 241, 0.35);
}

.sidebar-link .icon {
  width: 1.25rem;
  text-align: center;
  opacity: 0.85;
}

.sidebar-status {
  margin-top: auto;
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.55);
}

.sidebar-status-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.sidebar-status-text {
  font-size: 0.82rem;
  font-weight: 600;
}

.sidebar-status-text.is-on {
  color: #86efac;
}

.sidebar-status-text.is-off {
  color: var(--text-muted);
}

.sidebar-status-text.is-warn {
  color: #fcd34d;
}

.sidebar-status-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 0.2rem;
}

.sidebar-status-endpoint {
  display: block;
  font-size: 0.78rem;
  color: #cbd5e1;
  word-break: break-all;
  user-select: all;
}

.sidebar-section {
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.sidebar-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 0 0.75rem 0.5rem;
}

.sidebar-link.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.app-header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.worker-status-badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem 0.25rem 0.4rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.worker-status-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748b;
}

.worker-status-badge.worker-on {
  color: var(--success, #22c55e);
  border-color: currentColor;
}

.worker-status-badge.worker-on::before {
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.75);
}

.worker-status-badge.worker-off {
  color: var(--text-muted);
}

.header-username {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.app-main {
  grid-area: main;
  padding: 1.5rem;
  overflow: auto;
}

@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
    grid-template-areas:
      "header"
      "sidebar"
      "main";
  }

  .app-sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0.5rem;
  }

  .sidebar-brand {
    display: none;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .sidebar-section {
    display: none;
  }
}
