/* Playlists Design System - shadcn/ui based */
/* Compatible with static HTML pages */
/* Load shared/css/themes.css first for RGB vars; this provides utility classes. */

/* Playlists accent (optional – use for timer digits and primary actions) */
:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-header: clamp(1rem, 3vw, 1.25rem);
  --font-weight-header: 600;

  --timer-primary: 212 90% 59%;   /* blue #4A90E2 */
  --timer-success: 142 69% 55%;   /* green for Clear / success */
  --timer-phase: 0 0% 45.1%;      /* muted for WORK/REST phase label */
  
  /* Shadows */
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
  --shadow-large: 0 8px 24px rgba(0, 0, 0, 0.12);
  
  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
}

/* Utility Classes - use rgb(var(--x)) for timer pages with themes.css */
.bg-background { background-color: rgb(var(--background)); }
.bg-card { background-color: rgb(var(--card)); }
.bg-primary { background-color: rgb(var(--primary)); }
.bg-secondary { background-color: rgb(var(--secondary)); }
.bg-destructive { background-color: rgb(var(--destructive)); }
.bg-muted { background-color: rgb(var(--muted)); }
.bg-accent { background-color: rgb(var(--accent)); }

.text-foreground { color: rgb(var(--foreground)); }
.text-card-foreground { color: rgb(var(--card-foreground)); }
.text-primary { color: rgb(var(--primary)); }
.text-primary-foreground { color: rgb(var(--primary-foreground)); }
.text-secondary { color: rgb(var(--secondary)); }
.text-secondary-foreground { color: rgb(var(--secondary-foreground)); }
.text-muted-foreground { color: rgb(var(--muted-foreground)); }
.text-destructive { color: rgb(var(--destructive)); }
.text-destructive-foreground { color: rgb(var(--destructive-foreground)); }

.border { border: 1px solid rgb(var(--border)); }
.border-border { border-color: rgb(var(--border)); }
.border-primary { border-color: rgb(var(--primary)); }
.border-destructive { border-color: rgb(var(--destructive)); }

.rounded { border-radius: var(--radius); }
.rounded-lg { border-radius: calc(var(--radius) + 2px); }
.rounded-md { border-radius: var(--radius); }
.rounded-sm { border-radius: calc(var(--radius) - 2px); }

.shadow { box-shadow: var(--shadow); }
.shadow-lg { box-shadow: var(--shadow-large); }
.shadow-hover:hover { box-shadow: var(--shadow-hover); }

/* Button Styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  cursor: pointer;
  border: none;
  padding: 0.5rem 1rem;
  min-height: 44px;
  min-width: 44px;
  font-family: inherit;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background-color: rgb(var(--primary));
  color: rgb(var(--primary-foreground));
}

.btn-primary:hover:not(:disabled) {
  background-color: rgba(var(--primary), 0.9);
}

.btn-secondary {
  background-color: rgb(var(--secondary));
  color: rgb(var(--secondary-foreground));
}

.btn-secondary:hover:not(:disabled) {
  background-color: rgba(var(--secondary), 0.9);
}

.btn-destructive {
  background-color: rgb(var(--destructive));
  color: rgb(var(--destructive-foreground));
}

.btn-destructive:hover:not(:disabled) {
  background-color: rgba(var(--destructive), 0.9);
}

/* Card Styles */
.card {
  background-color: rgb(var(--card));
  color: rgb(var(--card-foreground));
  border: 1px solid rgb(var(--border));
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

/* Input Styles */
.input {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid rgb(var(--input));
  background-color: rgb(var(--background));
  color: rgb(var(--foreground));
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  transition: all var(--transition-fast);
  min-height: 44px;
}

.input:focus {
  outline: none;
  border-color: rgb(var(--ring));
  box-shadow: 0 0 0 2px rgba(var(--ring), 0.2);
}

/* Responsive Grid */
.grid {
  display: grid;
  gap: 1rem;
}

.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

@media (max-width: 768px) {
  .grid-cols-2 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
  .grid-cols-3 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
}

/* Spacing */
.space-y-2 > * + * { margin-top: 0.5rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.space-y-6 > * + * { margin-top: 1.5rem; }
.space-y-8 > * + * { margin-top: 2rem; }

.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }

/* Typography */
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }
.text-4xl { font-size: 2.25rem; }
.text-5xl { font-size: 3rem; }
.text-6xl { font-size: 3.75rem; }
.text-7xl { font-size: 4.5rem; }
.text-8xl { font-size: 6rem; }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }

