/* ====== TOTP Portal — White × Purple UI Refresh ======
   Goals: better contrast/legibility, clean white cards, soft purple accents,
   strong focus states, mobile friendliness, smooth but subtle motion.
======================================================= */

/* ---------- Color System ---------- */
:root {
  /* Brand */
  --brand-600: #6C63FF;  /* primary */
  --brand-500: #7C74FF;
  --brand-400: #8E84FF;  /* secondary */
  --brand-300: #A18CFF;
  --brand-200: #C8BFFF;

  /* Backgrounds */
  --bg-gradient-1: #6C63FF;
  --bg-gradient-2: #A18CFF;
  --page-bg: #f7f7ff;

  /* Surfaces */
  --surface: #ffffff;
  --surface-glass: rgba(255,255,255,0.82);
  --surface-tint: rgba(255,255,255,0.14);
  --surface-stroke: rgba(108, 99, 255, 0.18);

  /* Text */
  --text-900: #0f1221;
  --text-700: #2a2e52;
  --text-500: #626a91;

  /* States */
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;

  /* Shadows */
  --shadow-lg: 0 18px 40px rgba(27, 16, 87, .18);
  --shadow-md: 0 10px 24px rgba(27, 16, 87, .12);

  /* Focus ring */
  --ring: 0 0 0 4px rgba(108, 99, 255, 0.25);
}

/* ---------- Dark Mode ---------- */
.dark {
  --page-bg: #0e1020;
  --surface: #14162a;
  --surface-glass: rgba(20,22,42,0.72);
  --surface-tint: rgba(255,255,255,0.06);
  --surface-stroke: rgba(255,255,255,0.12);

  --text-900: #e9ebff;
  --text-700: #cfd5ff;
  --text-500: #a7add6;

  --shadow-lg: 0 18px 40px rgba(0,0,0,.45);
  --shadow-md: 0 10px 24px rgba(0,0,0,.35);
}

/* ---------- Resets & Base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: 'Poppins', 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text-900);
  background:
    radial-gradient(1200px 700px at 10% -10%, rgba(255,255,255,.55), transparent 60%),
    linear-gradient(135deg, var(--bg-gradient-1), var(--bg-gradient-2));
}

/* Subtle frosting under content for readability */
.gradient {
  min-height: 100%;
  display: flex;
  align-items: center;
  backdrop-filter: saturate(120%) blur(0px);
}

/* Container & Typography scale */
.container { width: 100%; max-width: 1150px; margin: 0 auto; padding: 28px; }
h1,h2,h3 { margin: 0 0 10px; line-height: 1.2; }
h1.brand { font-size: clamp(20px, 2.2vw, 26px); letter-spacing: .2px; font-weight: 700; }
h2 { font-size: clamp(18px, 1.8vw, 22px); color: var(--text-700); }

/* ---------- Top Nav ---------- */
.nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.nav-actions { display: flex; gap: 10px; align-items: center; }

/* ---------- Cards (white, elevated, glass edge) ---------- */
.card {
  background: var(--surface);
  border-radius: 18px;
  border: 1px solid var(--surface-stroke);
  box-shadow: var(--shadow-lg);
  padding: 20px;
  margin-bottom: 18px;
  position: relative;
  overflow: clip;
}
.card.glass {
  background: linear-gradient(180deg, var(--surface-glass), var(--surface)) border-box;
}
.card:before {
  /* glossy edge */
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(135deg, rgba(255,255,255,.65), rgba(255,255,255,0) 35%),
    linear-gradient(315deg, rgba(255,255,255,.25), rgba(255,255,255,0) 40%);
  opacity: .35; pointer-events: none;
}

/* Motion */
@media (prefers-reduced-motion: no-preference) {
  .card { animation: floatIn .45s ease both; }
  @keyframes floatIn { from { transform: translateY(8px); opacity:0; } to { transform: translateY(0); opacity:1; } }
}

/* ---------- Grid ---------- */
.grid { display: grid; grid-template-columns: 1fr; gap: 18px; }
@media (min-width: 920px) { .grid { grid-template-columns: 1fr 1fr; } }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 12px; }
.form.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.col-span-2 { grid-column: span 2; }

