/* =============================================================================
   macOS 27 Control Center — Liquid Glass modular capsules (Tahoe match)
   Wi-Fi, Bluetooth, Focus, Display, Sound with readable light-mode labels
   ============================================================================= */

#control-center {
  position: fixed !important;
  top: calc(var(--menubar-height, 25px) + 8px) !important;
  right: 12px !important;
  z-index: var(--z-control-center, 1200) !important;
  width: 340px !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  box-shadow: none !important;
  color: #fff !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.96);
  transform-origin: top right;
  transition:
    opacity 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0.22s;
  pointer-events: none;
}

#control-center.is-open {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(0) scale(1) !important;
  pointer-events: auto !important;
}

.cc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: start;
}

.cc-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

/* Shared liquid glass material for modules */
.cc-pill,
.cc-media,
.cc-round,
.cc-slider-card,
.cc-edit {
  background:
    linear-gradient(
      165deg,
      rgba(255, 255, 255, 0.28) 0%,
      rgba(255, 255, 255, 0.1) 48%,
      rgba(255, 255, 255, 0.16) 100%
    ),
    rgba(255, 255, 255, 0.16) !important;
  backdrop-filter: blur(40px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(40px) saturate(180%) !important;
  border: 0.5px solid rgba(255, 255, 255, 0.38) !important;
  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.18),
    0 2px 6px rgba(0, 0, 0, 0.08),
    inset 0 0.5px 0 rgba(255, 255, 255, 0.5) !important;
  color: #fff !important;
}

/* Connectivity / focus pills — Wi-Fi, Bluetooth, AirDrop, Focus */
.cc-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 22px !important;
  text-align: left;
  cursor: default;
  font: inherit;
  transition: background 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}

.cc-pill:hover {
  background:
    linear-gradient(
      165deg,
      rgba(255, 255, 255, 0.34) 0%,
      rgba(255, 255, 255, 0.14) 50%,
      rgba(255, 255, 255, 0.2) 100%
    ),
    rgba(255, 255, 255, 0.22) !important;
}

.cc-pill:active {
  transform: scale(0.98);
}

.cc-pill.is-active {
  /* Stay glass when on — real CC keeps glass, badge carries state color */
  background:
    linear-gradient(
      165deg,
      rgba(255, 255, 255, 0.3) 0%,
      rgba(255, 255, 255, 0.12) 50%,
      rgba(255, 255, 255, 0.18) 100%
    ),
    rgba(255, 255, 255, 0.18) !important;
}

.cc-badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: #fff;
  color: #0a84ff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.cc-badge svg {
  display: block;
}

.cc-badge.wifi {
  color: #0a84ff;
}

.cc-badge.bt {
  color: #0a84ff;
}

.cc-badge.airdrop {
  color: #30d158;
}

.cc-badge.focus {
  background: #5e5ce6;
  color: #fff;
}

.cc-pill:not(.is-active) .cc-badge {
  background: rgba(255, 255, 255, 0.35);
  color: rgba(255, 255, 255, 0.9);
}

.cc-pill:not(.is-active) .cc-badge.focus {
  background: rgba(255, 255, 255, 0.35);
  color: rgba(255, 255, 255, 0.9);
}

.cc-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.cc-label {
  font-size: 13px !important;
  font-weight: 600 !important;
  line-height: 1.15 !important;
  color: #fff !important;
  opacity: 1 !important;
  letter-spacing: -0.01em;
}