.text-center { text-align: center; }
.uppercase { text-transform: uppercase; }

/* Mode Toggle */
.mode-toggle {
  position: relative;
  z-index: 1001;
}

.mode-toggle-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  border: 1px solid rgb(var(--border));
  background-color: rgb(var(--background));
  color: rgb(var(--foreground));
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  padding: 0;
  font-size: 1.25rem;
}

.mode-toggle-btn:hover {
  background-color: rgb(var(--accent));
}

/* Header actions container */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Flex Utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

/* Hidden/Visible */
.hidden { display: none; }

/* shadcn-style Toggle Group (vanilla; mirrors ui.shadcn.com toggle-group outline) */
.pls-toggle-group {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.125rem;
}

.pls-toggle-group--outline {
  gap: 0.25rem;
}

.pls-toggle-group__item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  padding: 0.25rem 0.625rem;
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
  color: rgb(var(--foreground));
  background: rgb(var(--background));
  border: 1px solid rgb(var(--border));
  border-radius: var(--radius, 0.375rem);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.pls-toggle-group__item:hover {
  background: rgb(var(--accent));
  color: rgb(var(--accent-foreground, var(--foreground)));
}

.pls-toggle-group__item:focus-visible {
  outline: 2px solid rgb(var(--ring, 24 24 27));
  outline-offset: 2px;
}

.pls-toggle-group__item--on {
  background: rgb(var(--primary));
  color: rgb(var(--primary-foreground));
  border-color: rgb(var(--primary));
}

.pls-toggle-group__item--on:hover {
  opacity: 0.92;
}

/* Segmented toggle group (single track, pill selection — matches Browse Music / Lists control) */
.pls-toggle-group--segmented {
  display: flex;
  width: 100%;
  max-width: 100%;
  gap: 0;
  flex-wrap: nowrap;
  padding: 2px;
  border: 1px solid rgb(var(--border));
  border-radius: calc(var(--radius, 0.375rem) + 2px);
  background: rgb(var(--muted, 244 244 245) / 0.65);
}

.pls-toggle-group--segmented .pls-toggle-group__item {
  flex: 1;
  min-width: 0;
  border: none;
  border-radius: calc(var(--radius, 0.375rem) - 1px);
  background: transparent;
  color: rgb(var(--muted-foreground, 113 113 122));
  min-height: 2.25rem;
  padding: 0.375rem 0.5rem;
  font-size: 0.75rem;
}

.pls-toggle-group--segmented .pls-toggle-group__item:hover {
  background: rgb(var(--accent) / 0.45);
  color: rgb(var(--foreground));
}

.pls-toggle-group--segmented .pls-toggle-group__item--on {
  background: rgb(var(--background));
  color: rgb(var(--foreground));
  border: none;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
}

.pls-toggle-group--segmented .pls-toggle-group__item--on:hover {
  opacity: 1;
  background: rgb(var(--background));
}

.pls-toggle-group__label--long {
  display: inline;
}

.pls-toggle-group__label--short {
  display: none;
}

/* Compact visibility labels: iOS/Android, native app, or bottom tab bar active */
html[data-hide-footer="true"] .pls-toggle-group__label--long,
html[data-capacitor="true"] .pls-toggle-group__label--long {
  display: none;
}

html[data-hide-footer="true"] .pls-toggle-group__label--short,
html[data-capacitor="true"] .pls-toggle-group__label--short {
  display: inline;
}

@media (max-width: 768px) {
  body.has-tab-bar .pls-toggle-group__label--long {
    display: none;
  }

  body.has-tab-bar .pls-toggle-group__label--short {
    display: inline;
  }
}

