/*
 * SparkCraft voice client — layout & components
 */

:root {
  --sc-bg: #020617;
  --sc-surface: rgb(15 23 42 / 0.6);
  --sc-surface-solid: #0f172a;
  --sc-border: #1e293b;
  --sc-border-hover: rgb(16 185 129 / 0.5);
  --sc-text: #f8fafc;
  --sc-text-muted: #94a3b8;
  --sc-text-dim: #64748b;
  --sc-accent: #10b981;
  --sc-accent-hover: #34d399;
  --sc-accent-active: #059669;
  --sc-accent-text: #020617;
  --sc-danger: #dc2626;
  --sc-danger-hover: #ef4444;
  --sc-success: #10b981;
  --sc-success-text: #020617;
  --sc-radius-lg: 1rem;
  --sc-radius-md: 0.375rem;
  --sc-container: 720px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scrollbar-width: thin;
  scrollbar-color: rgb(51 65 85 / 0.8) transparent;
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background-color: rgb(51 65 85 / 0.8);
  border-radius: 9999px;
}

*::-webkit-scrollbar-thumb:hover {
  background-color: rgb(71 85 105);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Montserrat', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--sc-text);
  background: var(--sc-bg);
}

:focus-visible {
  outline: 2px solid #34d399;
  outline-offset: 2px;
}

/* Ambient background (matches AppShellAmbientBackground) */
.ambient-bg {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  background-color: var(--sc-bg);
  background-image:
    linear-gradient(to bottom right, rgba(52, 211, 153, 0.05) 0%, transparent 40%),
    linear-gradient(to bottom right, transparent 58%, rgba(167, 139, 250, 0.042) 100%),
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(56, 189, 248, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 50%, rgba(139, 92, 246, 0.08), transparent),
    radial-gradient(ellipse 70% 45% at 50% 110%, rgba(16, 185, 129, 0.07), transparent);
}

.page-shell {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

/* Main */
.voice-main {
  flex: 1;
  width: 100%;
  max-width: var(--sc-container);
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
}

.voice-hero {
  text-align: center;
  margin-bottom: 0.25rem;
}

.voice-hero h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #34d399, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.voice-subtitle {
  margin: 0;
  max-width: 36rem;
  margin-inline: auto;
  color: var(--sc-text-muted);
  font-size: 0.9375rem;
}

/* Cards */
.voice-card {
  width: 100%;
  background: var(--sc-surface);
  border: 1px solid var(--sc-border);
  border-radius: var(--sc-radius-lg);
  padding: 1.25rem;
  box-shadow: 0 4px 24px rgb(0 0 0 / 0.25);
}

#form-container {
  width: 100%;
  display: flex;
  justify-content: center;
}

form#joinForm {
  width: 100%;
  max-width: 420px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

#joinCredentials {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

#joinSession {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
}

#joinSession #joinbtn {
  width: 100%;
  margin-top: 0;
  padding-block: 0.75rem;
}

#joinSession #status {
  margin: 0;
}

label {
  display: block;
  width: 100%;
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--sc-text-muted);
}

