/* WPCap v3 — Layout: App Shell */

/* ── App Grid ── */
.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: 52px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  grid-row: 1 / -1;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  user-select: none;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.03em;
}

.sidebar-logo .logo-version {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  padding: 1px 5px;
  background: var(--bg-elevated);
  border-radius: var(--r-sm);
}

.nav-section {
  padding: var(--sp-3) var(--sp-2);
}

.nav-section:not(:last-of-type) {
  border-bottom: 1px solid var(--border-subtle);
}

.nav-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--sp-1) var(--sp-3);
  margin-bottom: var(--sp-1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px var(--sp-3);
  margin: 1px 0;
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 450;
  cursor: pointer;
  transition: all var(--t-fast);
  text-decoration: none;
}

.nav-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  text-decoration: none;
}

.nav-item.active {
  background: var(--accent-muted);
  color: var(--accent);
  font-weight: 500;
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.6;
}

.nav-item.active svg { opacity: 1; }
.nav-item:hover svg { opacity: 0.85; }

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  padding: 0 6px;
  border-radius: 10px;
  background: var(--bg-elevated);
  color: var(--text-tertiary);
  line-height: 18px;
}

.nav-badge.warn {
  background: var(--amber-bg);
  color: var(--amber);
}

.nav-badge.error {
  background: var(--red-bg);
  color: var(--red);
}

.sidebar-footer {
  margin-top: auto;
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

/* ── Top Bar ── */
.topbar {
  grid-column: 2;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-6);
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border-default);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

/* ── Agency Filter (top bar) ── */
.agency-filter {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 5px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  font-size: 13px;
  font-family: var(--font-sans);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color var(--t-fast);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

.agency-filter:hover { border-color: var(--border-strong); }
.agency-filter:focus { border-color: var(--accent); outline: none; }
.agency-filter option { background: var(--bg-elevated); color: var(--text-primary); }

/* ── Main Content ── */
.main {
  grid-column: 2;
  overflow-y: auto;
  padding: var(--sp-6);
}

.view { display: none; }
.view.active { display: block; animation: fadeIn 0.15s ease-out; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── View Header ── */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-5);
}

.view-header-left {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.view-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* ── Filter Bar ── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-5);
  flex-wrap: wrap;
}

.filter-pill {
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 450;
  color: var(--text-tertiary);
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: 100px;
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
}

.filter-pill:hover {
  color: var(--text-secondary);
  border-color: var(--border-strong);
}

.filter-pill.active {
  color: var(--text-primary);
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}

.filter-search {
  padding: 5px 12px;
  font-size: 13px;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  outline: none;
  width: 200px;
  transition: border-color var(--t-fast);
  margin-left: auto;
}

.filter-search:focus { border-color: var(--accent); }
.filter-search::placeholder { color: var(--text-muted); }

/* ── Sub Navigation (pills within a view) ── */
.sub-nav {
  display: flex;
  gap: 1px;
  background: var(--border-subtle);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: var(--sp-5);
  width: fit-content;
}

.sub-nav-item {
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 450;
  color: var(--text-tertiary);
  background: var(--bg-surface);
  cursor: pointer;
  transition: all var(--t-fast);
  border: none;
  white-space: nowrap;
}

.sub-nav-item:hover {
  color: var(--text-secondary);
  background: var(--bg-elevated);
}

.sub-nav-item.active {
  color: var(--text-primary);
  background: var(--bg-elevated);
  font-weight: 500;
}

/* ── Section Title ── */
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
  margin: var(--sp-6) 0 var(--sp-3);
}

.section-title:first-child { margin-top: 0; }

/* ── Login Screen ── */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
}

.login-screen.hidden { display: none; }

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-xl);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}

.login-brand {
  text-align: center;
  margin-bottom: var(--sp-8);
}

.login-brand .brand-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.03em;
}

.login-brand .brand-sub {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: var(--sp-1);
}

.login-field {
  margin-bottom: var(--sp-4);
}

.login-field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-tertiary);
  margin-bottom: var(--sp-1);
}

.login-field input {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  outline: none;
  transition: border-color var(--t-fast);
}

.login-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.login-error {
  font-size: 13px;
  color: var(--red);
  margin-bottom: var(--sp-3);
  min-height: 20px;
}

.login-submit {
  width: 100%;
  padding: 10px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-sans);
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--t-fast);
}

.login-submit:hover { background: var(--accent-hover); }
.login-submit:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
