/* ==========================================================================
   Samanyastra Identity Console — stylesheet
   Sections:
     1.  Tokens (light + dark)
     2.  Reset & base
     3.  Typography
     4.  Top navigation
     5.  Auth split layout + brand panel
     6.  Console layout shells
     7.  Alerts
     8.  Forms + password toggle
     9.  Buttons
    10.  Cards & grid
    11.  App tiles (my-apps)
    12.  Badges & status pills
    13.  App-row (onboarding)
    14.  Tag list
    15.  Stat tile
    16.  Link pills
    17.  Empty state
    18.  Utility
    19.  Responsive & motion
   ========================================================================== */


/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
:root {
  color-scheme: light dark;

  /* Palette — light. Sourced from the Samanyastra BrandColors token set
     (colors.grey / colors.white / colors.divider / colors.ebony). */
  --bg:           #F9FAFB;  /* grey.50 */
  --bg-tint:      #F0F0F0;  /* grey.25 */
  --surface:      #ffffff;  /* colors.white */
  --surface-2:    #F9FAFB;  /* grey.50 */
  --surface-3:    #E5E7EB;  /* grey.100 */
  --border:       #D1D5DB;  /* colors.divider */
  --border-strong:#9CA3AF;  /* grey.400 */

  /* Text — text.default / text.secondary / colors.ebony */
  --text:         #111827;  /* colors.ebony — headings, high emphasis */
  --text-sub:     #4B5563;  /* text.default (grey.600) — body copy */
  --text-dim:     #6B7280;  /* text.secondary (grey.500) — muted/meta */

  /* Brand / primary — colors.primary */
  --primary:      #4F46E5;  /* colors.primary.main */
  --primary-dark: #4338CA;  /* no darker shade in the palette — standard indigo-700 for hover/active */
  --primary-soft: #E5D9FA;  /* colors.primary[100] */
  --primary-text: #ffffff;
  --accent:       #9333EA;  /* colors.purple[600] */
  --ring:         #4F46E533; /* colors.primary[20] */

  /* Semantic — colors.green / colors.yellow / colors.blue.
     No red exists in the brand palette; danger/error kept as a standard red
     since error states need to read as unambiguously negative. */
  --success-bg:   #DCFCE7;  --success-border: #86EFAC; --success-text: #16A34A; /* green.50/200/600 */
  --warn-bg:      #FEF9C3;  --warn-border:    #FDE68A;  --warn-text:    #B45309; /* yellow.50/175/700 */
  --danger-bg:    #fef2f2;  --danger-border:  #fecaca;  --danger-text:  #dc2626;
  --info-bg:      #BFDBFE;  --info-border:    #93C5FD;  --info-text:    #2563EB; /* blue.100/200/600 */

  /* Shape */
  --radius-lg:    18px;
  --radius:       12px;
  --radius-sm:    8px;
  --radius-full:  999px;

  /* Shadow */
  --shadow-xs: 0 1px 2px rgba(17,24,39,.06);
  --shadow-sm: 0 1px 3px rgba(17,24,39,.08), 0 1px 2px rgba(17,24,39,.04);
  --shadow-md: 0 8px 24px rgba(17,24,39,.10), 0 2px 6px rgba(17,24,39,.05);
  --shadow-lg: 0 24px 60px rgba(17,24,39,.16), 0 8px 20px rgba(17,24,39,.08);

  --brand-gradient: linear-gradient(150deg, #4F46E5 0%, #9333EA 55%, #776AEA 100%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:           #0b1020;
    --bg-tint:      #0e1424;
    --surface:      #141b2e;
    --surface-2:    #1a2338;
    --surface-3:    #202b45;
    --border:       #26314b;
    --border-strong:#33405f;

    --text:         #eef2fb;
    --text-sub:     #a6b2c9;
    --text-dim:     #6f7d97;

    --primary:      #7c74ff;
    --primary-dark: #6a61f0;
    --primary-soft: #1e2340;
    --primary-text: #ffffff;
    --accent:       #a78bfa;
    --ring:         rgba(124,116,255,.28);

    --success-bg:   #08251c;  --success-border: #14532d; --success-text: #6ee7b7;
    --warn-bg:      #2a1f06;  --warn-border:    #78350f;  --warn-text:    #fcd34d;
    --danger-bg:    #2a1013;  --danger-border:  #7f1d1d;  --danger-text:  #fca5a5;
    --info-bg:      #0c1c38;  --info-border:    #1e3a8a;  --info-text:    #93c5fd;

    --shadow-xs: 0 1px 2px rgba(0,0,0,.4);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.45), 0 1px 2px rgba(0,0,0,.3);
    --shadow-md: 0 10px 30px rgba(0,0,0,.55);
    --shadow-lg: 0 28px 70px rgba(0,0,0,.65);
  }
}


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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color .15s ease;
}
a:hover { color: var(--primary-dark); text-decoration: underline; }