input:not([type='checkbox']):not([type='radio']):not([type='range']) {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border-radius: var(--sc-radius-md);
  border: 1px solid #334155;
  background: rgb(2 6 23 / 0.6);
  color: var(--sc-text);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.5;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

select {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border-radius: var(--sc-radius-md);
  border: 1px solid #334155;
  background: rgb(2 6 23 / 0.6);
  color: var(--sc-text);
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.5;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder {
  color: var(--sc-text-dim);
}

input:not([type='checkbox']):not([type='radio']):not([type='range']):hover,
select:hover {
  border-color: #475569;
  cursor: pointer;
}

input:not([type='checkbox']):not([type='radio']):not([type='range']):focus,
select:focus {
  outline: none;
  border-color: rgb(16 185 129 / 0.8);
  box-shadow: 0 0 0 2px rgb(16 185 129 / 0.25);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

/* Custom select (как DropdownSelect на сайте) */
.custom-select {
  position: relative;
  width: 100%;
}

.custom-select-native {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0.625rem 0.75rem;
  border-radius: var(--sc-radius-md);
  border: 1px solid #334155;
  background: rgb(2 6 23 / 0.6);
  color: #f8fafc;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.5;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.custom-select-trigger:hover:not(:disabled) {
  border-color: #475569;
  background: rgb(2 6 23 / 0.6);
}

.custom-select-trigger:focus-visible {
  outline: none;
  border-color: rgb(16 185 129 / 0.8);
  box-shadow: 0 0 0 2px rgb(16 185 129 / 0.25);
}

.custom-select-trigger.custom-select-open {
  border-color: rgb(16 185 129 / 0.8);
  box-shadow: 0 0 0 2px rgb(16 185 129 / 0.25);
}

.custom-select-trigger:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.custom-select-value {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #f8fafc;
}

.custom-select-value.custom-select-placeholder {
  color: #64748b;
}

.custom-select-chevron-wrap {
  display: flex;
  flex-shrink: 0;
  color: #94a3b8;
}

.custom-select-chevron {
  width: 1rem;
  height: 1rem;
  transition: transform 0.15s ease;
}

.custom-select-open .custom-select-chevron {
  transform: rotate(180deg);
}

.custom-select-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 0.25rem);
  left: 0;
  right: 0;
  max-height: 15rem;
  overflow-y: auto;
  border-radius: var(--sc-radius-md);
  border: 1px solid #334155;
  background: rgb(2 6 23 / 0.97);
  box-shadow: 0 10px 25px rgb(0 0 0 / 0.35);
  scrollbar-width: thin;
  scrollbar-color: rgb(51 65 85 / 0.8) transparent;
}

.custom-select-menu::-webkit-scrollbar {
  width: 6px;
}

.custom-select-menu::-webkit-scrollbar-track {
  background: transparent;
}

.custom-select-menu::-webkit-scrollbar-thumb {
  background-color: rgb(51 65 85 / 0.8);
  border-radius: 9999px;
}

.custom-select-menu::-webkit-scrollbar-thumb:hover {
  background-color: rgb(71 85 105);
}

.custom-select-option {
  display: block;
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: none;
  border-radius: 0;
  background: transparent;
  color: #e2e8f0;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.5;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.custom-select-option:hover:not(:disabled) {
  background: #1e293b;
  color: #f8fafc;
}

.custom-select-option-selected {
  background: rgb(16 185 129 / 0.2);
  color: #6ee7b7;
}

.custom-select-option-selected:hover:not(:disabled) {
  background: rgb(16 185 129 / 0.28);
  color: #6ee7b7;
}

.custom-select-option-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.custom-select-disabled .custom-select-trigger {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Buttons */
button {
  padding: 0.625rem 1rem;
  border: none;
  border-radius: var(--sc-radius-md);
  background: var(--sc-accent);
  color: var(--sc-accent-text);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

button:hover {
  background: var(--sc-accent-hover);
}

button:active {
  background: var(--sc-accent-active);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Voice session status */
#status {
  padding: 0.5rem 0.875rem;
  border-radius: 9999px;
  background: rgb(15 23 42 / 0.8);
  border: 1px solid var(--sc-border);
  color: var(--sc-text-muted);
  font-size: 0.8125rem;
  max-width: 100%;
  text-align: center;
}

#status.status-connected {
  border-color: rgb(16 185 129 / 0.45);
  color: #6ee7b7;
  background: rgb(16 185 129 / 0.08);
}

#status.status-disconnected {
  border-color: rgb(220 38 38 / 0.45);
  color: #fca5a5;
  background: rgb(220 38 38 / 0.08);
}

/* Controls */
#controls {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  width: 100%;
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
}

#controls-main {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.875rem;
  width: 100%;
}

.controls-card {
  flex: none;
  width: 100%;
  max-width: 420px;
  margin-inline: auto;
  background: var(--sc-surface);
  border: 1px solid var(--sc-border);
  border-radius: var(--sc-radius-lg);
  padding: 1rem;
  min-width: 0;
  box-shadow: 0 4px 24px rgb(0 0 0 / 0.25);
}

