/* ============================================================
   StW Audio Transport – Shared Styles
   Modern, minimal design with a professional feel
   ============================================================ */

/* ---------- Reset & base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:          #0f1117;
  --bg-card:     #1a1d27;
  --bg-input:    #252836;
  --border:      #2e3244;
  --text:        #e4e6f0;
  --text-muted:  #8a8fa8;
  --primary:     #4f8cff;
  --primary-hover: #6ba0ff;
  --success:     #34d399;
  --warning:     #fbbf24;
  --danger:      #f87171;
  --danger-hover:#fb9a9a;
  --radius:      10px;
  --radius-sm:   6px;
  --shadow:      0 2px 12px rgba(0, 0, 0, 0.3);
  --font:        'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono:        'SF Mono', 'Fira Code', 'Consolas', monospace;
}

html {
  font-size: 16px;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Layout ---------- */
.container {
  max-width: 540px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header .logo {
  display: block;
  margin: 0 auto 0.5rem;
  width: 100px;
  height: auto;
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.subtitle {
  font-size: 0.875rem;
  color: var(--primary);
  font-weight: 500;
  margin-top: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

footer {
  text-align: center;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

footer a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.2s;
}

footer a:hover {
  color: var(--primary);
}

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* ---------- Form elements ---------- */
.form-row {
  margin-bottom: 0.875rem;
}

.form-row label {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
  font-weight: 500;
}

.input-group {
  display: flex;
  gap: 0.5rem;
}

.input-group input {
  flex: 1;
}

input[type="text"],
select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.9375rem;
  outline: none;
  transition: border-color 0.2s;
}

input[type="text"]::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

input[type="text"]:focus,
select:focus {
  border-color: var(--primary);
}

select {
  font-family: var(--font);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%238a8fa8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.875rem center;
  padding-right: 2.5rem;
}

/* Range slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  margin: 0.5rem 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid var(--bg-card);
  box-shadow: 0 0 0 2px var(--primary);
}

.form-row:has(input[type="range"]) {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.form-row:has(input[type="range"]) label {
  margin-bottom: 0;
  white-space: nowrap;
}

.form-row:has(input[type="range"]) input[type="range"] {
  flex: 1;
}

#volume-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 3rem;
  text-align: right;
}

/* Checkbox row */
.checkbox-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.checkbox-row label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: 0;
}

.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  outline: none;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-icon {
  background: var(--bg-input);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.btn-icon:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--text-muted);
}

.input-group .btn-secondary {
  flex-shrink: 0;
  padding: 0.5rem 0.625rem;
}

.input-group .btn-secondary svg {
  display: block;
}

.btn-row {
  display: flex;
  gap: 0.5rem;
}

/* ---------- Status indicator ---------- */
.status {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-idle {
  background: var(--bg-input);
  color: var(--text-muted);
}

.status-idle::before {
  background: var(--text-muted);
}

.status-connecting {
  background: rgba(251, 191, 36, 0.1);
  color: var(--warning);
}

.status-connecting::before {
  background: var(--warning);
  animation: pulse 1.5s ease-in-out infinite;
}

.status-connected {
  background: rgba(52, 211, 153, 0.1);
  color: var(--success);
}

.status-connected::before {
  background: var(--success);
}

.status-error {
  background: rgba(248, 113, 113, 0.1);
  color: var(--danger);
}

.status-error::before {
  background: var(--danger);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ---------- Device hint ---------- */
.device-hint {
  font-size: 0.75rem;
  color: var(--warning);
  margin-top: 0.375rem;
  line-height: 1.4;
}

/* ---------- Level meter ---------- */
.level-bar {
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
  margin: 0.75rem 0;
}

.level-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--success), var(--warning), var(--danger));
  border-radius: 3px;
  transition: width 0.05s linear;
}

/* ---------- Room code display ---------- */
.room-display {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: center;
}

.room-code {
  font-family: var(--mono);
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--primary);
  text-align: center;
  user-select: all;
}

.room-hint {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  margin-bottom: 1rem;
}

/* ---------- Stats grid ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.stat-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.stat-value {
  font-family: var(--mono);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .container {
    padding: 1.25rem 1rem;
  }

  header h1 {
    font-size: 1.25rem;
  }

  .room-code {
    font-size: 1.75rem;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .checkbox-row {
    flex-direction: column;
    gap: 0.5rem;
  }
}
