/* =================================================================
   ElevatePFS Portal — Shared Stylesheet
   Sections: 1) Reset & tokens  2) Shared chrome  3) Login page
             4) Apps dashboard  5) Responsive
   ================================================================= */

/* ── 1. Reset & design tokens ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:        #0a0f1e;
  --navy-panel:  #0b1e3d;
  --blue:        #0078d4;
  --blue-hover:  #106ebe;
  --teal:        #0a9396;
  --teal-light:  #94d2bd;

  --card-bg:     rgba(255,255,255,0.04);
  --card-border: rgba(255,255,255,0.08);
  --text-dim:    rgba(255,255,255,0.4);
  --text-soft:   rgba(255,255,255,0.65);

  --success: #4ade80;
  --error:   #ff6b6b;
}

html, body { height: 100%; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--navy);
  color: #e8eaf0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Faint grid background used on every page */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(10,147,150,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(10,147,150,0.05) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
  z-index: 0;
}

/* Soft glow blobs — reused on login page */
.blob-top-left {
  position: fixed;
  top: -200px; left: -200px;
  width: 700px; height: 700px;
  background: radial-gradient(circle, rgba(0,120,212,0.12) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}
.blob-bottom-right {
  position: fixed;
  bottom: -200px; right: -200px;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(80,0,180,0.10) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ── 2. Shared chrome (header / footer / env badge) ─────────────── */
.env-badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(255,170,0,0.12);
  color: #ffaa00;
  border: 1px solid rgba(255,170,0,0.25);
}
.env-badge.prod {
  background: rgba(0,212,120,0.12);
  color: #00d478;
  border-color: rgba(0,212,120,0.25);
}

footer {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: rgba(255,255,255,0.2);
  border-top: 1px solid rgba(255,255,255,0.04);
}

/* ── 3. Login page (index.html) ─────────────────────────────────── */
header.login-header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 40px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(8px);
}
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  font-weight: 600;
  color: #ffffff;
}

main.login-main {
  position: relative;
  z-index: 10;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.card {
  width: 100%;
  max-width: 420px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 40px 36px;
  backdrop-filter: blur(16px);
  box-shadow: 0 24px 64px rgba(0,0,0,0.4);
}
.card h1 { font-size: 22px; margin-bottom: 8px; color: #fff; }
.subtitle {
  font-size: 14px;
  color: rgba(255,255,255,0.45);
  margin-bottom: 32px;
  line-height: 1.5;
}
.login-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 20px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  font-family: inherit;
  transition: background 0.2s;
}
.login-btn:hover { background: var(--blue-hover); }
.login-btn:disabled { opacity: 0.55; cursor: not-allowed; }

#status-msg {
  margin-top: 16px;
  font-size: 13px;
  text-align: center;
  min-height: 20px;
  color: rgba(255,255,255,0.45);
}
#status-msg.error   { color: var(--error); }
#status-msg.success { color: var(--success); }

.spinner {
  display: inline-block;
  width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Full-page spinner used on the /auth/callback interstitial */
.callback-wrap {
  min-height: 100vh;
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.spinner-lg {
  width: 36px; height: 36px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 20px;
}
.callback-wrap p { color: rgba(255,255,255,0.5); font-size: 14px; }

/* ── 4. Apps dashboard (apps/index.html) ────────────────────────── */
header.apps-header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 40px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(8px);
  background: rgba(11,30,61,0.7);
}
.header-left { display: flex; align-items: center; gap: 16px; }
.apps-header .logo { font-size: 17px; text-decoration: none; }
.logo-dot {
  width: 8px; height: 8px;
  background: var(--teal);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--teal);
}
.header-divider { width: 1px; height: 20px; background: rgba(255,255,255,0.12); }
.header-title   { font-size: 14px; font-weight: 500; color: var(--text-soft); }
.header-right   { display: flex; align-items: center; gap: 16px; }
.user-info      { display: flex; align-items: center; gap: 10px; }

