/* =========================================================
   HEALTH LAW RX — SHARED THEME CSS
   All 8 color themes × light/dark + FAB/panel styles
   ========================================================= */

/* ---- MIDNIGHT ---- */
[data-theme="midnight"][data-mode="dark"] {
  --color-bg:           #0a0e1a;
  --color-bg-alt:       #111827;
  --color-bg-nav:       rgba(10, 14, 26, 0.92);
  --color-text:         #e8e4d8;
  --color-text-muted:   #8b8c99;
  --color-accent:       #c9a84c;
  --color-accent-hover: #e2c06a;
  --color-accent-subtle:rgba(201, 168, 76, 0.12);
  --color-border:       rgba(201, 168, 76, 0.18);
  --color-heading:      #f0e6c8;
  --color-swatch:       #c9a84c;
}
[data-theme="midnight"][data-mode="light"] {
  --color-bg:           #f5f0e8;
  --color-bg-alt:       #ede8de;
  --color-bg-nav:       rgba(245, 240, 232, 0.95);
  --color-text:         #1a1e2e;
  --color-text-muted:   #5a5f72;
  --color-accent:       #1a2744;
  --color-accent-hover: #253558;
  --color-accent-subtle:rgba(26, 39, 68, 0.08);
  --color-border:       rgba(26, 39, 68, 0.15);
  --color-heading:      #0d1422;
  --color-swatch:       #c9a84c;
}

/* ---- CRIMSON ---- */
[data-theme="crimson"][data-mode="dark"] {
  --color-bg:           #120608;
  --color-bg-alt:       #1e0b0f;
  --color-bg-nav:       rgba(18, 6, 8, 0.92);
  --color-text:         #f0e8e8;
  --color-text-muted:   #9a7a7e;
  --color-accent:       #d4a0a8;
  --color-accent-hover: #e8b8be;
  --color-accent-subtle:rgba(212, 160, 168, 0.12);
  --color-border:       rgba(212, 160, 168, 0.18);
  --color-heading:      #f8e0e4;
  --color-swatch:       #c0506a;
}
[data-theme="crimson"][data-mode="light"] {
  --color-bg:           #fdf5f5;
  --color-bg-alt:       #f5eaeb;
  --color-bg-nav:       rgba(253, 245, 245, 0.95);
  --color-text:         #2a0810;
  --color-text-muted:   #6b3840;
  --color-accent:       #8b1a2a;
  --color-accent-hover: #a82034;
  --color-accent-subtle:rgba(139, 26, 42, 0.08);
  --color-border:       rgba(139, 26, 42, 0.15);
  --color-heading:      #1a0408;
  --color-swatch:       #c0506a;
}

/* ---- EMERALD ---- */
[data-theme="emerald"][data-mode="dark"] {
  --color-bg:           #060f08;
  --color-bg-alt:       #0d1f11;
  --color-bg-nav:       rgba(6, 15, 8, 0.92);
  --color-text:         #e4ede6;
  --color-text-muted:   #7a9a80;
  --color-accent:       #b8c98a;
  --color-accent-hover: #ccdda0;
  --color-accent-subtle:rgba(184, 201, 138, 0.12);
  --color-border:       rgba(184, 201, 138, 0.18);
  --color-heading:      #d8eddc;
  --color-swatch:       #2e7d52;
}
[data-theme="emerald"][data-mode="light"] {
  --color-bg:           #f4faf5;
  --color-bg-alt:       #e8f4ea;
  --color-bg-nav:       rgba(244, 250, 245, 0.95);
  --color-text:         #0d2414;
  --color-text-muted:   #3d6848;
  --color-accent:       #1a5c30;
  --color-accent-hover: #226e3c;
  --color-accent-subtle:rgba(26, 92, 48, 0.08);
  --color-border:       rgba(26, 92, 48, 0.15);
  --color-heading:      #071410;
  --color-swatch:       #2e7d52;
}