.cc-sublabel {
  font-size: 11px !important;
  font-weight: 400 !important;
  opacity: 0.78 !important;
  color: #fff !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Now Playing card */
.cc-media {
  border-radius: 22px !important;
  padding: 14px 12px 12px;
  min-height: 132px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.cc-media-art {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0.08) 55%, rgba(10, 132, 255, 0.25) 100%),
    rgba(255, 255, 255, 0.14);
  box-shadow:
    inset 0 0 0 0.5px rgba(255, 255, 255, 0.28),
    0 4px 12px rgba(0, 0, 0, 0.18);
  position: relative;
  flex-shrink: 0;
}
.cc-media-art::after {
  content: '♪';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 20px;
  color: rgba(255, 255, 255, 0.72);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.cc-media.is-playing .cc-media-art {
  background: linear-gradient(135deg, #ff375f, #af52de 55%, #5e5ce6);
}
.cc-media.is-playing .cc-media-art::after {
  content: '';
}

.cc-media-title {
  font-size: 13px;
  font-weight: 500;
  opacity: 0.9;
}

.cc-media-controls {
  display: flex;
  align-items: center;
  gap: 18px;
  opacity: 0.85;
}

.cc-media-btn {
  border: none;
  background: transparent;
  color: #fff;
  font-size: 14px;
  padding: 4px;
  cursor: default;
  opacity: 0.85;
}

.cc-media-btn.play {
  font-size: 16px;
}

/* Round icon buttons */
.cc-round-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.cc-round {
  width: 52px;
  height: 52px;
  border-radius: 50% !important;
  display: grid;
  place-items: center;
  border: 0.5px solid rgba(255, 255, 255, 0.35) !important;
  color: #fff;
  cursor: default;
  padding: 0;
  font: inherit;
  transition: background 0.15s ease, transform 0.12s ease;
}

.cc-round:hover {
  background: rgba(255, 255, 255, 0.28) !important;
}

.cc-round.solid {
  background: #fff !important;
  color: #1d1d1f !important;
  border-color: rgba(255, 255, 255, 0.8) !important;
}

.cc-round.is-active:not(.solid) {
  background: rgba(10, 132, 255, 0.55) !important;
}

/* Focus row: camera + DND pill */
.cc-focus-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.cc-focus-row .cc-round {
  flex-shrink: 0;
}

.cc-pill.focus {
  flex: 1;
  min-width: 0;
}

/* Display / Sound sliders */
.cc-slider-card {
  grid-column: 1 / -1;
  border-radius: 22px !important;
  padding: 12px 14px 14px;
}

.cc-slider-card.display {
  /* Neutral clear glass for Display */
}

.cc-slider-card.sound {
  /* Warm amber glass like real CC sound module */
  background:
    linear-gradient(180deg, rgba(255, 200, 120, 0.22), rgba(255, 170, 80, 0.12)),
    rgba(255, 255, 255, 0.14) !important;
  border-color: rgba(255, 220, 160, 0.35) !important;
}

.cc-slider-label {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
  opacity: 0.95;
  letter-spacing: -0.01em;
}

.cc-slider-row {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
}

.cc-slider-ico {
  opacity: 0.9;
  display: grid;
  place-items: center;
  color: #fff;
  flex-shrink: 0;
}

.cc-range {
  flex: 1 !important;
  -webkit-appearance: none;
  appearance: none;
  height: 6px !important;
  border-radius: 999px !important;
  background: rgba(255, 255, 255, 0.35) !important;
  outline: none;
  margin: 0;
}

.cc-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  border: none;
  cursor: default;
}

.cc-range::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.cc-slider-end {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.92);
  color: #1d1d1f;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  cursor: default;
  font-size: 12px;
  padding: 0;
}

/* Edit Controls */
.cc-edit {
  align-self: center;
  margin-top: 2px;
  padding: 8px 18px;
  border-radius: 999px !important;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 236, 180, 0.95) !important;
  background: rgba(255, 220, 120, 0.18) !important;
  border: 0.5px solid rgba(255, 220, 140, 0.35) !important;
  cursor: default;
  font: inherit;
  font-weight: 600;
}

.cc-edit:hover {
  background: rgba(255, 220, 120, 0.28) !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Kill old grid tile styles when present */
#control-center .cc-tile {
  display: none !important;
}

/* =============================================================================
   Light mode — pale frosted glass + dark type with soft shadow (real CC match)
   Labels must stay readable on white glass over bright wallpapers.
   ============================================================================= */
html[data-theme='light'] #control-center {
  color: rgba(0, 0, 0, 0.88) !important;
}

html[data-theme='light'] .cc-pill,
html[data-theme='light'] .cc-media,
html[data-theme='light'] .cc-round,
html[data-theme='light'] .cc-slider-card {
  /* Frosted white glass over wallpaper */
  background:
    linear-gradient(
      165deg,
      rgba(255, 255, 255, 0.72) 0%,
      rgba(255, 255, 255, 0.48) 55%,
      rgba(255, 255, 255, 0.58) 100%
    ),
    rgba(255, 255, 255, 0.52) !important;
  border: 0.5px solid rgba(255, 255, 255, 0.78) !important;
  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.12),
    0 2px 6px rgba(0, 0, 0, 0.06),
    inset 0 0.5px 0 rgba(255, 255, 255, 0.95) !important;
  color: rgba(0, 0, 0, 0.88) !important;
}

html[data-theme='light'] .cc-pill:hover {
  background:
    linear-gradient(
      165deg,
      rgba(255, 255, 255, 0.82) 0%,
      rgba(255, 255, 255, 0.58) 55%,
      rgba(255, 255, 255, 0.68) 100%
    ),
    rgba(255, 255, 255, 0.65) !important;
}

html[data-theme='light'] .cc-pill.is-active {
  background:
    linear-gradient(
      165deg,
      rgba(255, 255, 255, 0.78) 0%,
      rgba(255, 255, 255, 0.54) 55%,
      rgba(255, 255, 255, 0.62) 100%
    ),
    rgba(255, 255, 255, 0.58) !important;
}

