/* Windows 11 Fluent-inspired styling (light + dark) */
:root {
  --accent: #2563eb;
  --accent-hover: #007f7f;
  --danger: #dc2626;
  --warning: #d97706;
  --success: #059669;
  --text-color: #1a1a1a;
  --text-color-subtle: #444;
  --surface: rgba(255, 255, 255, 0.75);
  --surface-alt: rgba(255, 255, 255, 0.55);
  --mica-tint: 210 25% 98%;
  --border-color: rgba(0, 0, 0, 0.08);
  --radius-s: 6px;
  --radius-m: 12px;
  --radius-l: 20px;
  --focus-ring: 0 0 0 2px #fff, 0 0 0 4px var(--accent);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
  --shadow-2: 0 4px 12px rgba(0, 0, 0, 0.12), 0 2px 4px rgba(0, 0, 0, 0.06);
  --transition-fast: 120ms cubic-bezier(.4, 0, .2, 1);
}

:root {
  --accent: #2563eb;
  --accent-hover: #007f7f;
  --accent-rgb: 37, 99, 235;
  --danger: #dc2626;
  --warn: #d97706;
  --success: #059669;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --surface-glass: rgba(255, 255, 255, 0.55);
  --surface-glass-alt: rgba(255, 255, 255, 0.38);
  --border-color: rgba(0, 0, 0, 0.08);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px -3px rgba(0, 0, 0, 0.14), 0 2px 4px -2px rgba(0, 0, 0, 0.10);
  --ease-standard: cubic-bezier(.4, 0, .2, 1);
  --focus-ring: 0 0 0 3px rgba(var(--accent-rgb), 0.33);
  --font-sans: 'Segoe UI Variable', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  --surface-warm-base: #fffaf6;
  --surface-warm-alt: #fff3ec;
  --surface-warm-soft: #ffe9df;
}

/* Accessible focus ring refinement */
:where(a, button, input, select, textarea, .btn-win11, [role="button"])::selection {
  background: var(--accent);
  color: #fff;
}

:where(a, button, input, select, textarea, .btn-win11, [role="button"]):focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* High contrast mode (forced-colors) tweak */
@media (forced-colors: active) {

  .btn-win11,
  .win11-input,
  .win11-select,
  .win11-textarea {
    border: 1px solid CanvasText;
    background: Canvas;
    color: CanvasText;
  }
}

/* Improve contrast for danger/warning chips */
.win11-chip[data-flag="risk-danger"],
.chip-danger {
  background: color-mix(in srgb, var(--danger) 35%, var(--surface));
  color: #fff;
}

.win11-chip[data-flag="risk-warning"],
.chip-warning {
  background: color-mix(in srgb, var(--warning) 35%, var(--surface));
  color: #1a1a1a;
}

/* Reduced motion: turn off shimmer animation */
@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
    background-size: 100% 100%;
  }
}

html {
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, Ubuntu, sans-serif;
  font-size: 15px;
}

body.win11 {
  color: var(--text-color);
  background: linear-gradient(125deg, hsl(var(--mica-tint)) 0%, hsl(var(--mica-tint) / 0.85) 35%, hsl(var(--mica-tint) / 0.6) 100%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Soft layered background for main content wrapper */
body.win11 main#app-root {
  /* Warm Windows 11 inspired luminous backdrop */
  background:
    radial-gradient(circle at 28% 22%, rgba(255, 198, 140, 0.55), rgba(255, 198, 140, 0) 60%),
    radial-gradient(circle at 78% 72%, rgba(255, 170, 125, 0.42), rgba(255, 170, 125, 0) 65%),
    linear-gradient(135deg, #fff8f2 0%, #ffe9d9 38%, #ffe1cc 60%, #ffd7bd 100%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  backdrop-filter: blur(22px) saturate(150%);
}

body.win11 main#app-root {
  /* Subtler warm luminous backdrop (reduced saturation & opacity) */
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 190, 130, 0.28), rgba(255, 190, 130, 0) 62%),
    radial-gradient(circle at 76% 74%, rgba(255, 158, 110, 0.22), rgba(255, 158, 110, 0) 66%),
    linear-gradient(135deg, var(--surface-warm-base) 0%, var(--surface-warm-alt) 45%, var(--surface-warm-soft) 85%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  backdrop-filter: blur(20px) saturate(140%);
}

