/* =====================================================
   WYNet Shared Header — wynet-header.css
   Self-contained; include before <body> content.
   ===================================================== */

:root {
  --wh-accent:  #1d4ed8;
  --wh-card:    #ffffff;
  --wh-bg:      #f0f2f6;
  --wh-text:    #111827;
  --wh-border:  #e4e7ec;
  --wh-shadow:  0 1px 4px rgba(0,0,0,.07), 0 0 0 1px rgba(0,0,0,.04);
}

[data-wh-theme="dark"] {
  --wh-accent:  #4f83f7;
  --wh-card:    #1a1d27;
  --wh-bg:      #0f1117;
  --wh-text:    #e8eaf0;
  --wh-border:  #2d3148;
  --wh-shadow:  0 1px 4px rgba(0,0,0,.3), 0 0 0 1px rgba(255,255,255,.04);
}

.wynet-header {
  background: var(--wh-accent);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wynet-header *, .wynet-header *::before, .wynet-header *::after {
  box-sizing: border-box;
}

.wynet-header-top {
  padding: .75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

/* Logo */
.wynet-logo {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  color: #fff;
  flex-shrink: 0;
}
.wh-logo-brand { font-weight: 700; }
.wh-logo-sep   { opacity: .5; }
.wh-logo-site  { font-weight: 400; opacity: .85; }

/* User area */
.wynet-user-area { position: relative; flex-shrink: 0; }

.wh-user-trigger {
  display: flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  background: rgba(255,255,255,.15);
  border-radius: 20px;
  padding: .35rem .75rem .35rem .45rem;
  border: none;
  color: #fff;
  font-family: inherit;
  font-size: inherit;
  transition: background .15s;
}
.wh-user-trigger:hover { background: rgba(255,255,255,.22); }

.wh-user-avatar {
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.wh-user-name { font-size: .85rem; font-weight: 500; }

.wh-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + .5rem);
  background: var(--wh-card);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
  min-width: 200px;
  z-index: 200;
  overflow: hidden;
  display: none;
  border: 1px solid var(--wh-border);
}
.wh-dropdown.open { display: block; }

.wh-dropdown-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .65rem 1rem;
  font-size: .875rem;
  color: var(--wh-text);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  transition: background .1s;
}
.wh-dropdown-item:hover { background: var(--wh-bg); }

.wh-dropdown-divider {
  border: none;
  border-top: 1px solid var(--wh-border);
  margin: .25rem 0;
}