.controls-card-ptt {
  max-width: 420px;
}

.control-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  width: 100%;
}

.control-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sc-text-dim);
}

.control-label-with-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.control-hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--sc-text-muted);
  text-align: left;
}

.form-voice-channel {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
  margin-bottom: 0.25rem;
}

#groupPassword {
  width: 100%;
  max-width: 16rem;
  margin-top: 0.35rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--sc-radius-md);
  border: 1px solid var(--sc-border);
  background: var(--sc-surface-solid);
  color: var(--sc-text);
}

.groups-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  width: 100%;
}

.groups-actions button {
  min-width: 5.5rem;
  padding: 0.45rem 0.75rem;
  white-space: nowrap;
}

.dev-hidden {
  display: none !important;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mic */
#micControls,
#musicControls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  width: 100%;
}

#musicControls {
  justify-content: space-between;
  flex-wrap: nowrap;
}

#micControls #muteBtn,
#musicControls #musicMuteBtn {
  flex: 0 0 8rem;
  width: 8rem;
  text-align: center;
}

#musicVolume {
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
  height: 0.375rem;
  padding: 0;
  border: 0;
  border-radius: 9999px;
  outline: none;
  background: linear-gradient(
    to right,
    var(--sc-accent) 0%,
    var(--sc-accent) var(--music-volume-fill, 100%),
    #334155 var(--music-volume-fill, 100%),
    #334155 100%
  );
  appearance: none;
}

#musicVolume::-webkit-slider-runnable-track {
  height: 0.375rem;
  border: 0;
  border-radius: 9999px;
  background: transparent;
}

#musicVolume::-webkit-slider-thumb {
  width: 1rem;
  height: 1rem;
  margin-top: -0.3125rem;
  border: 0;
  border-radius: 50%;
  background: var(--sc-accent);
  box-shadow: none;
  appearance: none;
}

#musicVolume::-moz-range-thumb {
  width: 1rem;
  height: 1rem;
  border: 0;
  border-radius: 50%;
  background: var(--sc-accent);
  box-shadow: none;
}

#musicVolume::-moz-range-track {
  height: 0.375rem;
  border: 0;
  border-radius: 9999px;
  background: #334155;
}

#musicVolume::-moz-range-progress {
  height: 0.375rem;
  border: 0;
  border-radius: 9999px;
  background: var(--sc-accent);
}

#muteBtn,
#musicMuteBtn,
.mute-toggle {
  padding: 0.625rem 1.125rem;
  font-weight: 600;
  border-radius: var(--sc-radius-md);
}

#muteBtn.muted,
#musicMuteBtn.muted,
.mute-toggle.muted {
  background: var(--sc-danger);
  color: #fff;
}

#muteBtn.muted:hover,
#musicMuteBtn.muted:hover,
.mute-toggle.muted:hover {
  background: var(--sc-danger-hover);
}

#muteBtn.unmuted,
#musicMuteBtn.unmuted,
.mute-toggle.unmuted {
  background: var(--sc-success);
  color: var(--sc-success-text);
}

#muteBtn.unmuted:hover,
#musicMuteBtn.unmuted:hover,
.mute-toggle.unmuted:hover {
  background: var(--sc-accent-hover);
}

#micIndicator {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: #334155;
  border: 1px solid #475569;
  flex-shrink: 0;
}

#micIndicator.active {
  background: #34d399;
  border-color: #6ee7b7;
  box-shadow: 0 0 8px rgb(52 211 153 / 0.6);
}

/* Noscript */
.noscript-banner {
  background: rgb(220 38 38 / 0.15);
  border: 1px solid rgb(220 38 38 / 0.4);
  color: #fecaca;
  padding: 1rem;
  border-radius: var(--sc-radius-lg);
  text-align: center;
}

.noscript-banner h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.noscript-banner p {
  margin: 0;
}

/* Mobile */
@media (max-width: 767px) {
  .voice-card,
  .controls-card {
    padding: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