/* ---- OCEAN ---- */
[data-theme="ocean"][data-mode="dark"] {
  --color-bg:           #03111a;
  --color-bg-alt:       #081f2e;
  --color-bg-nav:       rgba(3, 17, 26, 0.92);
  --color-text:         #deeef8;
  --color-text-muted:   #5e8a9e;
  --color-accent:       #38c9d8;
  --color-accent-hover: #58dde8;
  --color-accent-subtle:rgba(56, 201, 216, 0.12);
  --color-border:       rgba(56, 201, 216, 0.18);
  --color-heading:      #c8f0f8;
  --color-swatch:       #0e90a8;
}
[data-theme="ocean"][data-mode="light"] {
  --color-bg:           #f0f8fd;
  --color-bg-alt:       #e0f2f8;
  --color-bg-nav:       rgba(240, 248, 253, 0.95);
  --color-text:         #042030;
  --color-text-muted:   #2a6070;
  --color-accent:       #066880;
  --color-accent-hover: #087a96;
  --color-accent-subtle:rgba(6, 104, 128, 0.08);
  --color-border:       rgba(6, 104, 128, 0.15);
  --color-heading:      #021018;
  --color-swatch:       #0e90a8;
}

/* ---- COPPER ---- */
[data-theme="copper"][data-mode="dark"] {
  --color-bg:           #0e0c0a;
  --color-bg-alt:       #1a1612;
  --color-bg-nav:       rgba(14, 12, 10, 0.92);
  --color-text:         #f0ece4;
  --color-text-muted:   #8a7e6e;
  --color-accent:       #c8783a;
  --color-accent-hover: #e08c48;
  --color-accent-subtle:rgba(200, 120, 58, 0.12);
  --color-border:       rgba(200, 120, 58, 0.18);
  --color-heading:      #f8ead8;
  --color-swatch:       #b8622a;
}
[data-theme="copper"][data-mode="light"] {
  --color-bg:           #fdf8f2;
  --color-bg-alt:       #f5ede0;
  --color-bg-nav:       rgba(253, 248, 242, 0.95);
  --color-text:         #201408;
  --color-text-muted:   #6a4828;
  --color-accent:       #8a4018;
  --color-accent-hover: #a04e20;
  --color-accent-subtle:rgba(138, 64, 24, 0.08);
  --color-border:       rgba(138, 64, 24, 0.15);
  --color-heading:      #100a04;
  --color-swatch:       #b8622a;
}

/* ---- VIOLET ---- */
[data-theme="violet"][data-mode="dark"] {
  --color-bg:           #080612;
  --color-bg-alt:       #120e22;
  --color-bg-nav:       rgba(8, 6, 18, 0.92);
  --color-text:         #ece8f8;
  --color-text-muted:   #7e78a0;
  --color-accent:       #b8a0e8;
  --color-accent-hover: #ccc0f8;
  --color-accent-subtle:rgba(184, 160, 232, 0.12);
  --color-border:       rgba(184, 160, 232, 0.18);
  --color-heading:      #dcd8f8;
  --color-swatch:       #6040c0;
}
[data-theme="violet"][data-mode="light"] {
  --color-bg:           #f8f5ff;
  --color-bg-alt:       #ede8f8;
  --color-bg-nav:       rgba(248, 245, 255, 0.95);
  --color-text:         #140c2c;
  --color-text-muted:   #4a3870;
  --color-accent:       #4a2090;
  --color-accent-hover: #5a28a8;
  --color-accent-subtle:rgba(74, 32, 144, 0.08);
  --color-border:       rgba(74, 32, 144, 0.15);
  --color-heading:      #0a0618;
  --color-swatch:       #6040c0;
}