ul { padding-left: 18px; }
li { margin-bottom: 2px; }

::selection { background: var(--ring); }


/* --------------------------------------------------------------------------
   3. Typography
   -------------------------------------------------------------------------- */
h1 { font-size: 24px; font-weight: 750; letter-spacing: -0.4px; color: var(--text); }
h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.2px; color: var(--text); }
h3 { font-size: 15px; font-weight: 650; color: var(--text); }
h4 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-dim);
  margin-bottom: 7px;
}

p { color: var(--text-sub); }

.text-sm    { font-size: 13px; }
.text-muted { color: var(--text-sub); }
.text-dim   { color: var(--text-dim); }
.mono       { font-family: ui-monospace, "SF Mono", Menlo, monospace; }

.page-title { margin-bottom: 4px; }
.page-sub   { margin-bottom: 26px; color: var(--text-sub); }


/* --------------------------------------------------------------------------
   4. Top navigation
   -------------------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 58px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(150%) blur(10px);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 22px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-mark { display: flex; align-items: center; gap: 10px; }

.brand-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
}

.brand-name { font-weight: 700; font-size: 15px; color: var(--text); letter-spacing: -0.2px; }
.brand-sub  { font-size: 12px; color: var(--text-dim); margin-left: 5px; font-weight: 500; }

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

.topbar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-sub);
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}


/* --------------------------------------------------------------------------
   5. Auth split layout + brand panel
   -------------------------------------------------------------------------- */
.auth-layout {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  min-height: 100dvh;
}

/* Left — branded panel */
.auth-brand {
  position: relative;
  overflow: hidden;
  background: var(--brand-gradient);
  color: #fff;
  padding: 56px 56px 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.auth-brand::before,
.auth-brand::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,.10);
  pointer-events: none;
}
.auth-brand::before { width: 460px; height: 460px; top: -160px; right: -140px; }
.auth-brand::after  { width: 300px; height: 300px; bottom: -120px; left: -90px; background: rgba(255,255,255,.07); }

.auth-brand > * { position: relative; z-index: 1; }

.auth-brand-logo {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.2px;
}

.auth-brand-headline { max-width: 30ch; }
.auth-brand-headline h2 {
  color: #fff;
  font-size: 30px;
  line-height: 1.2;
  font-weight: 750;
  letter-spacing: -0.6px;
  margin-bottom: 14px;
}
.auth-brand-headline p { color: rgba(255,255,255,.82); font-size: 15px; line-height: 1.6; }

.auth-features { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 15px; }
.auth-features li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 14px;
  color: rgba(255,255,255,.92);
  margin: 0;
}
.auth-features .tick {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: rgba(255,255,255,.16);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}
.auth-features .tick svg { width: 14px; height: 14px; stroke: #fff; }

.auth-brand-foot { font-size: 12px; color: rgba(255,255,255,.65); }

/* Right — form panel */
.auth-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  animation: card-in .45s cubic-bezier(.16,1,.3,1);
}

/* Small logo shown above the card on narrow screens */
.auth-card-logo { display: none; align-items: center; gap: 10px; margin-bottom: 24px; }

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}


/* --------------------------------------------------------------------------
   6. Console layout shells
   -------------------------------------------------------------------------- */
.app-shell {
  max-width: 1180px;
  margin: 30px auto;
  padding: 0 22px 56px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}
.page-header-text h1 { margin-bottom: 3px; }
.page-header-text p  { margin: 0; }
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 22px 0;
}


/* --------------------------------------------------------------------------
   7. Alerts
   -------------------------------------------------------------------------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid;
  margin-bottom: 18px;
  font-size: 13px;
  line-height: 1.5;
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }

.alert-info    { background: var(--info-bg);    color: var(--info-text);    border-color: var(--info-border);    }
.alert-success { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.alert-warn    { background: var(--warn-bg);    color: var(--warn-text);    border-color: var(--warn-border);    }
.alert-danger  { background: var(--danger-bg);  color: var(--danger-text);  border-color: var(--danger-border);  }


/* --------------------------------------------------------------------------
   8. Forms + password toggle
   -------------------------------------------------------------------------- */
.field { margin-bottom: 17px; }

form p           { margin-bottom: 17px; }
form p > label,
.field > label   {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
select,
textarea {
  display: block;
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }

input:hover, select:hover, textarea:hover { border-color: var(--primary); }

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--ring);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238494a8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
}

.helptext {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 5px;
  line-height: 1.5;
}

.errorlist {
  list-style: none;
  padding: 0;
  font-size: 12px;
  color: var(--danger-text);
  margin-top: 5px;
  font-weight: 500;
}

