/* ═══════════════════════════════════════════════
   ChurchLiveTranslate — Client Styles
   Mobile-first, dark theme, church-appropriate
   ═══════════════════════════════════════════════ */

:root {
  --bg-primary: #0f0f14;
  --bg-secondary: #1a1a24;
  --bg-card: #222233;
  --bg-modal: rgba(0, 0, 0, 0.85);
  --text-primary: #f0f0f5;
  --text-secondary: #a0a0b5;
  --text-muted: #6a6a80;
  --accent: #7c6df0;
  --accent-glow: rgba(124, 109, 240, 0.3);
  --accent-hover: #9182f5;
  --success: #4cdf8a;
  --warning: #f0c040;
  --error: #f06060;
  --border: rgba(255, 255, 255, 0.08);
  --radius: 12px;
  --radius-lg: 20px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: 0.2s ease;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

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

[hidden] {
  display: none !important;
}

/* ─── Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* ─── Login Overlay ─── */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.login-card {
  background: rgba(34, 34, 51, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  width: 90%;
  max-width: 320px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.login-card .icon-wrapper {
  width: 48px;
  height: 48px;
  background: rgba(124, 109, 240, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--accent);
  border: 1px solid rgba(124, 109, 240, 0.3);
  box-shadow: 0 0 16px rgba(124, 109, 240, 0.2);
}

.login-card .icon-wrapper svg {
  width: 20px;
  height: 20px;
}

.login-card h2 {
  font-size: 1.25rem;
  margin-bottom: 6px;
  color: var(--text-primary);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.login-card p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 20px;
}

.login-card input {
  width: 100%;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  margin-bottom: 16px;
  outline: none;
  text-align: center;
  transition: all var(--transition);
  letter-spacing: 0.1em;
}

.login-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 109, 240, 0.15);
  background: rgba(0,0,0,0.6);
}

.login-card .btn-primary {
  width: 100%;
  background: var(--accent);
  color: white;
  border: none;
  padding: 12px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--accent-glow);
  transition: all var(--transition);
}

.login-card .btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--accent-glow);
  background: var(--accent-hover);
}

.login-card .login-error {
  color: var(--error);
  font-size: 0.8rem;
  margin-top: 12px;
  margin-bottom: 0;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.modal-card h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.modal-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.modal-card input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition);
  margin-bottom: 16px;
  text-align: center;
  letter-spacing: 0.1em;
}

.modal-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.error-text {
  color: var(--error);
  font-size: 0.85rem;
  margin-top: 12px;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:active {
  transform: translateY(0);
}

/* ─── App Layout ─── */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 600px;
  margin: 0 auto;
}