/* Soft refined acrylic sidebar background layering */
body.win11 aside#sidebar.acrylic-sidebar {
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.75), rgba(255, 245, 235, 0.55)) padding-box,
    radial-gradient(circle at 25% 18%, rgba(255, 195, 140, 0.38), transparent 65%),
    radial-gradient(circle at 80% 78%, rgba(255, 170, 125, 0.32), transparent 60%);
  position: relative;
}

body.win11 aside#sidebar.acrylic-sidebar {
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.68), rgba(255, 245, 235, 0.48)) padding-box,
    radial-gradient(circle at 26% 20%, rgba(255, 190, 135, 0.28), transparent 66%),
    radial-gradient(circle at 78% 80%, rgba(255, 160, 120, 0.24), transparent 62%);
  position: relative;
}

body.win11 aside#sidebar.acrylic-sidebar::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: overlay;
  opacity: .28;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.12) 0 2px, rgba(255, 255, 255, 0) 2px 6px);
}

/* Unified font across the application (inherit from root variable) */
body,
body * {
  font-family: var(--font-sans) !important;
}

/* Allow icon fonts (Font Awesome etc.) to keep their own font-family */
body i.fas,
body i.far,
body i.fal,
body i.fab,
body i.fa,
body span.fa,
body [class^="fa-"],
body [class*=" fa-"] {
  font-family: var(--fa-style-family, "Font Awesome 6 Free") !important;
  font-weight: var(--fa-style, 900);
}

/* Convert hard bg-white surfaces to translucent warm glass on win11 pages (exclude explicit login/index by absence of .win11) */
body.win11 .bg-white {
  background: rgba(255, 255, 255, 0.62) !important;
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
}

body.win11 .bg-white.shadow-xl,
body.win11 .bg-white.shadow-2xl,
body.win11 .bg-white.shadow {
  background: rgba(255, 255, 255, 0.58) !important;
}

/* Pagination & small interactive white pills soften */
body.win11 a.bg-white,
body.win11 button.bg-white,
body.win11 [class*='bg-white/'] {
  background: rgba(255, 255, 255, 0.55) !important;
}

body.win11 a.bg-white:hover,
body.win11 button.bg-white:hover,
body.win11 [class*='bg-white/']:hover {
  background: rgba(255, 255, 255, 0.70) !important;
}

/* Modal panels keep slightly higher opacity */
body.win11 [data-modal-panel].bg-white {
  background: rgba(255, 255, 255, 0.75) !important;
}

/* --------------------------------------------------
     Panel Utility System
     .panel        - default translucent surface
     .panel--hero  - elevated, larger padding & subtle border glow
     .panel--sub   - denser variant for nested sections
  -------------------------------------------------- */
body.win11 .panel {
  position: relative;
  background: rgba(255, 255, 255, 0.60);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 16px;
  padding: 1.5rem 1.75rem;
  box-shadow: 0 2px 6px -2px rgba(0, 0, 0, 0.12), 0 4px 18px -6px rgba(0, 0, 0, 0.10);
}

body.win11 .panel--hero {
  padding: 2.25rem 2.5rem;
  border-radius: 22px;
  box-shadow: 0 6px 24px -4px rgba(0, 0, 0, 0.18), 0 2px 8px -2px rgba(0, 0, 0, 0.12);
}

body.win11 .panel--hero::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0));
  mix-blend-mode: overlay;
  opacity: .55;
}

body.win11 .panel--sub {
  padding: 1rem 1.1rem;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.10);
}

/* Density helpers */
body.win11 .panel.pad-sm {
  padding: 1rem 1.1rem;
}

body.win11 .panel.pad-lg {
  padding: 2.75rem 3rem;
}

