/* ── Reset & base ───────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #26668c;
  /*   #6B4FBB;   /* Growing Pai purple-ish */
  --primary-dk: #f26e23;
  /* #4e39a0; */
  --bg: #f5f6fa;
  --surface: #ffffff;
  --border: #e2e4ea;
  --text: #1a1d2e;
  --text-muted: #6b7280;
  --unread-bg: #faf7ff;
  --red: #dc2626;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0, 0, 0, .08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  /* Light haze over the photo so text and cards stay readable */
  background:
    linear-gradient(rgba(245, 246, 250, .72), rgba(245, 246, 250, .72)),
    url("../img/growing-pai-bg.jpg") center / cover no-repeat fixed,
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dk);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg);
}

.btn-large {
  padding: 13px 24px;
  font-size: 16px;
  border-radius: 8px;
}

.btn-small {
  padding: 5px 12px;
  font-size: 13px;
}

/* ── Navbar ─────────────────────────────────────────────────────────────── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
}

.brand-icon {
  font-size: 22px;
}

.brand-logo {
  height: 26px;
  width: auto;
  display: block;
}

.brand-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

.navbar-tabs {
  display: flex;
  align-self: stretch;
  gap: 4px;
  margin-left: 32px;
  margin-right: auto;
}

.nav-tab {
  display: flex;
  white-space: nowrap;
  align-items: center;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}

.nav-tab:hover {
  color: var(--text);
}

.nav-tab--active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-name {
  font-size: 14px;
  color: var(--text-muted);
}

/* ── Alerts ─────────────────────────────────────────────────────────────── */
.alert {
  margin: 16px auto;
  max-width: 720px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--red);
}

.alert-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
}

/* ── Main content ───────────────────────────────────────────────────────── */
.main-content {
  padding: 28px 20px;
}