/* ---- ROSE ---- */
[data-theme="rose"][data-mode="dark"] {
  --color-bg:           #120a0e;
  --color-bg-alt:       #1e1018;
  --color-bg-nav:       rgba(18, 10, 14, 0.92);
  --color-text:         #f4e8ee;
  --color-text-muted:   #9a7888;
  --color-accent:       #d48090;
  --color-accent-hover: #e898a8;
  --color-accent-subtle:rgba(212, 128, 144, 0.12);
  --color-border:       rgba(212, 128, 144, 0.18);
  --color-heading:      #f8d8e8;
  --color-swatch:       #b85878;
}
[data-theme="rose"][data-mode="light"] {
  --color-bg:           #fdf5f8;
  --color-bg-alt:       #f5e8ee;
  --color-bg-nav:       rgba(253, 245, 248, 0.95);
  --color-text:         #280a14;
  --color-text-muted:   #6a3848;
  --color-accent:       #883050;
  --color-accent-hover: #a03860;
  --color-accent-subtle:rgba(136, 48, 80, 0.08);
  --color-border:       rgba(136, 48, 80, 0.15);
  --color-heading:      #18040c;
  --color-swatch:       #b85878;
}

/* ---- ARCTIC ---- */
[data-theme="arctic"][data-mode="dark"] {
  --color-bg:           #060c14;
  --color-bg-alt:       #0e1828;
  --color-bg-nav:       rgba(6, 12, 20, 0.92);
  --color-text:         #deeaf8;
  --color-text-muted:   #6880a0;
  --color-accent:       #90c8f0;
  --color-accent-hover: #aadcff;
  --color-accent-subtle:rgba(144, 200, 240, 0.12);
  --color-border:       rgba(144, 200, 240, 0.18);
  --color-heading:      #c8e8ff;
  --color-swatch:       #3878b0;
}
[data-theme="arctic"][data-mode="light"] {
  --color-bg:           #f8fbff;
  --color-bg-alt:       #edf4fc;
  --color-bg-nav:       rgba(248, 251, 255, 0.95);
  --color-text:         #081428;
  --color-text-muted:   #2c4870;
  --color-accent:       #1a4880;
  --color-accent-hover: #205898;
  --color-accent-subtle:rgba(26, 72, 128, 0.08);
  --color-border:       rgba(26, 72, 128, 0.15);
  --color-heading:      #040c1c;
  --color-swatch:       #3878b0;
}

/* =========================================================
   THEME FAB + PANEL
   ========================================================= */
#theme-fab {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 950;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-bg);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  transition: transform 0.25s ease, background 0.25s ease;
}
#theme-fab:hover { transform: scale(1.1); }

#theme-panel {
  position: fixed;
  bottom: 96px;
  right: 32px;
  z-index: 940;
  width: 280px;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
#theme-panel.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: all;
}

.theme-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.theme-panel-title {
  font-family: 'Outfit', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.theme-panel-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 2px;
  line-height: 1;
}
.theme-panel-close:hover { color: var(--color-text); }

.mode-toggle-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--color-border);
}
.mode-toggle-label { font-size: 0.85rem; color: var(--color-text); }
.mode-toggle-switch { position: relative; width: 44px; height: 24px; }
.mode-toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.mode-toggle-track {
  position: absolute;
  inset: 0;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.3s;
}
.mode-toggle-track::before {
  content: '';
  position: absolute;
  left: 3px; top: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--color-accent);
  transition: transform 0.3s ease;
}
.mode-toggle-switch input:checked + .mode-toggle-track::before { transform: translateX(20px); }

.theme-swatches-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}
.theme-swatches {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.swatch-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.swatch-circle {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid transparent;
  position: relative;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.swatch-circle:hover { transform: scale(1.1); }
.swatch-item.active .swatch-circle {
  border-color: var(--color-text);
  box-shadow: 0 0 0 2px var(--color-accent);
}
.swatch-item.active .swatch-circle::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z'/%3E%3C/svg%3E");
  background-size: 18px;
  background-repeat: no-repeat;
  background-position: center;
}
.swatch-label {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  text-align: center;
  letter-spacing: 0.04em;
}

@media (max-width: 768px) {
  #theme-panel { right: 16px; bottom: 80px; width: calc(100vw - 32px); max-width: 320px; }
  #theme-fab   { right: 16px; bottom: 16px; }
}
