/* =========================================================
   BHK Cloud — Portal Styles (Affiliate & Admin dashboards)
   Extends styles.css design tokens
   ========================================================= */

/* ─── Portal Layout ──────────────────────────────────────── */
.portal {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.portal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px var(--gutter);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(14px);
}

.portal__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.portal__brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--gradient);
}

.portal__brand-name {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
}

.portal__brand-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(43, 107, 255, 0.15);
  color: var(--electric);
  border: 1px solid rgba(43, 107, 255, 0.25);
}

.portal__user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.portal__user-name {
  font-size: 0.875rem;
  color: var(--text-soft);
}

.portal__logout {
  font-size: 0.8rem;
  padding: 6px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-soft);
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.portal__logout:hover {
  background: rgba(255, 60, 60, 0.1);
  border-color: rgba(255, 60, 60, 0.3);
  color: #ff6b6b;
}

/* ─── Portal Navigation ──────────────────────────────────── */
.portal__nav {
  display: flex;
  gap: 4px;
  padding: 12px var(--gutter);
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  overflow-x: auto;
}

.portal__nav a {
  font-size: 0.85rem;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 8px;
  color: var(--text-mute);
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.2s var(--ease);
}

.portal__nav a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.portal__nav a.active {
  color: var(--electric);
  background: rgba(43, 107, 255, 0.1);
  border: 1px solid rgba(43, 107, 255, 0.2);
}

/* ─── Portal Content ─────────────────────────────────────── */
.portal__content {
  flex: 1;
  padding: 32px var(--gutter);
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.portal__title {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 8px;
}

.portal__subtitle {
  color: var(--text-soft);
  font-size: 0.95rem;
  margin: 0 0 32px;
}

/* ─── Stat Cards ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px;
  transition: border-color 0.2s var(--ease);
}

.stat-card:hover {
  border-color: var(--border-strong);
}

.stat-card__label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-mute);
  margin-bottom: 8px;
}

.stat-card__value {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
}

.stat-card__value--highlight {
  background: var(--gradient-text);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ─── Data Tables ────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-mute);
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-soft);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: rgba(43, 107, 255, 0.03);
}

/* ─── Status Badges ──────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 10px;
  border-radius: 20px;
}

.badge--active,
.badge--approved,
.badge--completed {
  background: rgba(34, 197, 94, 0.12);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.badge--pending,
.badge--processing {
  background: rgba(234, 179, 8, 0.12);
  color: #fbbf24;
  border: 1px solid rgba(234, 179, 8, 0.25);
}

.badge--cancelled,
.badge--voided,
.badge--failed,
.badge--terminated {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.badge--suspended,
.badge--expired {
  background: rgba(156, 163, 175, 0.12);
  color: #9ca3af;
  border: 1px solid rgba(156, 163, 175, 0.25);
}

.badge--paid {
  background: rgba(43, 107, 255, 0.12);
  color: var(--cyan);
  border: 1px solid rgba(43, 107, 255, 0.25);
}

/* ─── Login Page ─────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: 40px;
  backdrop-filter: blur(14px);
}

.login-card__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}

.login-card__logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--gradient);
}

.login-card__logo-text {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text);
}

.login-card h1 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 8px;
}

.login-card__sub {
  color: var(--text-soft);
  font-size: 0.9rem;
  margin: 0 0 28px;
}

.login-card .field {
  margin-bottom: 18px;
}

.login-card .field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 6px;
}

.login-card .field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-card .field input:focus {
  outline: none;
  border-color: var(--electric);
  box-shadow: 0 0 0 3px rgba(43, 107, 255, 0.15);
}

.login-card__error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  font-size: 0.85rem;
  color: #f87171;
  margin-bottom: 16px;
  display: none;
}

.login-card__error.visible {
  display: block;
}

/* ─── Forms (Portal) ─────────────────────────────────────── */
.portal-form {
  max-width: 600px;
}

.portal-form .field {
  margin-bottom: 20px;
}

.portal-form .field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 6px;
}

.portal-form .field input,
.portal-form .field select,
.portal-form .field textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.portal-form .field input:focus,
.portal-form .field select:focus,
.portal-form .field textarea:focus {
  outline: none;
  border-color: var(--electric);
  box-shadow: 0 0 0 3px rgba(43, 107, 255, 0.15);
}

/* ─── Link Generator Box ─────────────────────────────────── */
.link-box {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 20px;
  margin-bottom: 20px;
}

.link-box__label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-mute);
  margin-bottom: 8px;
}

.link-box__url {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  margin-bottom: 10px;
}

.link-box__url code {
  flex: 1;
  font-size: 0.85rem;
  color: var(--cyan);
  word-break: break-all;
  font-family: "SF Mono", "Fira Code", monospace;
}

.link-box__copy {
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  background: var(--gradient);
  color: white;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s;
}

.link-box__copy:hover {
  transform: translateY(-1px);
}

.link-box__copy:active {
  transform: translateY(0);
}

/* ─── Empty State ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-mute);
}

.empty-state__icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state__text {
  font-size: 0.9rem;
}

/* ─── Action Bar ─────────────────────────────────────────── */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.action-bar__filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.action-bar__filter {
  padding: 6px 14px;
  font-size: 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  transition: all 0.2s;
}

.action-bar__filter:hover,
.action-bar__filter.active {
  border-color: var(--electric);
  color: var(--electric);
  background: rgba(43, 107, 255, 0.06);
}

/* ─── Modal (simple) ─────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 15, 0.85);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.modal-overlay.visible {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: 32px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal__title {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 20px;
}

.modal__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ─── Buttons ────────────────────────────────────────────── */
.btn--sm {
  padding: 8px 16px;
  font-size: 0.8rem;
}

.btn--full {
  width: 100%;
}

.btn--danger {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
}

.btn--danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .portal__header {
    padding: 12px 16px;
  }

  .portal__nav {
    padding: 8px 16px;
  }

  .portal__content {
    padding: 20px 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .portal__title {
    font-size: 1.4rem;
  }

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

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .action-bar {
    flex-direction: column;
    align-items: stretch;
  }
}
