/*
  Luna UI overrides (Citadel theme)
  Loaded outside Vite to avoid stale cached hashed assets after theme edits.
  Scope: portal pages (NOT store routes).
*/

html.dark { color-scheme: dark; }
html, body { height: 100%; }
body { margin: 0; overflow-x: hidden; }

/* -------------------------------------------------------------------------- */
/* Design tokens                                                              */
/* -------------------------------------------------------------------------- */
body.luna-ui:not(.luna-store) {
  /* Layout */
  --topbar-height: 4rem;   /* 64px */
  --sidebar-width: 18rem;  /* w-72 */
  --gap: 24px;

  /* Accent (back to Citadel purple) */
  --luna-accent: 262 83% 62%;
  --luna-violet: 262 83% 62%;
  --color-primary: var(--luna-violet);

  /* Surfaces (tinted glass) */
  --luna-surface: rgba(8, 10, 18, 0.62);
  --luna-panel: rgba(255, 255, 255, 0.04);
  --luna-panel-2: rgba(255, 255, 255, 0.03);
  --luna-border: rgba(255, 255, 255, 0.08);
  --luna-border-strong: rgba(255, 255, 255, 0.14);

  /* Purple ambience background (single palette, no "bands") */
  background:
    radial-gradient(900px circle at 15% -10%, rgba(120, 90, 255, 0.38), transparent 55%),
    radial-gradient(900px circle at 85% 0%, rgba(70, 160, 255, 0.18), transparent 52%),
    linear-gradient(180deg, #0b1220 0%, #070b14 55%, #060a12 100%);
  background-attachment: fixed;
}

/* -------------------------------------------------------------------------- */
/* App shell                                                                  */
/* -------------------------------------------------------------------------- */
body.luna-ui:not(.luna-store) .luna-page {
  /* Keep the topbar flush to the viewport (no outer padding). */
  padding: 0;
}

body.luna-ui:not(.luna-store) .luna-shell {
  max-width: none;
  margin: 0;
  min-height: 100dvh;

  background:
    radial-gradient(1200px circle at 20% -20%, rgba(120, 90, 255, 0.22), transparent 55%),
    radial-gradient(900px circle at 85% 5%, rgba(70, 160, 255, 0.14), transparent 55%),
    var(--luna-surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);

  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.luna-ui:not(.luna-store) .luna-shell.luna-shell--sidebar {
  max-width: none;
}

/* Topbar: same surface as the rest to avoid banding */
body.luna-ui:not(.luna-store) .luna-topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  height: var(--topbar-height);

  background:
    radial-gradient(900px circle at 18% 0%, rgba(120, 90, 255, 0.16), transparent 62%),
    rgba(10, 12, 20, 0.72) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  box-shadow: none !important;
  backdrop-filter: blur(14px);
}


/* Dropdown panels (notifications, language, currency): glass + transparent */
body.luna-ui:not(.luna-store) .luna-dropdown-panel {
  background: rgba(12, 14, 26, 0.60);
  border: 1px solid rgba(255, 255, 255, 0.10);
  backdrop-filter: blur(14px);
}

/* Main row (sidebar + content) */
body.luna-ui:not(.luna-store) .luna-shell-body {
  display: flex;
  flex: 1 1 auto;
  align-items: stretch;
  min-height: 0;

  padding: var(--gap);
  gap: var(--gap);
}

/* Kill old pseudo-background layers (they created multiple shades/stripes). */
body.luna-ui:not(.luna-store) .luna-shell-body.has-sidebar::before,
body.luna-ui:not(.luna-store) .luna-shell-body.has-sidebar::after {
  content: none !important;
  display: none !important;
}

/* Sidebar panel */
body.luna-ui:not(.luna-store) .luna-sidebar {
  flex: 0 0 var(--sidebar-width);
  min-width: var(--sidebar-width);
  max-width: var(--sidebar-width);

  position: sticky;
  top: calc(var(--topbar-height) + var(--gap));
  height: calc(100dvh - var(--topbar-height) - (var(--gap) * 2));

  /* Don't clip the last items (Logout). Scroll if needed. */
  overflow-x: hidden;
  overflow-y: auto;
  padding-bottom: 10px;

  background:
    radial-gradient(700px circle at 30% 0%, rgba(120, 90, 255, 0.16), transparent 65%),
    var(--luna-panel) !important;
  border: 1px solid var(--luna-border) !important;
  border-radius: 16px;
}

/* Sidebar inner links */
body.luna-ui:not(.luna-store) .luna-sidebar-links {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: auto;
}

/* Do NOT pin account section to the bottom (caused huge empty gap). */
body.luna-ui:not(.luna-store) .luna-side-section--account {
  margin-top: 0;
}

/* Content column */
body.luna-ui:not(.luna-store) .luna-main {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}

/* Keep content readable (align with topbar container width). */
body.luna-ui:not(.luna-store) .luna-container {
  width: 100%;
  max-width: 1560px;
  margin: 0 auto;
}

/* Sidebar layout tends to look better a bit wider on very large screens */
@media (min-width: 1536px) {
  body.luna-ui:not(.luna-store) .luna-container { max-width: 1700px; }
}

/* Footer: minimal + unified with the rest */
body.luna-ui:not(.luna-store) .luna-footer-wrap {
  margin-top: auto;
  padding: 18px 0 0;
  background: transparent !important;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

body.luna-ui:not(.luna-store) .luna-footer-wrap::before {
  content: none !important;
  display: none !important;
}

body.luna-ui:not(.luna-store) .luna-footer-wrap > * {
  max-width: 1560px;
  margin: 0 auto;
}

body.luna-ui:not(.luna-store) .luna-portal-footer {
  background: var(--luna-panel-2) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: 14px;
  padding: 14px 16px;
}

/* -------------------------------------------------------------------------- */
/* Sidebar links look & feel                                                   */
/* -------------------------------------------------------------------------- */
body.luna-ui:not(.luna-store) .luna-profile-card {
  background: var(--luna-panel) !important;
  border: 1px solid var(--luna-border) !important;
  border-radius: 14px;
  padding: 12px;
}

body.luna-ui:not(.luna-store) .luna-profile-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

body.luna-ui:not(.luna-store) .luna-avatar {
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

body.luna-ui:not(.luna-store) .luna-profile-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.luna-ui:not(.luna-store) .luna-profile-email {
  font-size: 12px;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.luna-ui:not(.luna-store) .luna-side-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

body.luna-ui:not(.luna-store) .luna-side-heading {
  padding: 0 8px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.6;
}

body.luna-ui:not(.luna-store) .luna-side-link,
body.luna-ui:not(.luna-store) .luna-accordion-trigger,
body.luna-ui:not(.luna-store) .luna-sub-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  background: transparent;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

body.luna-ui:not(.luna-store) .luna-side-link:hover,
body.luna-ui:not(.luna-store) .luna-accordion-trigger:hover,
body.luna-ui:not(.luna-store) .luna-sub-link:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.08);
}

body.luna-ui:not(.luna-store) .luna-side-link.is-active {
  background: hsl(var(--luna-accent) / 0.14);
  border-color: hsl(var(--luna-accent) / 0.30);
  color: hsl(145 65% 86%);
  box-shadow: 0 0 0 1px hsl(var(--luna-accent) / 0.12), 0 14px 26px rgba(0, 0, 0, 0.25);
}

body.luna-ui:not(.luna-store) .luna-side-link.is-danger:hover {
  background: rgba(244, 63, 94, 0.12);
  border-color: rgba(244, 63, 94, 0.18);
  color: rgba(254, 205, 211, 1);
}

body.luna-ui:not(.luna-store) .luna-ico {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

body.luna-ui:not(.luna-store) .luna-link-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

body.luna-ui:not(.luna-store) .luna-accordion-body {
  margin-top: 6px;
  padding-left: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

body.luna-ui:not(.luna-store) .luna-sub-link {
  padding: 8px 10px;
  font-size: 13px;
  opacity: 0.95;
}

body.luna-ui:not(.luna-store) .luna-sub-empty {
  padding: 8px 10px;
  font-size: 12px;
  opacity: 0.6;
}

/* -------------------------------------------------------------------------- */
/* Panels/cards: remove heavy purple gradients (they made 3 different tones). */
/* -------------------------------------------------------------------------- */
body.luna-ui:not(.luna-store) .bg-background-secondary,
body.luna-ui:not(.luna-store) .luna-profile-card,
body.luna-ui:not(.luna-store) .luna-portal-footer {
  background: var(--luna-panel) !important;
  border-color: var(--luna-border) !important;
}

body.luna-ui:not(.luna-store) .bg-background-secondary:hover,
body.luna-ui:not(.luna-store) .luna-profile-card:hover {
  border-color: var(--luna-border-strong) !important;
}

/* Keep inner dividers subtle (tables/widgets) */
body.luna-ui:not(.luna-store) .divide-neutral\/20 > :not([hidden]) ~ :not([hidden]),
body.luna-ui:not(.luna-store) .border-neutral\/20 {
  border-color: rgba(255, 255, 255, 0.08) !important;
}

/* Top navigation active underline */
body.luna-ui:not(.luna-store) .luna-nav-active { position: relative; }
body.luna-ui:not(.luna-store) .luna-nav-active::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -10px;
  height: 2px;
  background: hsl(var(--luna-accent));
  border-radius: 999px;
  opacity: 0.85;
}

/* Dashboard banner */
body.luna-ui:not(.luna-store) .luna-dashboard-banner {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
body.luna-ui:not(.luna-store) .luna-dashboard-banner__bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: saturate(1.05) contrast(1.05);
  transform: scale(1.02);
}
body.luna-ui:not(.luna-store) .luna-dashboard-banner__overlay {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(124, 58, 237, 0.68) 0%, rgba(6, 10, 18, 0.74) 55%, hsl(var(--luna-accent) / 0.16) 100%);
}
body.luna-ui:not(.luna-store) .luna-dashboard-banner__content {
  position: relative;
  z-index: 2;
  padding: 22px 22px;
}
@media (min-width: 768px) {
  body.luna-ui:not(.luna-store) .luna-dashboard-banner__content { padding: 28px 30px; }
}

/* Guard rails: keep common accidental light classes from breaking portal */
body.luna-ui:not(.luna-store) .bg-white { background-color: rgba(255, 255, 255, 0.06) !important; }
body.luna-ui:not(.luna-store) .text-gray-900,
body.luna-ui:not(.luna-store) .text-slate-900,
body.luna-ui:not(.luna-store) .text-black { color: rgba(255, 255, 255, 0.92) !important; }
body.luna-ui:not(.luna-store) .border-gray-200,
body.luna-ui:not(.luna-store) .border-slate-200 { border-color: rgba(255, 255, 255, 0.10) !important; }

/* Make Tailwind "container" full-width inside the portal (we constrain with .luna-container) */
body.luna-ui:not(.luna-store) .container { max-width: none !important; }

/* -------------------------------------------------------------------------- */
/* Responsive                                                                */
/* -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  body.luna-ui:not(.luna-store) {
    --gap: 18px;
    --sidebar-width: 16rem;
  }
  body.luna-ui:not(.luna-store) .luna-shell-body { padding: var(--gap); gap: var(--gap); }
}

@media (max-width: 767px) {
  body.luna-ui:not(.luna-store) {
    --sidebar-width: 0px;
    --gap: 14px;
  }

  body.luna-ui:not(.luna-store) .luna-shell-body {
    padding: var(--gap);
    gap: var(--gap);
  }

  body.luna-ui:not(.luna-store) .luna-container,
  body.luna-ui:not(.luna-store) .luna-footer-wrap > * {
    max-width: none;
    margin: 0;
  }

  body.luna-ui:not(.luna-store) .luna-footer-wrap {
    padding-top: 14px;
  }
}

/* -------------------------------------------------------------------------- */
/* My Services redesign (kept, but aligned to the new softer surfaces)        */
/* -------------------------------------------------------------------------- */
body.luna-ui:not(.luna-store) .luna-service-card {
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
}

body.luna-ui:not(.luna-store) .luna-service-head {
  padding: 18px 20px;
  background:
    radial-gradient(900px 140px at 18% 0%, rgba(124, 58, 237, 0.20), transparent 60%),
    radial-gradient(720px 140px at 84% 0%, hsl(var(--luna-accent) / 0.12), transparent 55%),
    linear-gradient(180deg, rgba(2, 6, 23, 0.42), rgba(2, 6, 23, 0.12));
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

body.luna-ui:not(.luna-store) .luna-service-meta {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(226, 232, 240, 0.55);
}

body.luna-ui:not(.luna-store) .luna-service-title {
  margin-top: 6px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: rgba(248, 250, 252, 0.95);
}

body.luna-ui:not(.luna-store) .luna-service-sub {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 13px;
  color: rgba(226, 232, 240, 0.70);
}

body.luna-ui:not(.luna-store) .luna-service-status {
  white-space: nowrap;
  padding: 7px 10px;
  border-radius: 999px;
  border-width: 1px;
  font-size: 12px;
  font-weight: 600;
}
/* Service card body + resources + actions (restored) */
body.luna-ui:not(.luna-store) .luna-service-body {
  padding: 16px 20px 18px;
}

body.luna-ui:not(.luna-store) .luna-resource-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

body.luna-ui:not(.luna-store) .luna-resource-item {
  padding: 12px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(2, 6, 23, 0.32);
}

body.luna-ui:not(.luna-store) .luna-resource-label {
  font-size: 11px;
  color: rgba(226, 232, 240, 0.55);
}

body.luna-ui:not(.luna-store) .luna-resource-value {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 700;
  color: rgba(248, 250, 252, 0.92);
}

body.luna-ui:not(.luna-store) .luna-action-row {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

body.luna-ui:not(.luna-store) .luna-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(2, 6, 23, 0.30);
  color: rgba(248, 250, 252, 0.86);
  font-size: 13px;
  font-weight: 600;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease, filter 150ms ease;
}

body.luna-ui:not(.luna-store) .luna-action:hover {
  background: rgba(2, 6, 23, 0.44);
  border-color: rgba(255, 255, 255, 0.16);
  transform: translateY(-1px);
}

body.luna-ui:not(.luna-store) .luna-action[disabled],
body.luna-ui:not(.luna-store) .luna-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

body.luna-ui:not(.luna-store) .luna-action--primary {
  background: hsl(var(--luna-accent));
  border-color: hsl(var(--luna-accent));
  color: rgba(255, 255, 255, 0.96);
}

body.luna-ui:not(.luna-store) .luna-action--primary:hover {
  filter: brightness(1.08);
}

body.luna-ui:not(.luna-store) .luna-action--warning {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.26);
  color: rgba(253, 230, 138, 0.95);
}

body.luna-ui:not(.luna-store) .luna-action--warning:hover {
  background: rgba(245, 158, 11, 0.20);
}

@media (max-width: 1024px) {
  body.luna-ui:not(.luna-store) .luna-resource-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  body.luna-ui:not(.luna-store) .luna-service-head {
    flex-direction: column;
    align-items: flex-start;
  }
  body.luna-ui:not(.luna-store) .luna-resource-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Badges (service cards, etc.) */
body.luna-ui:not(.luna-store) .luna-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:.35rem;
  padding:.28rem .65rem;
  border-radius:9999px;
  font-size:.75rem;
  font-weight:600;
  line-height:1;
  border:1px solid rgba(255,255,255,.14);
  background:rgba(255,255,255,.03);
  color:rgba(255,255,255,.90);
  white-space:nowrap;
}

body.luna-ui:not(.luna-store) .luna-badge--active{
  border-color: hsla(var(--luna-accent), .50);
  background: linear-gradient(180deg, hsla(var(--luna-accent), .18), hsla(var(--luna-accent), .10));
  color: hsl(var(--luna-accent));
  box-shadow: 0 0 0 1px hsla(var(--luna-accent), .10) inset, 0 10px 26px rgba(124, 58, 237, .12);
}

body.luna-ui:not(.luna-store) .luna-badge--warning{
  border-color: rgba(245, 158, 11, .45);
  background: linear-gradient(180deg, rgba(245, 158, 11, .16), rgba(245, 158, 11, .08));
  color: rgba(251, 191, 36, .98);
  box-shadow: 0 0 0 1px rgba(245, 158, 11, .10) inset, 0 10px 26px rgba(245, 158, 11, .08);
}

body.luna-ui:not(.luna-store) .luna-badge--danger{
  border-color: rgba(244, 63, 94, .45);
  background: linear-gradient(180deg, rgba(244, 63, 94, .16), rgba(244, 63, 94, .08));
  color: rgba(251, 113, 133, .98);
  box-shadow: 0 0 0 1px rgba(244, 63, 94, .10) inset, 0 10px 26px rgba(244, 63, 94, .08);
}

body.luna-ui:not(.luna-store) .luna-badge--neutral{
  border-color: rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .04);
  color: rgba(255, 255, 255, .9);
}

body.luna-ui:not(.luna-store) .luna-badge .luna-dot{
  width:.42rem;
  height:.42rem;
  border-radius:9999px;
  background: currentColor;
  opacity:.9;
  box-shadow: 0 0 0 3px rgba(255,255,255,.03), 0 0 0 1px rgba(0,0,0,.20) inset;
}