/* Tab nav (optional) */
.wynet-header-nav {
  padding: 0 1.5rem;
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.wynet-header-nav::-webkit-scrollbar { display: none; }

.wh-tab-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.75);
  padding: .85rem 1.3rem;
  font-size: .95rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color .15s, background .15s, border-color .15s;
  font-family: inherit;
}
.wh-tab-btn:hover { color: #fff; background: rgba(255,255,255,.1); }
.wh-tab-btn.active { color: #fff; border-bottom-color: #fff; }

/* ── View As popup ── */
.wh-va-overlay {
  position: fixed; inset: 0; z-index: 9998;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
}
.wh-va-popup {
  background: var(--wh-card); border-radius: .75rem;
  box-shadow: 0 8px 32px rgba(0,0,0,.35); border: 1px solid var(--wh-border);
  width: 320px; max-height: 480px; display: flex; flex-direction: column; overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wh-va-popup-hdr {
  padding: .85rem 1rem .6rem; border-bottom: 1px solid var(--wh-border);
  display: flex; align-items: center; justify-content: space-between;
}
.wh-va-popup-hdr span { font-weight: 600; font-size: .9rem; color: var(--wh-text); }
.wh-va-popup-close {
  background: none; border: none; cursor: pointer; font-size: 1rem;
  color: var(--wh-text); opacity: .5; line-height: 1; padding: 0;
}
.wh-va-popup-close:hover { opacity: 1; }
.wh-va-search {
  margin: .55rem .75rem; padding: .45rem .65rem; border-radius: .4rem;
  border: 1px solid var(--wh-border); background: var(--wh-bg); color: var(--wh-text);
  font-size: .88rem; outline: none; width: calc(100% - 1.5rem);
  box-sizing: border-box; font-family: inherit;
}
.wh-va-list { overflow-y: auto; flex: 1; padding: .25rem .5rem .75rem; }
.wh-va-row {
  display: flex; align-items: center; gap: .65rem; width: 100%;
  padding: .55rem .65rem; border: none; background: none; cursor: pointer;
  border-radius: .4rem; text-align: left; color: var(--wh-text); font-family: inherit;
}
.wh-va-row:hover { background: rgba(255,255,255,.08); }
[data-wh-theme="light"] .wh-va-row:hover { background: rgba(0,0,0,.05); }
.wh-va-avatar {
  width: 2rem; height: 2rem; border-radius: 50%; background: var(--wh-accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; flex-shrink: 0;
}
.wh-va-info { flex: 1; min-width: 0; }
.wh-va-name { font-weight: 500; font-size: .88rem; color: var(--wh-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wh-va-username { font-size: .75rem; color: var(--wh-text); opacity: .55; }
.wh-va-empty { padding: .75rem; color: var(--wh-text); opacity: .5; font-size: .85rem; text-align: center; }

/* ── View As banner ── */
.wh-va-banner {
  position: sticky; top: 0; z-index: 200;
  background: #7c3aed; color: #fff;
  padding: .5rem 1.5rem; display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; font-size: .85rem; font-weight: 500;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wh-va-banner-label { display: flex; align-items: center; gap: .5rem; }
.wh-va-banner-btns { display: flex; gap: .5rem; }
.wh-va-banner-btn {
  background: rgba(255,255,255,.2); border: none; color: #fff;
  padding: .3rem .85rem; border-radius: 6px; cursor: pointer; font-size: .83rem;
  font-family: inherit; transition: background .12s;
}
.wh-va-banner-btn:hover { background: rgba(255,255,255,.3); }

/* Responsive */
@media (max-width: 640px) {
  .wynet-header-top { padding: .6rem 1rem; }
  .wh-user-name { display: none; }
}

/* ── App launcher trigger ── */
.wynet-logo.wh-apps-trigger {
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  padding: 0;
  line-height: inherit;
  -webkit-appearance: none;
}
.wynet-logo.wh-apps-trigger:hover { opacity: .85; }

/* ── App launcher overlay + panel ── */
.wh-apps-overlay {
  position: fixed;
  inset: 0;
  z-index: 9997;
  background: rgba(0,0,0,.3);
}

.wh-apps-panel {
  position: absolute;
  left: 0;
  width: 380px;
  max-width: 95vw;
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  background: var(--wh-card);
  border: 1px solid var(--wh-border);
  border-top: none;
  border-bottom-right-radius: 10px;
  box-shadow: 4px 4px 28px rgba(0,0,0,.28);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.wh-apps-panel-hdr {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--wh-border);
  flex-shrink: 0;
}

.wh-apps-panel-title {
  font-weight: 700;
  font-size: .88rem;
  color: var(--wh-text);
  flex-shrink: 0;
}

.wh-apps-search {
  flex: 1;
  padding: .32rem .6rem;
  border-radius: .4rem;
  border: 1px solid var(--wh-border);
  background: var(--wh-bg);
  color: var(--wh-text);
  font-size: .84rem;
  outline: none;
  font-family: inherit;
  min-width: 0;
}
.wh-apps-search:focus { border-color: var(--wh-accent); }

.wh-apps-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--wh-text);
  opacity: .45;
  padding: 3px;
  line-height: 0;
  flex-shrink: 0;
  border-radius: 4px;
}
.wh-apps-close:hover { opacity: 1; background: var(--wh-bg); }

/* ── App grid ── */
.wh-apps-grid {
  flex: 1;
  overflow-y: auto;
  padding: .75rem .75rem .5rem;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .15rem;
  align-content: start;
  scrollbar-width: thin;
  scrollbar-color: var(--wh-border) transparent;
}
.wh-apps-grid::-webkit-scrollbar { width: 4px; }
.wh-apps-grid::-webkit-scrollbar-thumb { background: var(--wh-border); border-radius: 2px; }

.wh-app-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .45rem;
  padding: .7rem .3rem;
  text-decoration: none;
  border-radius: 8px;
  transition: background .12s;
  cursor: pointer;
}
.wh-app-tile:hover { background: var(--wh-bg); }

.wh-app-icon {
  width: 46px;
  height: 46px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .82rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: .3px;
  flex-shrink: 0;
}

.wh-app-name {
  font-size: .7rem;
  font-weight: 500;
  color: var(--wh-text);
  text-align: center;
  max-width: 76px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
}

.wh-apps-status {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem 1rem;
  color: var(--wh-text);
  opacity: .45;
  font-size: .88rem;
}

/* ── Pagination ── */
.wh-apps-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .65rem;
  padding: .55rem 1rem;
  border-top: 1px solid var(--wh-border);
  flex-shrink: 0;
}

.wh-apps-pager-btn {
  background: none;
  border: 1px solid var(--wh-border);
  color: var(--wh-text);
  padding: .28rem .7rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: .8rem;
  font-family: inherit;
  transition: background .1s;
}
.wh-apps-pager-btn:hover:not(:disabled) { background: var(--wh-bg); }
.wh-apps-pager-btn:disabled { opacity: .3; cursor: not-allowed; }

.wh-apps-pager-info {
  font-size: .8rem;
  color: var(--wh-text);
  opacity: .6;
}