.header h1 {
  font-size: 1.2rem;
  font-weight: 600;
  background: linear-gradient(135deg, var(--accent), #b09cf5);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── Status Badge ─── */
.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid var(--border);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

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

.status-connected .status-dot { background: var(--success); }
.status-connecting .status-dot { background: var(--warning); }
.status-disconnected .status-dot { background: var(--error); animation: none; }

/* ─── Main ─── */
.main {
  flex: 1;
  padding: 24px 20px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ─── Switch UI ─── */
/* ─── Controls Layout & Meters ─── */
.controls-with-meters {
  display: flex;
  align-items: stretch;
  gap: 16px;
  width: 100%;
}

.admin-controls {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.audio-meter-container {
  width: 12px;
  background: var(--bg-primary);
  border-radius: 6px;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.audio-meter-fill {
  width: 100%;
  height: 0%;
  background: linear-gradient(to top, #22c55e, #eab308, #ef4444);
  transition: height 0.05s ease-out;
  border-radius: 4px;
}

.switch-holder {
  display: flex;
  padding: 14px 20px;
  background: var(--bg-card);
  border-radius: 16px;
  border: 1px solid var(--border);
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 380px;
  margin-bottom: 12px;
}

.switch-label {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
  font-size: 1rem;
}

.switch-toggle {
  height: 36px;
  position: relative;
}

.switch-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  z-index: -2;
}

.switch-toggle label {
  position: relative;
  display: inline-block;
  width: 72px;
  height: 36px;
  border-radius: 20px;
  margin: 0;
  cursor: pointer;
  background: var(--bg-primary);
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.5), inset 0 0 0 1px var(--border);
  transition: .3s ease;
}

.switch-toggle label::before {
  position: absolute;
  content: 'OFF';
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  line-height: 28px;
  top: 4px;
  left: 4px;
  width: 36px;
  height: 28px;
  border-radius: 14px;
  background-color: var(--text-muted);
  color: var(--bg-primary);
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  transition: .3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.admin-section {
  margin-top: 16px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.admin-title {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  text-align: center;
}

.switch-toggle input[type="checkbox"]:disabled + label {
  opacity: 0.5;
  cursor: not-allowed;
}

.switch-toggle input[type="checkbox"]:checked + label::before {
  left: 32px;
  content: 'ON';
  color: white;
  background-color: var(--accent);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.switch-toggle.mic input[type="checkbox"]:checked + label::before {
  background-color: #ef4444;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

.switch-toggle.test input[type="checkbox"]:checked + label::before {
  content: 'TEST';
  left: 32px;
  background-color: #a0a0b5;
  box-shadow: 0 2px 8px rgba(255, 255, 255, 0.2);
}

@keyframes bgPulse {
  0% { box-shadow: inset 0 2px 6px rgba(0,0,0,0.5), inset 0 0 0 1px var(--border), 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: inset 0 2px 6px rgba(0,0,0,0.5), inset 0 0 0 1px var(--border), 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { box-shadow: inset 0 2px 6px rgba(0,0,0,0.5), inset 0 0 0 1px var(--border), 0 0 0 0 rgba(239, 68, 68, 0); }
}

.play-icon {
  width: 28px;
  height: 28px;
}

.audio-status {
  color: var(--warning);
  font-size: 0.85rem;
  margin-top: 8px;
}

/* ─── Volume ─── */
.volume-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.volume-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.volume-icon {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
}

/* Range slider */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-primary);
  border-radius: 3px;
  outline: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 8px var(--accent-glow);
  transition: transform var(--transition);
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* ─── Device Selection ─── */
.device-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg-card);
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  margin-bottom: 24px;
}

.device-control {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.device-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.device-select {
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.95rem;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
  appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23a0a0b5%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat, repeat;
  background-position: right .7em top 50%, 0 0;
  background-size: .65em auto, 100%;
}

.device-select:focus {
  border-color: var(--accent);
}

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

/* ─── Captions Toggle ─── */
.captions-toggle {
  display: flex;
  align-items: center;
}

.toggle-container {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.toggle-container input {
  display: none;
}

.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 13px;
  transition: all var(--transition);
  flex-shrink: 0;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all var(--transition);
}

.toggle-container input:checked + .toggle-switch {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle-container input:checked + .toggle-switch::after {
  transform: translateX(22px);
  background: white;
}

.toggle-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ─── Captions ─── */
.captions-container {
  flex: 1;
  min-height: 200px;
  max-height: 50vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-y: auto;
  scroll-behavior: smooth;
}

.captions-content {
  padding: 20px;
}

.caption-placeholder {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.9rem;
  text-align: center;
  padding: 40px 0;
}

.caption-line {
  font-size: 1.1rem;
  line-height: 1.7;
  color: var(--text-primary);
  margin-bottom: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--bg-card);
  animation: captionIn 0.3s ease;
}

@keyframes captionIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.english-caption {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
  margin-bottom: -8px;
  background: transparent;
  padding: 4px 12px;
}



.captions-container.hidden {
  display: none;
}

/* ─── Footer Info ─── */
.footer-info {
  text-align: center;
  padding: 8px 0;
}

.listener-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ─── Scrollbar ─── */
.captions-container::-webkit-scrollbar {
  width: 4px;
}

.captions-container::-webkit-scrollbar-track {
  background: transparent;
}

.captions-container::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* ─── Responsive ─── */
@media (min-width: 768px) {
  .main {
    padding: 32px 24px;
    gap: 28px;
  }

  .play-button {
    padding: 24px 48px;
    font-size: 1.2rem;
  }

  .caption-line {
    font-size: 1.2rem;
  }
}