body.mobile-tab-bar-viewport.has-tab-bar .pls-toggle-group__label--long {
  display: none;
}

body.mobile-tab-bar-viewport.has-tab-bar .pls-toggle-group__label--short {
  display: inline;
}

/* My Playlists ↔ Shared Lists dashboard scope toggle */
.dashboard-scope-toggle.pls-toggle-group--segmented {
  max-width: 28rem;
}

/* Always show full labels — enough width even on phone + tab bar */
.dashboard-scope-toggle .pls-toggle-group__label--long {
  display: inline !important;
}

.dashboard-scope-toggle .pls-toggle-group__label--short {
  display: none !important;
}

.card-header .dashboard-scope-toggle {
  margin-bottom: 0.125rem;
}

.dashboard-scope-toggle-mount {
  margin-bottom: 1rem;
}

/* Community hub: Contests / Ideas / Shared (3-segment) */
.community-hub-toggle.pls-toggle-group--segmented {
  max-width: 36rem;
  margin: 0 auto;
}

.community-hub-toggle .pls-toggle-group__item {
  text-decoration: none;
  text-align: center;
  font-size: 0.8125rem;
}

.community-hub-toggle button.pls-toggle-group__item {
  font: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.community-hub-toggle a.pls-toggle-group__item:hover,
.community-hub-toggle button.pls-toggle-group__item:hover {
  color: rgb(var(--foreground));
}

/* Keep readable 3 labels on phones — use short labels under tab-bar width */
.community-hub-toggle .pls-toggle-group__label--long {
  display: none;
}
.community-hub-toggle .pls-toggle-group__label--short {
  display: inline;
}

@media (min-width: 520px) {
  .community-hub-toggle .pls-toggle-group__label--long {
    display: inline;
  }
  .community-hub-toggle .pls-toggle-group__label--short {
    display: none;
  }
}

.community-hub-toggle-mount {
  margin: 0 auto 1rem;
  max-width: 36rem;
  padding: 0 0.25rem;
}

/*
 * Uniform hub chrome (desktop / no persistent header).
 * On mobile tab-bar, persistent-header.css overrides main padding with !important —
 * community-hub-main exception lives there too.
 */
.community-hub-main {
  padding-top: 0.5rem;
}

/* Shared Lists: section heading sits between hub toggle and dashboard toggle */
.community-hub-toggle-mount + .dashboard-scope-toggle-mount,
.community-hub-section-head + .dashboard-scope-toggle-mount {
  /* heading already has mb-4; keep a little extra before dashboard */
  margin-top: 0;
}

.pls-hub-help {
  vertical-align: middle;
}

.pls-hub-help [id$='-help-popover'] {
  z-index: 50;
  box-sizing: border-box;
  width: min(22rem, calc(100vw - 2.5rem));
  max-width: min(22rem, calc(100vw - 2.5rem));
  white-space: normal;
  overflow-wrap: break-word;
  word-wrap: break-word;
  overflow-x: hidden;
  background-color: #ffffff;
  color: #0a0a0a;
  border: 1px solid #e4e4e7;
  box-shadow: 0 10px 28px rgb(0 0 0 / 0.18);
}

.dark .pls-hub-help [id$='-help-popover'] {
  background-color: #18181b;
  color: #fafafa;
  border-color: #3f3f46;
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.55);
}

.pls-hub-help .pls-hub-help__title {
  color: #71717a;
}

.dark .pls-hub-help .pls-hub-help__title {
  color: #a1a1aa;
}

.pls-hub-help .pls-hub-help__body,
.pls-hub-help [id$='-help-popover'] li {
  color: #52525b;
  white-space: normal;
  overflow-wrap: break-word;
  max-width: 100%;
}

.dark .pls-hub-help .pls-hub-help__body,
.dark .pls-hub-help [id$='-help-popover'] li {
  color: #a1a1aa;
}

.pls-hub-help [id$='-help-popover'] strong {
  color: #0a0a0a;
}

.dark .pls-hub-help [id$='-help-popover'] strong {
  color: #fafafa;
}