/* ── Login page ─────────────────────────────────────────────────────────── */
.login-container {
  min-height: calc(100vh - 1px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(107, 79, 187, .15);
  padding: 52px 44px;
  text-align: center;
  max-width: 420px;
  width: 100%;
}

.login-logo {
  display: block;
  width: 100%;
  max-width: 260px;
  height: auto;
  margin: 0 auto 20px;
}

.login-title {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 10px;
}

.login-subtitle {
  color: var(--text-muted);
  margin-bottom: 32px;
  line-height: 1.6;
}

.login-note {
  margin-top: 18px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Inbox ──────────────────────────────────────────────────────────────── */
.inbox-container {
  max-width: 780px;
  margin: 0 auto;
}

.inbox-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.inbox-title {
  font-size: 22px;
  font-weight: 700;
}

.inbox-filter-badge {
  background: #ede9ff;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
}

.inbox-count {
  margin-left: auto;
  font-size: 13px;
  color: var(--text-muted);
}

/* Email list */
.email-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.email-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
}

.email-row:last-child {
  border-bottom: none;
}

.email-row:hover {
  background: #f9f8ff;
}

.email-row--unread {
  background: var(--unread-bg);
}

.email-row--unread .email-subject {
  font-weight: 700;
}

.email-row--unread .email-sender {
  font-weight: 700;
}

.email-row-left {
  flex: 1;
  min-width: 0;
}

.email-sender {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 3px;
}

.email-subject {
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.email-preview {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-row-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.email-date {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.unread-dot {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-unread {
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 52px;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 18px;
  color: var(--text);
  margin-bottom: 8px;
}

/* ── Email detail ───────────────────────────────────────────────────────── */
.detail-container {
  max-width: 780px;
  margin: 0 auto;
}

.detail-back {
  margin-bottom: 16px;
}

.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.detail-subject {
  font-size: 20px;
  font-weight: 700;
  padding: 24px 28px 0;
  line-height: 1.3;
}

.detail-meta {
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meta-row {
  display: flex;
  gap: 12px;
  font-size: 14px;
}

.meta-label {
  color: var(--text-muted);
  min-width: 48px;
  flex-shrink: 0;
}

.meta-value {
  color: var(--text);
}

.detail-body {
  padding: 28px;
}

.email-html-body {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  overflow-x: auto;
}

.email-html-frame {
  width: 100%;
  min-height: 200px;
  border: none;
  display: block;
}

/* Scope injected HTML styles */
.email-html-body img {
  max-width: 100%;
  height: auto;
}

.email-html-body a {
  color: var(--primary);
  text-decoration: underline;
}

.email-text-body {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .navbar {
    padding: 0 16px;
  }

  .login-card {
    padding: 36px 24px;
  }

  .main-content {
    padding: 16px 12px;
  }

  .detail-subject {
    padding: 16px 16px 0;
  }

  .detail-meta,
  .detail-body {
    padding: 12px 16px;
  }

  .email-row {
    padding: 14px 14px;
  }
}

/* ── Passwords ──────────────────────────────────────────────────────────── */
.pw-add {
  margin-left: auto;
}

/* Stays at the top while scrolling */
.pw-search-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 8px 0 16px;
  margin-bottom: 8px;
  background: rgba(245, 246, 250, .9);
  backdrop-filter: blur(4px);
}

.pw-search {
  width: 100%;
  padding: 10px 14px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.pw-search:focus {
  outline: none;
  border-color: var(--primary);
}

.pw-row[hidden],
.pw-category[hidden] {
  display: none;
}

.pw-category {
  margin-bottom: 28px;
}

.pw-category-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

.pw-category-toggle:hover {
  color: var(--text);
}

.pw-category-toggle .pw-chevron {
  font-size: 16px;
  transform: rotate(90deg);
}

.pw-category.is-collapsed .pw-category-toggle .pw-chevron {
  transform: none;
}

.pw-count {
  font-weight: 500;
}

.pw-category.is-collapsed .pw-category-body {
  display: none;
}

body.pw-searching .pw-category.is-collapsed .pw-category-body {
  display: block;
}

/* Personal: thin accent line so it's clear at a glance that these are private */
.pw-category--personal .email-list {
  border-left: 3px solid var(--primary-dk);
}

.pw-updated {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.pw-category-note {
  font-size: 13px;
  color: var(--text-muted);
  margin: -6px 0 10px;
}

.pw-category-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.pw-row {
  border-bottom: 1px solid var(--border);
}

.pw-row:last-child {
  border-bottom: none;
}

.pw-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 8px 8px;
}

.pw-toggle {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) minmax(0, 1.2fr);
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  font: inherit;
  text-align: left;
  color: inherit;
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.pw-toggle:hover {
  background: var(--bg);
}

.pw-chevron {
  font-size: 18px;
  line-height: 1;
  color: var(--text-muted);
  transition: transform .15s;
}

.pw-toggle[aria-expanded="true"] .pw-chevron {
  transform: rotate(90deg);
}

.pw-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pw-user {
  font-size: 14px;
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Fixed width so the name and user columns line up on every row. */
.pw-quick {
  flex: 0 0 300px;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.pw-details {
  padding: 4px 20px 16px 44px;
}

.pw-details[hidden] {
  display: none;
}

.pw-details-actions {
  margin-top: 12px;
}

.pw-danger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 28px 24px;
  padding: 14px 16px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  font-size: 14px;
}

.pw-danger small {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
}

.pw-field {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.pw-label {
  color: var(--text-muted);
  min-width: 96px;
}

.pw-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
}

.pw-link {
  color: inherit;
  text-decoration: none;
}

.pw-link:hover {
  text-decoration: underline;
}

.pw-notes {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
  white-space: pre-wrap;
}

.pw-delete {
  color: var(--red);
}

.pw-empty {
  font-size: 14px;
  color: var(--text-muted);
}

.pw-form {
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pw-form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

.pw-form-field>span {
  font-weight: 500;
}

.pw-form-field small {
  color: var(--text-muted);
  font-size: 12px;
}

.pw-form-field input,
.pw-form-field select,
.pw-form-field textarea {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.pw-form-field input:focus,
.pw-form-field select:focus,
.pw-form-field textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}

.pw-form-actions {
  display: flex;
  gap: 10px;
}

@media (max-width: 600px) {
  .navbar {
    padding: 0 16px;
    height: auto;
    flex-wrap: wrap;
  }

  .navbar-brand {
    height: 52px;
  }

  .brand-logo {
    height: 20px;
  }

  .brand-name {
    display: none;
  }

  .navbar-tabs {
    order: 3;
    width: 100%;
    height: 42px;
    margin: 0 -14px;
  }

  .user-name {
    display: none;
  }

  .pw-summary {
    flex-wrap: wrap;
    padding: 8px 12px 10px 4px;
  }

  .pw-toggle {
    flex-basis: 100%;
    grid-template-columns: 20px minmax(0, 1fr);
  }

  .pw-user {
    grid-column: 2;
  }

  .pw-quick {
    flex: 1 1 100%;
    justify-content: flex-start;
    padding-left: 36px;
    flex-wrap: wrap;
  }

  .pw-details {
    padding: 4px 12px 14px 40px;
  }
}