/* --------------------------------------------------
     Chip Utility System
     Usage: .chip + modifiers (.chip--status-success, .chip--risk, etc.)
  -------------------------------------------------- */
body.win11 .chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: 10px;
  line-height: 1;
  font-weight: 600;
  padding: .35rem .6rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.55);
  -webkit-backdrop-filter: blur(8px) saturate(140%);
  backdrop-filter: blur(8px) saturate(140%);
  letter-spacing: .3px;
}

body.win11 .chip i {
  font-size: 10px;
}

body.win11 .chip--pill {
  padding: .40rem .75rem;
}

body.win11 .chip--tight {
  padding: .25rem .5rem;
}

body.win11 .chip--status-success {
  background: linear-gradient(145deg, #ecfdf5, #d1fae5);
  color: #065f46;
  border-color: #6ee7b7;
}

body.win11 .chip--status-warn {
  background: linear-gradient(145deg, #fefce8, #fef3c7);
  color: #92400e;
  border-color: #fcd34d;
}

body.win11 .chip--status-danger {
  background: linear-gradient(145deg, #fef2f2, #fee2e2);
  color: #991b1b;
  border-color: #fca5a5;
}

body.win11 .chip--status-info {
  background: linear-gradient(145deg, #eff6ff, #dbeafe);
  color: #1e3a8a;
  border-color: #93c5fd;
}

body.win11 .chip--risk {
  background: linear-gradient(140deg, #faf5ff, #f3e8ff);
  color: #6b21a8;
  border-color: #d8b4fe;
}

/* New Phase 2 variants */
body.win11 .chip--xs {
  font-size: 9px;
  padding: .25rem .45rem;
  gap: .25rem;
}

body.win11 .chip--status-neutral {
  background: linear-gradient(145deg, #f5f5f5, #ececec);
  color: #374151;
  border-color: #d1d5db;
}

body.win11 .chip--risk-active {
  background: linear-gradient(145deg, #fff1f2, #ffe4e6);
  color: #b91c1c;
  border-color: #fda4af;
}

body.win11 .chip--risk-inactive {
  background: linear-gradient(145deg, #f3f4f6, #e5e7eb);
  color: #6b7280;
  border-color: #d1d5db;
}

/* --------------------------------------------------
     Powder / Baby Blue Variant (optional)
     Activate by adding class 'theme-powder' to body (alongside win11)
  -------------------------------------------------- */
body.win11.theme-powder main#app-root {
  background:
    radial-gradient(circle at 32% 24%, rgba(180, 210, 255, 0.30), rgba(180, 210, 255, 0) 62%),
    radial-gradient(circle at 78% 76%, rgba(160, 200, 255, 0.22), rgba(160, 200, 255, 0) 66%),
    linear-gradient(135deg, #f6f9fe 0%, #eef5fd 45%, #e6effc 85%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  backdrop-filter: blur(20px) saturate(140%);
}

body.win11.theme-powder aside#sidebar.acrylic-sidebar {
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.70), rgba(245, 250, 255, 0.50)) padding-box,
    radial-gradient(circle at 26% 18%, rgba(170, 205, 255, 0.35), transparent 60%),
    radial-gradient(circle at 78% 80%, rgba(150, 190, 255, 0.28), transparent 58%);
}

/* Powder variant softens white panels just a touch cooler */
body.win11.theme-powder .bg-white {
  background: rgba(255, 255, 255, 0.70) !important;
}

/* --------------------------------------------------
     Action Icon Hover / Focus Glow
     Applies to icons inside buttons / links with accent or primary intent
  -------------------------------------------------- */
body.win11 .btn i.fas,
body.win11 .btn i.fa,
body.win11 a i.fas,
body.win11 a i.fa {
  transition: color .18s var(--ease-standard), text-shadow .25s var(--ease-standard), transform .25s var(--ease-standard);
}

body.win11 .btn:hover i.fas,
body.win11 .btn:hover i.fa,
body.win11 a:hover i.fas,
body.win11 a:hover i.fa,
body.win11 .btn:focus-visible i.fas,
body.win11 .btn:focus-visible i.fa,
body.win11 a:focus-visible i.fas,
body.win11 a:focus-visible i.fa {
  text-shadow: 0 0 4px rgba(var(--accent-rgb), 0.55), 0 0 10px rgba(var(--accent-rgb), 0.35);
  transform: translateY(-1px);
}

@media (prefers-reduced-motion: reduce) {

  body.win11 .btn i.fas,
  body.win11 .btn i.fa,
  body.win11 a i.fas,
  body.win11 a i.fa {
    transition: color .18s var(--ease-standard);
  }

  body.win11 .btn:hover i.fas,
  body.win11 .btn:hover i.fa,
  body.win11 a:hover i.fas,
  body.win11 a:hover i.fa {
    transform: none;
  }
}

@supports not (backdrop-filter: blur(18px)) {
  body.win11 {
    background: hsl(var(--mica-tint));
  }
}

/* Cards / Surfaces */
.win11-surface {
  background: var(--surface);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-1);
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

.win11-surface.hoverable:hover {
  box-shadow: var(--shadow-2);
}

.win11-surface.dense {
  border-radius: var(--radius-m);
}

/* Buttons */
.btn-win11 {
  --btn-bg: var(--surface-alt);
  --btn-border: var(--border-color);
  --btn-color: var(--text-color);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  line-height: 1;
  gap: .5rem;
  padding: .65rem 1.1rem;
  border-radius: var(--radius-m);
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform 40ms;
}

.btn-win11:hover {
  background: rgba(255, 255, 255, 0.9);
}

.btn-win11:active {
  transform: translateY(1px);
}

.btn-accent {
  --btn-bg: var(--accent);
  --btn-border: var(--accent);
  --btn-color: #fff;
  color: #fff;
}

.btn-accent:hover {
  background: var(--accent-hover);
}

.btn-accent:active {
  background: var(--accent-active);
}

.btn-danger {
  --btn-bg: var(--danger);
  --btn-border: var(--danger);
  --btn-color: #fff;
  color: #fff;
}

.btn-outline {
  background: transparent;
}

.btn-outline:hover {
  background: var(--surface-alt);
}

.btn-win11:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Inputs */
.win11-input,
.win11-select,
.win11-textarea {
  width: 100%;
  border: 1px solid var(--border-color);
  background: var(--surface-alt);
  border-radius: var(--radius-m);
  padding: .55rem .75rem;
  font: inherit;
  color: var(--text-color);
  transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

.win11-input:focus-visible,
.win11-select:focus-visible,
.win11-textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 60%, transparent);
}

/* Toggle group & chips */
.win11-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .75rem;
  font-weight: 500;
  padding: .35rem .6rem;
  border-radius: var(--radius-s);
  background: var(--surface-alt);
  background: color-mix(in srgb, var(--accent) 15%, var(--surface));
  border: 1px solid var(--border-color);
  /* Fallback: removed color-mix for broader support */
  color: var(--text-color-subtle);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  backdrop-filter: blur(20px) saturate(140%);
}

.win11-chip[data-flag="risk"] {
  background: var(--surface-alt);
}

/* Shimmer Skeleton */
.skeleton {
  position: relative;
  overflow: hidden;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.18) 0%, rgba(255, 255, 255, 0.32) 50%, rgba(255, 255, 255, 0.18) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
  }
}

/* Ghost Add Card */
.add-profile-ghost {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-l);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  gap: .75rem;
  cursor: pointer;
  background: var(--surface-alt);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.add-profile-ghost:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}

.add-profile-ghost:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Command bar / header */
.win11-toolbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-l);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
}

/* Collapsible flag section */
.flag-toggle-btn {
  font-size: .75rem;
  font-weight: 500;
  background: transparent;
  border: 1px solid var(--border-color);
  padding: .4rem .7rem;
  border-radius: var(--radius-s);
  cursor: pointer;
}

.flag-toggle-btn:hover {
  background: var(--surface-alt);
}

.flag-toggle-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Utility */
.fade-in {
  animation: fadeIn .35s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}