/* ============================================================
   LAYOUT.CSS - Header, Navigation, Page Layout
   ============================================================ */

/* ========== MAIN SHELL ==========
 * `.shell` is a horizontal centering container only. It is used BOTH in
 * `#app-nav` (wrapping the sticky <header>) and inside each page under
 * `#app-content`. Previously it also declared `min-height: 100vh` + flex,
 * which caused the nav's shell to take up the full viewport height with
 * nothing but the 70px header visible — pushing page content below the fold
 * and creating a huge empty area at the top of every page.
 *
 * The full-height / sticky-footer behaviour is now delegated to <body>
 * (see base.css) so that the footer still sits at the bottom on short pages
 * without inflating the shell.
 */
.shell {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 16px;
}

#app-content {
  flex: 1;
  padding: var(--spacing-lg) 0;
  min-width: 0;
}

/* ========== HEADER ========== */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  padding: var(--spacing-md) 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
  transition: border-color var(--transition-base);
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  flex-shrink: 0;
}

.logo-icon {
  font-size: 28px;
}

.logo:hover {
  color: var(--accent2);
}

/* ========== NAVIGATION ========== */
nav {
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
  flex-wrap: wrap;
  flex: 1;
  justify-content: center;
}

nav a, nav button {
  padding: 8px 16px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--font-sans);
}

nav a:hover, nav button:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--accent);
  color: var(--text);
}

nav a.active, nav button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

nav a.active:hover {
  opacity: 0.9;
}

/* ========== HEADER ACTIONS ========== */
.header-actions {
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
}

#conn-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: 4px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  transition: all var(--transition-base);
}

#conn-badge.ok {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--green);
}

#conn-badge.ko {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--red);
}

#conn-badge.wait {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--yellow);
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

.dot.pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ========== FOOTER ========== */
footer {
  border-top: 1px solid var(--border);
  padding: var(--spacing-lg) 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-top: auto;
  transition: border-color var(--transition-base);
}

footer a {
  color: var(--accent);
}

/* ========== PAGE SECTION ========== */
.page-section {
  margin-bottom: var(--spacing-xl);
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
  flex-wrap: wrap;
}

.page-header h1 {
  margin: 0;
  flex: 1;
}

.page-actions {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

/* ========== GRID LAYOUTS ========== */
.grid {
  display: grid;
  gap: var(--spacing-md);
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.grid-auto {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

/* ========== MAIN CONTENT WRAPPER ========== */
.content-wrapper {
  display: flex;
  gap: var(--spacing-lg);
}

.main-content {
  flex: 1;
  min-width: 0;
}

.sidebar {
  width: 280px;
  flex-shrink: 0;
}

/* ========== CONTAINER ========== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

.container-fluid {
  width: 100%;
  padding: 0 var(--spacing-md);
}

/* ========== RESPONSIVE GRID ========== */
@media (max-width: 1200px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .shell {
    padding: 0 8px;
  }

  header {
    padding: 12px 0;
    position: relative;
  }

  nav {
    flex-basis: 100%;
    order: 3;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  nav a, nav button {
    font-size: 12px;
    padding: 6px 12px;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .page-header h1 {
    margin-bottom: 12px;
  }

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

  .grid-auto {
    grid-template-columns: 1fr;
  }

  .content-wrapper {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
  }

  #conn-badge {
    font-size: 10px;
    padding: 3px 8px;
  }

  .dot {
    width: 5px;
    height: 5px;
  }
}

@media (max-width: 480px) {
  .shell {
    padding: 0 4px;
  }

  header {
    gap: 8px;
  }

  nav {
    gap: 4px;
  }

  nav a, nav button {
    font-size: 11px;
    padding: 4px 8px;
  }

  .logo {
    font-size: 16px;
  }

  .logo-icon {
    font-size: 20px;
  }

  h1 { font-size: 24px; }
  h2 { font-size: 20px; }
  h3 { font-size: 16px; }
}
