/* layout.css - page structure, header, footer, containers */

/* App shell */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.header__logo {
  height: 36px;
  width: auto;
}

.header__title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-left: var(--space-md);
}

.header__nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.header__link {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}

.header__link:hover,
.header__link.active {
  color: var(--primary);
  background: var(--primary-light);
}

.header__user {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  padding-left: var(--space-sm);
  border-left: 1px solid var(--border);
}

.header__logout {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.15s;
}

.header__logout:hover {
  color: var(--error);
  border-color: var(--error);
  background: var(--error-light);
}

/* Main content */
.main {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg);
}

/* Footer */
.footer {
  background: var(--grey-800);
  color: var(--grey-400);
  text-align: center;
  padding: var(--space-lg);
  font-size: 13px;
  margin-top: auto;
}

.footer a {
  color: var(--grey-300);
  text-decoration: underline;
}

/* Page title */
.page-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: var(--space-xs);
}

.page-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: var(--space-xl);
}

/* Section */
.section {
  margin-bottom: var(--space-2xl);
}

.section__title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: var(--space-md);
  color: var(--text);
}

/* Hamburger toggle button - hidden on desktop */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: space-around;
  width: 36px;
  height: 36px;
  padding: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-left: auto;
  flex-shrink: 0;
}

.nav-toggle__bar {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.2s ease;
}

/* Hamburger nav - tablets and mobile (up to 1024px) */
@media (max-width: 1024px) {
  .nav-toggle {
    display: flex;
  }

  /* Only collapse nav on authenticated pages (#app-header = post-login only) */
  #app-header .header__nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    flex-direction: column;
    padding: var(--space-sm) var(--space-md) var(--space-md);
    gap: 2px;
    z-index: 99;
  }

  #app-header.header--nav-open .header__nav {
    display: flex;
  }

  #app-header .header__link {
    font-size: 15px;
    padding: var(--space-sm) var(--space-xs);
    display: block;
  }

  #app-header .header__user {
    font-size: 13px;
    border-left: none;
    padding-left: 0;
    border-top: 1px solid var(--border);
    padding-top: var(--space-sm);
    margin-top: var(--space-xs);
  }

  #app-header .header__logout {
    width: 100%;
    text-align: center;
  }

  #app-header .dark-toggle {
    text-align: left;
    padding: var(--space-xs) 0;
  }
}

/* Mobile layout tweaks */
@media (max-width: 768px) {
  .header {
    position: sticky;
    height: auto;
    min-height: var(--header-height);
    flex-wrap: nowrap;
    padding: 0 var(--space-md);
  }

  .header__title {
    font-size: 14px;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .main {
    padding: var(--space-md) var(--space-sm);
  }

  .page-title {
    font-size: 20px;
  }

  .page-subtitle {
    font-size: 14px;
  }

  .section__title {
    font-size: 16px;
  }

  .footer {
    padding: var(--space-md);
    font-size: 12px;
  }
}

@media (max-width: 320px) {
  .header__title {
    font-size: 13px;
  }

  .page-title {
    font-size: 18px;
  }
}

/* Print */
@media print {
  .header,
  .footer {
    display: none !important;
  }

  .main {
    padding: 0;
    max-width: 100%;
  }
}
