/* ============================================================
   IHTS Member Portal — portal.css  v3.2.0
   All CSS variables scoped to .ihts-portal to prevent
   WordPress theme variable bleed-through.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300..700&family=DM+Serif+Display:ital@0;1&display=swap');

/* ── All tokens scoped inside the portal wrapper ── */
.ihts-portal {
  /* Surfaces */
  --ihts-bg:              #f5f4f0;
  --ihts-surface:         #faf9f7;
  --ihts-surface-2:       #ffffff;
  --ihts-surface-offset:  #edeae4;
  --ihts-border:          rgba(40,37,29,0.11);
  --ihts-divider:         rgba(40,37,29,0.08);

  /* Text — explicit hex values so theme :root vars cannot override */
  --ihts-text:            #1e1c16;
  --ihts-text-muted:      #706e68;
  --ihts-text-faint:      #b0aea8;
  --ihts-text-inverse:    #f9f8f5;

  /* Brand teal */
  --ihts-primary:         #01696f;
  --ihts-primary-hover:   #0c4e54;
  --ihts-primary-hl:      #d2e4e2;

  /* Semantic */
  --ihts-success:         #437a22;
  --ihts-success-hl:      #d4dfcc;
  --ihts-warning:         #964219;
  --ihts-warning-hl:      #e6d5c8;
  --ihts-error:           #a12c7b;
  --ihts-error-hl:        #e0ced7;
  --ihts-info:            #006494;
  --ihts-info-hl:         #c6d8e4;
  --ihts-neutral-hl:      #e5e3de;

  /* Spacing */
  --s1: 0.25rem; --s2: 0.5rem;  --s3: 0.75rem; --s4: 1rem;
  --s5: 1.25rem; --s6: 1.5rem;  --s8: 2rem;    --s10: 2.5rem;
  --s12: 3rem;   --s16: 4rem;

  /* Radius */
  --r-sm: 0.375rem; --r-md: 0.5rem;
  --r-lg: 0.75rem;  --r-xl: 1rem; --r-full: 9999px;

  /* Type — explicit sizes to prevent theme override */
  --t-xs:   0.8125rem;  /* 13px */
  --t-sm:   0.9375rem;  /* 15px */
  --t-base: 1rem;       /* 16px */
  --t-lg:   1.1875rem;  /* 19px */
  --t-xl:   1.5rem;     /* 24px */

  /* Fonts */
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body:    'Inter', 'Helvetica Neue', Arial, sans-serif;

  /* Transitions */
  --ease: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(30,28,22,0.07);
  --shadow-md: 0 4px 14px rgba(30,28,22,0.09);
  --shadow-lg: 0 12px 36px rgba(30,28,22,0.12);
}

/* ── Base portal reset — scoped to avoid theme leaking in ── */
.ihts-portal,
.ihts-portal *,
.ihts-portal *::before,
.ihts-portal *::after {
  box-sizing: border-box;
}
.ihts-portal {
  font-family: var(--font-body);
  font-size: var(--t-base);
  /* Explicit fallback values — crucial when theme overrides :root vars */
  color: #1e1c16;
  color: var(--ihts-text);
  background: #f5f4f0;
  background: var(--ihts-bg);
  min-height: 40vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}
/* Force text color on ALL direct children to overcome theme specificity */
.ihts-portal p,
.ihts-portal span,
.ihts-portal li,
.ihts-portal dd,
.ihts-portal td,
.ihts-portal th,
.ihts-portal label,
.ihts-portal h1,
.ihts-portal h2,
.ihts-portal h3 {
  color: #1e1c16;
  color: var(--ihts-text);
}
.ihts-portal a {
  color: #01696f;
  color: var(--ihts-primary);
  text-decoration: none;
}
.ihts-portal a:hover { text-decoration: underline; }
.ihts-hidden { display: none !important; }

/* ── Top Bar ── */
.ihts-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: #ffffff;
  background: var(--ihts-surface-2);
  border-bottom: 1px solid rgba(40,37,29,0.11);
  border-bottom-color: var(--ihts-border);
  box-shadow: 0 1px 3px rgba(30,28,22,0.07);
  position: sticky;
  top: 0;
  z-index: 100;
}
.ihts-topbar__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.ihts-topbar__site {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #1e1c16;
  color: var(--ihts-text);
  letter-spacing: -0.01em;
}
.ihts-topbar__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.ihts-logo { flex-shrink: 0; }