label { font-size: 12px; color: var(--text-500); font-weight: 600; }
.form input, .form select {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--surface-stroke);
  background: #fff;
  color: var(--text-900);
  outline: none;
  transition: box-shadow .15s ease, border-color .15s ease, background .15s ease;
}
.dark .form input, .dark .form select {
  background: rgba(255,255,255,0.06);
  color: var(--text-900);
}
.form input::placeholder { color: #9aa3c7; }

.form input:focus, .form select:focus {
  border-color: var(--brand-400);
  box-shadow: var(--ring);
}

/* ---------- Buttons ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer;
  border-radius: 12px; padding: 12px 16px;
  font-weight: 700; letter-spacing: .2px;
  background: var(--brand-600); color: #fff;
  box-shadow: 0 10px 24px rgba(108,99,255,0.35);
  transition: transform .08s ease, box-shadow .2s ease, filter .2s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 14px 28px rgba(108,99,255,0.45); }
.btn:active { transform: translateY(0); filter: brightness(.98); }

.btn.primary { background: linear-gradient(135deg, var(--brand-600), var(--brand-400)); }
.btn.secondary { background: linear-gradient(135deg, var(--brand-400), var(--brand-300)); }
.btn.ghost {
  background: transparent; color: var(--brand-200);
  border: 1px solid var(--surface-stroke); box-shadow: none;
}
.btn.danger { background: linear-gradient(135deg, #f43f5e, #ef4444); box-shadow: 0 12px 26px rgba(239,68,68,.35); }
.btn.small { padding: 8px 12px; font-size: 12px; }
.nowrap { white-space: nowrap; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 10px; margin-bottom: 12px; }
.tab {
  background: rgba(108,99,255,0.08);
  border: 1px solid var(--surface-stroke);
  color: var(--text-700);
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  font-weight: 600;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.tab:hover { background: rgba(108,99,255,0.12); }
.tab.active {
  background: linear-gradient(180deg, rgba(255,255,255,0.65), rgba(255,255,255,0.35));
  color: var(--brand-600);
  border-color: rgba(108,99,255,0.35);
  box-shadow: inset 0 0 0 1px rgba(108,99,255,0.12);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---------- Tables ---------- */
.responsive-table { overflow:auto; border-radius: 14px; border:1px solid var(--surface-stroke); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
thead th {
  position: sticky; top: 0; z-index: 1;
  background: linear-gradient(180deg, #ffffff, #fafaff);
  color: var(--text-500);
  text-align: left; font-weight: 700; padding: 12px 14px;
  border-bottom: 1px solid var(--surface-stroke);
}
tbody td {
  padding: 11px 14px; border-bottom: 1px solid rgba(108,99,255,0.12);
}
tbody tr:nth-child(even) td { background: rgba(108,99,255,0.03); }
tbody tr:hover td { background: rgba(108,99,255,0.06); }
td code { font-weight: 800; letter-spacing: 2px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.link-btn {
  background: transparent; border: none; color: var(--brand-600);
  text-decoration: underline; cursor: pointer; font-weight: 700;
}
.inline-form { display: inline-flex; gap: 8px; align-items: center; margin-left: 8px; }

/* ---------- Secret + OTP row ---------- */
.secret { font-family: 'Inter', ui-monospace, SFMono-Regular, Menlo, monospace; }
.bar {
  width: 110px; height: 7px; background: rgba(108,99,255,0.18);
  border-radius: 999px; overflow: hidden; display: inline-block; margin-left: 8px; vertical-align: middle;
}
.bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--brand-400), var(--brand-600));
  transition: width .3s linear;
}

/* ---------- Footer ---------- */
.footer { text-align: center; color: var(--text-500); margin-top: 10px; font-size: 13px; }

/* ---------- Utility ---------- */
.role-pill {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  background: rgba(108,99,255,.09); color: var(--brand-600); font-weight: 700; font-size: 12px;
  border: 1px solid rgba(108,99,255,.18);
}

/* ---------- Accessibility ---------- */
:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:focus-visible, .tab:focus-visible, input:focus-visible, select:focus-visible { box-shadow: var(--ring); }

/* ---------- Mobile Tweaks ---------- */
@media (max-width: 520px) {
  .container { padding: 18px; }
  .nav { margin-bottom: 12px; }
  .btn.small { font-size: 11.5px; padding: 7px 10px; }
  thead th { font-size: 12.5px; }
  tbody td { font-size: 13.5px; padding: 10px 12px; }
}