/* Password reveal toggle (progressively enhanced via JS) */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px; }
.pw-toggle {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 42px;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.pw-toggle:hover { color: var(--text); }
.pw-toggle svg { width: 18px; height: 18px; }


/* --------------------------------------------------------------------------
   9. Buttons
   -------------------------------------------------------------------------- */
.btn,
button[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
  transition: transform .08s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease, color .15s ease;
}
.btn:active,
button[type="submit"]:active { transform: translateY(1px); }

.btn-primary,
button[type="submit"] {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
  box-shadow: 0 2px 8px var(--ring);
}
.btn-primary:hover,
button[type="submit"]:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: var(--primary-text);
  text-decoration: none;
  box-shadow: 0 4px 14px var(--ring);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover {
  background: var(--surface-2);
  border-color: var(--primary);
  color: var(--text);
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-sub);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

.btn-sm   { padding: 6px 12px; font-size: 13px; }
.btn-full { width: 100%; }

.btn-row { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 22px; }


/* --------------------------------------------------------------------------
   10. Cards & grid
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}
.card + .card { margin-top: 12px; }

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.card-header h3 { margin: 0; }
.card-body      { color: var(--text-sub); }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }


/* --------------------------------------------------------------------------
   11. App tiles (my-apps)
   -------------------------------------------------------------------------- */
.app-tile {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.app-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
  text-decoration: none;
  color: inherit;
}
.app-tile .app-tile-body { min-width: 0; flex: 1; }
.app-tile h3 {
  margin: 0 0 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-tile .app-id { font-size: 12px; }

.app-tile-disabled {
  cursor: default;
  opacity: .7;
}
.app-tile-disabled:hover {
  transform: none;
  box-shadow: var(--shadow-sm);
  border-color: var(--border);
}
.app-tile-hint {
  display: block;
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 2px;
}

.app-avatar {
  width: 48px;
  height: 48px;
  border-radius: 13px;
  background: var(--brand-gradient);
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px var(--ring);
}


/* --------------------------------------------------------------------------
   12. Badges & status pills
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid;
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.badge-green { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.badge-amber { background: var(--warn-bg);    color: var(--warn-text);    border-color: var(--warn-border);    }
.badge-blue  { background: var(--info-bg);    color: var(--info-text);    border-color: var(--info-border);    }
.badge-red   { background: var(--danger-bg);  color: var(--danger-text);  border-color: var(--danger-border);  }


/* --------------------------------------------------------------------------
   13. App-row (onboarding dashboard)
   -------------------------------------------------------------------------- */
.app-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .16s ease, border-color .16s ease;
}
.app-row:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.app-row + .app-row { margin-top: 12px; }

.app-row-head {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.app-logo {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--primary-soft);
  border: 1px solid var(--border);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.app-logo svg { width: 20px; height: 20px; }

.app-meta h3  { margin: 0 0 2px; font-size: 15px; }
.app-id       { font-size: 12px; color: var(--text-dim); font-family: ui-monospace, "SF Mono", Menlo, monospace; }

.app-cols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}


/* --------------------------------------------------------------------------
   14. Tag list
   -------------------------------------------------------------------------- */
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

.tag {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-sub);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}


/* --------------------------------------------------------------------------
   15. Stat tile
   -------------------------------------------------------------------------- */
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
.stat-tile .stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.stat-tile .stat-value { font-size: 30px; font-weight: 800; color: var(--text); letter-spacing: -0.5px; }
.stat-tile .stat-sub   { font-size: 12px; color: var(--text-sub); margin-top: 3px; }


/* --------------------------------------------------------------------------
   16. Link pills
   -------------------------------------------------------------------------- */
.link-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

.link-pill {
  font-size: 12px;
  font-weight: 500;
  color: var(--primary);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--radius-full);
  padding: 6px 14px;
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease;
}
.link-pill:hover { background: var(--primary-soft); border-color: var(--primary); text-decoration: none; }


/* --------------------------------------------------------------------------
   17. Empty state
   -------------------------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 52px 24px;
}
.empty-state .empty-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 16px;
  border-radius: 16px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.empty-state .empty-icon svg { width: 28px; height: 28px; }
.empty-state h2 { margin-bottom: 8px; }
.empty-state p  { max-width: 42ch; margin: 0 auto; }


/* --------------------------------------------------------------------------
   18. Utility
   -------------------------------------------------------------------------- */
.mt-0  { margin-top: 0 !important; }
.mb-0  { margin-bottom: 0 !important; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.center { text-align: center; }


/* --------------------------------------------------------------------------
   19. Responsive & motion
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-brand  { display: none; }
  .auth-card-logo { display: flex; }
}

@media (max-width: 600px) {
  .auth-main   { padding: 28px 18px; }
  .app-cols    { grid-template-columns: 1fr; }
  .topbar-inner { padding: 0 14px; }
  .app-shell   { padding: 0 14px 36px; }
  .topbar-user span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}