/* ── Hero ── */
.ihts-hero {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 2rem 1.5rem;
  background: linear-gradient(135deg, #01696f 0%, #0c4e54 100%);
}
.ihts-avatar {
  width: 80px; height: 80px; flex-shrink: 0;
  border-radius: 9999px;
  overflow: hidden;
  background: rgba(255,255,255,0.15);
  border: 3px solid rgba(255,255,255,0.3);
}
.ihts-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ihts-avatar__initials {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.75rem; font-weight: 700;
  font-family: 'DM Serif Display', Georgia, serif;
  font-family: var(--font-display);
  color: rgba(255,255,255,0.9);
}
.ihts-hero__info { min-width: 0; }
.ihts-hero__name {
  font-family: 'DM Serif Display', Georgia, serif;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1.15;
  color: #ffffff !important;
  margin-bottom: 0.25rem;
}
.ihts-hero__title {
  font-size: 0.9375rem;
  color: rgba(255,255,255,0.75) !important;
  margin-bottom: 0.5rem;
}
.ihts-hero__meta { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.ihts-hero__meta span {
  font-size: 0.8125rem;
  color: rgba(255,255,255,0.7) !important;
}

/* ── Status Grid ── */
.ihts-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(200px,100%), 1fr));
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: #faf9f7;
  background: var(--ihts-surface);
  border-bottom: 1px solid rgba(40,37,29,0.08);
}
.ihts-status-card {
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  background: #ffffff;
  background: var(--ihts-surface-2);
  border: 1px solid rgba(40,37,29,0.11);
  display: flex; flex-direction: column; gap: 0.25rem;
  box-shadow: 0 1px 3px rgba(30,28,22,0.07);
}
.ihts-status-card__label {
  font-size: 0.75rem !important;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #706e68 !important;
  color: var(--ihts-text-muted) !important;
  font-weight: 600;
}
.ihts-status-card__value { font-size: 0.9375rem; font-weight: 600; }
.ihts-status-card--success { border-left: 3px solid #437a22; }
.ihts-status-card--success .ihts-status-card__value { color: #437a22 !important; }
.ihts-status-card--warning { border-left: 3px solid #964219; }
.ihts-status-card--warning .ihts-status-card__value { color: #964219 !important; }
.ihts-status-card--error   { border-left: 3px solid #a12c7b; }
.ihts-status-card--error   .ihts-status-card__value { color: #a12c7b !important; }
.ihts-status-card--info    { border-left: 3px solid #006494; }
.ihts-status-card--info    .ihts-status-card__value { color: #006494 !important; }
.ihts-status-card--neutral { border-left: 3px solid rgba(40,37,29,0.11); }
.ihts-status-card--neutral .ihts-status-card__value { color: #706e68 !important; }

/* ── Sections ── */
.ihts-section {
  background: #faf9f7;
  background: var(--ihts-surface);
  border-bottom: 1px solid rgba(40,37,29,0.08);
  border-bottom-color: var(--ihts-divider);
  padding: 1.5rem;
}
.ihts-section__header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.ihts-section__header h2 {
  font-family: 'Inter', sans-serif;
  font-family: var(--font-body);
  font-size: 1.1875rem;
  font-weight: 600;
  color: #1e1c16 !important;
  color: var(--ihts-text) !important;
}

/* ── DL (view mode) ── */
.ihts-dl {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px,100%), 1fr));
  gap: 0 1.5rem;
}
.ihts-dl__row {
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(40,37,29,0.08);
}
.ihts-dl__row:last-child { border-bottom: none; }
.ihts-dl dt {
  font-size: 0.75rem !important;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #706e68 !important;
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.ihts-dl dd {
  font-size: 0.9375rem !important;
  color: #1e1c16 !important;
  word-break: break-word;
}

/* ── Form ── */
.ihts-form__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(260px,100%), 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.ihts-form__group { display: flex; flex-direction: column; gap: 0.25rem; }
.ihts-form__group--full { grid-column: 1 / -1; }
.ihts-form__group label {
  font-size: 0.75rem !important;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #706e68 !important;
}
/* Inputs — aggressive specificity to override theme styles */
.ihts-portal input[type="text"],
.ihts-portal input[type="email"],
.ihts-portal input[type="tel"],
.ihts-portal input[type="url"],
.ihts-portal input[type="number"],
.ihts-portal select,
.ihts-portal textarea {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid rgba(40,37,29,0.2) !important;
  border-radius: 0.5rem;
  background: #ffffff !important;
  color: #1e1c16 !important;
  font-family: 'Inter', sans-serif;
  font-size: 0.9375rem !important;
  line-height: 1.5;
  transition: border-color 180ms ease, box-shadow 180ms ease;
  -webkit-appearance: none;
  appearance: none;
}
.ihts-portal input:focus,
.ihts-portal select:focus,
.ihts-portal textarea:focus {
  outline: none !important;
  border-color: #01696f !important;
  box-shadow: 0 0 0 3px rgba(1,105,111,0.18) !important;
}
.ihts-portal textarea { resize: vertical; min-height: 80px; }
.ihts-portal select { cursor: pointer; 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='%23706e68' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2rem; }
.ihts-portal input[type="checkbox"] { width: auto; display: inline-block; }
.ihts-form__actions { display: flex; gap: 0.5rem; align-items: center; padding-top: 0.5rem; }

/* ── Buttons ── */
.ihts-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-family: 'Inter', sans-serif;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 180ms ease, color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
  text-decoration: none !important;
  white-space: nowrap;
  line-height: 1.4;
}
.ihts-btn:hover { transform: translateY(-1px); }
.ihts-btn:active { transform: translateY(0); }
.ihts-btn svg { flex-shrink: 0; }

.ihts-btn--primary {
  background: #01696f !important;
  color: #ffffff !important;
  border-color: #01696f !important;
}
.ihts-btn--primary:hover {
  background: #0c4e54 !important;
  color: #ffffff !important;
}
.ihts-btn--ghost {
  background: transparent !important;
  color: #706e68 !important;
  border-color: rgba(40,37,29,0.2) !important;
}
.ihts-btn--ghost:hover {
  background: #edeae4 !important;
  color: #1e1c16 !important;
}
.ihts-btn--sm  { padding: 0.25rem 0.75rem; font-size: 0.8125rem; }
.ihts-btn--xs  { padding: 2px 0.5rem; font-size: 0.75rem; border-radius: 0.375rem; }

/* ── Badges ── */
.ihts-badge {
  display: inline-block;
  padding: 2px 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #e5e3de;
  color: #706e68 !important;
}
.ihts-badge--level { background: #d2e4e2; color: #0c4e54 !important; }
.ihts-badge--role  { background: #c6d8e4; color: #006494 !important; }
.ihts-badge--count { background: #edeae4; color: #706e68 !important; }

/* ── Status dots ── */
.ihts-dot { display: inline-block; width: 8px; height: 8px; border-radius: 9999px; margin-right: 0.25rem; vertical-align: middle; }
.ihts-dot--success { background: #437a22; }
.ihts-dot--warning { background: #964219; }
.ihts-dot--error   { background: #a12c7b; }
.ihts-dot--neutral { background: #b0aea8; }

/* ── Search Form ── */
.ihts-search-form { margin-bottom: 1rem; }
.ihts-search-form__row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.ihts-input--search {
  flex: 1; min-width: 200px;
  padding: 0.5rem 1rem;
  border: 1px solid rgba(40,37,29,0.2) !important;
  border-radius: 0.5rem;
  background: #ffffff !important;
  font-family: 'Inter', sans-serif;
  font-size: 0.9375rem !important;
  color: #1e1c16 !important;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
.ihts-input--search:focus {
  outline: none;
  border-color: #01696f !important;
  box-shadow: 0 0 0 3px rgba(1,105,111,0.18) !important;
}

/* ── Table ── */
.ihts-table-wrap {
  overflow-x: auto;
  border-radius: 0.75rem;
  border: 1px solid rgba(40,37,29,0.11);
  margin-top: 1rem;
}
.ihts-table { border-collapse: collapse; width: 100%; }
.ihts-table th {
  padding: 0.5rem 1rem;
  text-align: left;
  font-size: 0.75rem !important;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #706e68 !important;
  background: #edeae4;
  border-bottom: 1px solid rgba(40,37,29,0.11);
}
.ihts-table td {
  padding: 0.75rem 1rem;
  font-size: 0.9375rem !important;
  color: #1e1c16 !important;
  border-bottom: 1px solid rgba(40,37,29,0.08);
  vertical-align: middle;
}
.ihts-table tr:last-child td { border-bottom: none; }
.ihts-table tr:hover td { background: #f3f0ec; }
.ihts-table__actions { white-space: nowrap; display: flex; gap: 0.25rem; }
.ihts-table code {
  font-size: 0.8125rem;
  background: #edeae4;
  color: #1e1c16 !important;
  padding: 2px 0.5rem;
  border-radius: 0.375rem;
}

/* ── Pagination ── */
.ihts-pagination { display: flex; align-items: center; gap: 0.25rem; margin-top: 1rem; flex-wrap: wrap; }
.ihts-pagination__info { font-size: 0.8125rem; color: #706e68 !important; margin-left: auto; }

/* ── Inline Panel (manage view/edit) ── */
.ihts-inline-panel {
  border: 1px solid rgba(40,37,29,0.11);
  border-radius: 0.75rem;
  overflow: hidden;
  margin-top: 1rem;
}
.ihts-inline-panel__bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1rem;
  background: #edeae4;
  border-bottom: 1px solid rgba(40,37,29,0.11);
  font-size: 0.9375rem;
  font-weight: 600;
  color: #1e1c16 !important;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.ihts-inline-panel .ihts-topbar { position: static; }

/* ── Notice ── */
.ihts-notice {
  padding: 1rem;
  border-radius: 0.5rem;
  background: #c6d8e4;
  color: #1e1c16 !important;
  font-size: 0.9375rem;
}
.ihts-notice--error { background: #e0ced7; }

/* ── Empty state ── */
.ihts-empty-state {
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding: 4rem 2rem;
  color: #706e68 !important;
}
.ihts-empty-state svg { margin-bottom: 1rem; color: #b0aea8; }
.ihts-empty-state h3 { color: #1e1c16 !important; margin-bottom: 0.5rem; font-size: 1rem; }
.ihts-empty-state p  { max-width: 36ch; font-size: 0.9375rem; color: #706e68 !important; }

/* ── Toast ── */
.ihts-toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: #01696f;
  color: #ffffff !important;
  padding: 0.75rem 1.25rem;
  border-radius: 0.75rem;
  font-size: 0.9375rem;
  font-weight: 500;
  box-shadow: 0 12px 36px rgba(30,28,22,0.18);
  z-index: 99999;
  animation: ihts-fadein 0.3s ease, ihts-fadeout 0.5s 2.5s forwards;
}
@keyframes ihts-fadein  { from { opacity:0; transform:translateY(8px);  } to { opacity:1; transform:translateY(0); } }
@keyframes ihts-fadeout { to   { opacity:0; transform:translateY(-4px); } }

/* ── Print styles ── */
@media print {
  .ihts-topbar,
  .ihts-edit-btn,
  .ihts-form__actions,
  .ihts-btn,
  .ihts-search-form,
  .ihts-pagination { display: none !important; }
  .ihts-section { page-break-inside: avoid; }
  .ihts-portal  { background: #ffffff; }
  .ihts-edit-mode { display: none !important; }
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .ihts-hero { flex-direction: column; align-items: flex-start; padding: 1.25rem 1rem; }
  .ihts-status-grid { padding: 0.75rem 1rem; }
  .ihts-section { padding: 1rem; }
  .ihts-topbar { padding: 0.5rem 1rem; }
  .ihts-form__grid { grid-template-columns: 1fr; }
  .ihts-dl { grid-template-columns: 1fr; }
  .ihts-topbar__actions { gap: 0.25rem; }
}

/* ── Upload field ── */
.ihts-upload-wrap { display: flex; flex-direction: column; gap: 0.5rem; }
.ihts-upload-wrap input[type="file"] {
  padding: 0.25rem 0;
  border: none !important;
  background: transparent !important;
  font-size: 0.875rem;
  color: var(--ihts-text-muted) !important;
  cursor: pointer;
}
.ihts-hint {
  font-size: 0.75rem;
  color: var(--ihts-text-muted) !important;
  margin: 0;
}

/* ── Required marker ── */
.ihts-required { color: var(--ihts-error); margin-left: 2px; }