/* ── Session status badge ───────────────────────────────────────── */
.session-badge {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  font-size: 12px; font-weight: 500;
  color: var(--text-soft);
}
.session-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
  flex-shrink: 0;
}
.session-badge.expiring-soon .session-dot {
  background: #ffaa00;
  box-shadow: 0 0 6px #ffaa00;
}
.session-badge.expiring-soon { color: #ffaa00; border-color: rgba(255,170,0,0.25); }
.session-badge.expired .session-dot {
  background: var(--error);
  box-shadow: 0 0 6px var(--error);
  animation: none;
}
.session-badge.expired { color: var(--error); border-color: rgba(255,107,107,0.25); }
.user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--teal) 0%, #005f73 100%);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: white; flex-shrink: 0;
}
.user-name  { font-size: 13px; font-weight: 500; color: var(--text-soft); }
.user-email { font-size: 11px; color: var(--text-dim); }
.signout-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 7px;
  color: var(--text-soft);
  font-size: 13px; font-family: inherit;
  cursor: pointer; transition: all 0.2s;
}
.signout-btn:hover { background: rgba(255,255,255,0.09); color: #fff; }

main.apps-main {
  position: relative;
  z-index: 10;
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 40px;
}

.welcome-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 36px;
}
.welcome-text h2 {
  font-size: 22px; font-weight: 600;
  color: #fff; letter-spacing: -0.3px; margin-bottom: 4px;
}
.welcome-text p { font-size: 13px; color: var(--text-dim); }

.search-wrap { position: relative; }
.search-input {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 8px;
  padding: 9px 14px 9px 36px;
  color: #fff; font-size: 13px; font-family: inherit;
  width: 240px; outline: none; transition: border-color 0.2s;
}
.search-input::placeholder { color: var(--text-dim); }
.search-input:focus { border-color: rgba(10,147,150,0.4); }
.search-icon {
  position: absolute; left: 11px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim); pointer-events: none;
}

/* ── Environment tabs (role-gated) ──────────────────────────────── */
.env-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.env-tab {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-soft);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 7px 16px;
  cursor: pointer;
  transition: all 0.2s;
}
.env-tab:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.env-tab.active {
  background: rgba(10,147,150,0.16);
  border-color: rgba(10,147,150,0.4);
  color: #fff;
}

/* ── No-access empty state (user has zero environment role assignments) ── */
.no-access {
  display: none;
  flex-direction: column; align-items: center;
  padding: 60px 20px; gap: 6px; text-align: center;
}
.no-access.visible { display: flex; }
.no-access p { font-size: 14px; color: var(--text-dim); }
.no-access .no-access-sub { font-size: 12px; color: rgba(255,255,255,0.25); }

.section-header {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 20px;
}.section-title {
  font-size: 13px; font-weight: 600;
  color: var(--text-soft);
  text-transform: uppercase; letter-spacing: 0.8px;
}
.app-count-badge {
  font-size: 12px; color: var(--text-dim);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.07);
  padding: 3px 10px; border-radius: 20px;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.app-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 22px 20px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  position: relative;
  overflow: hidden;
}
.app-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--teal), transparent);
  opacity: 0; transition: opacity 0.2s;
}
.app-card:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(10,147,150,0.3);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.app-card:hover::before { opacity: 1; }
.app-card.is-hidden { display: none !important; }

.app-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; flex-shrink: 0;
  overflow: hidden;
}
.app-icon-img {
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 6px;
  box-sizing: border-box;
}
.app-icon-fallback {
  display: none; /* shown via JS if the logo image fails to load */
  align-items: center; justify-content: center;
  width: 100%; height: 100%;
}
.app-icon-generic {
  display: block;
}
.app-name {
  font-size: 14px; font-weight: 500;
  color: #fff; line-height: 1.3;
}
.app-desc {
  font-size: 11px; color: var(--text-dim); line-height: 1.4;
}
.app-arrow {
  position: absolute; right: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  opacity: 0; transition: opacity 0.2s, right 0.2s;
}
.app-card:hover .app-arrow { opacity: 1; right: 12px; }

.no-results {
  display: none;
  flex-direction: column; align-items: center;
  padding: 60px 20px; gap: 10px; text-align: center;
}
.no-results.visible { display: flex; }
.no-results p { font-size: 14px; color: var(--text-dim); }

/* ── 5. Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  header.login-header, header.apps-header { padding: 14px 20px; }
  main.login-main { padding: 24px 20px; }
  main.apps-main  { padding: 24px 20px; }
  .welcome-bar { flex-direction: column; align-items: flex-start; gap: 14px; }
  .search-input { width: 100%; }
  .app-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .user-name, .user-email { display: none; }
}