/* Labels: near-black + slight dark shadow for legibility on white glass */
html[data-theme='light'] .cc-label,
html[data-theme='light'] .cc-sublabel,
html[data-theme='light'] .cc-media-title,
html[data-theme='light'] .cc-slider-label,
html[data-theme='light'] #control-center .cc-label,
html[data-theme='light'] #control-center .cc-sublabel {
  color: rgba(0, 0, 0, 0.9) !important;
  opacity: 1 !important;
  text-shadow:
    0 0.5px 0 rgba(255, 255, 255, 0.65),
    0 0.5px 1.5px rgba(0, 0, 0, 0.22),
    0 1px 2px rgba(0, 0, 0, 0.1) !important;
}

html[data-theme='light'] .cc-sublabel,
html[data-theme='light'] #control-center .cc-sublabel {
  color: rgba(0, 0, 0, 0.55) !important;
  opacity: 1 !important;
  text-shadow:
    0 0.5px 0 rgba(255, 255, 255, 0.55),
    0 0.5px 1.5px rgba(0, 0, 0, 0.18) !important;
}

html[data-theme='light'] .cc-slider-label {
  color: rgba(0, 0, 0, 0.82) !important;
}

html[data-theme='light'] .cc-media-btn,
html[data-theme='light'] .cc-round,
html[data-theme='light'] .cc-slider-ico {
  color: rgba(0, 0, 0, 0.78) !important;
  filter: drop-shadow(0 0.5px 1px rgba(0, 0, 0, 0.16));
}

html[data-theme='light'] .cc-round {
  border-color: rgba(255, 255, 255, 0.75) !important;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.48)),
    rgba(255, 255, 255, 0.5) !important;
}

html[data-theme='light'] .cc-round:hover {
  background: rgba(255, 255, 255, 0.78) !important;
}

html[data-theme='light'] .cc-round.solid {
  background: #fff !important;
  color: #1d1d1f !important;
  border-color: rgba(0, 0, 0, 0.06) !important;
  filter: none;
}

html[data-theme='light'] .cc-round.is-active:not(.solid) {
  background: rgba(10, 132, 255, 0.55) !important;
  color: #fff !important;
  filter: none;
}

/* Badges stay white circles with colored glyphs */
html[data-theme='light'] .cc-badge {
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

html[data-theme='light'] .cc-pill:not(.is-active) .cc-badge {
  background: rgba(255, 255, 255, 0.95);
  color: #8e8e93;
}

html[data-theme='light'] .cc-badge.wifi,
html[data-theme='light'] .cc-pill.is-active .cc-badge:not(.focus) {
  color: #0a84ff;
}

html[data-theme='light'] .cc-badge.bt {
  color: #0a84ff;
}

html[data-theme='light'] .cc-badge.airdrop {
  color: #30d158;
}

html[data-theme='light'] .cc-badge.focus {
  background: #5e5ce6;
  color: #fff;
}

html[data-theme='light'] .cc-pill.focus.is-active .cc-badge.focus {
  background: #5e5ce6;
  color: #fff;
}

/* Display / Sound stay pale glass in light mode */
html[data-theme='light'] .cc-slider-card.sound {
  background:
    linear-gradient(180deg, rgba(255, 240, 220, 0.55), rgba(255, 255, 255, 0.5)),
    rgba(255, 255, 255, 0.55) !important;
  border-color: rgba(255, 255, 255, 0.78) !important;
}

html[data-theme='light'] .cc-range {
  background: rgba(0, 0, 0, 0.1) !important;
}

html[data-theme='light'] .cc-range::-webkit-slider-thumb {
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.22);
}

html[data-theme='light'] .cc-range::-moz-range-thumb {
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.22);
}

html[data-theme='light'] .cc-media-art {
  background: rgba(0, 0, 0, 0.06);
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.06);
}

html[data-theme='light'] .cc-edit {
  color: rgba(0, 0, 0, 0.55) !important;
  background: rgba(255, 255, 255, 0.5) !important;
  border-color: rgba(255, 255, 255, 0.75) !important;
  text-shadow: 0 0.5px 1px rgba(0, 0, 0, 0.12) !important;
}

html[data-theme='light'] .cc-edit:hover {
  background: rgba(255, 255, 255, 0.7) !important;
}

/* body.light-chrome fallback if data-theme not set */
body.light-chrome #control-center .cc-label,
body.light-chrome #control-center .cc-sublabel,
body.light-chrome #control-center .cc-slider-label {
  color: rgba(0, 0, 0, 0.9) !important;
  text-shadow:
    0 0.5px 0 rgba(255, 255, 255, 0.65),
    0 0.5px 1.5px rgba(0, 0, 0, 0.22) !important;
}
