/* Soundbin.io - Cyberpunk Terminal Theme */

:root {
  --bg: #000000;
  --bg-dim: #0a0a0a;
  --fg: #00aaff;
  --fg-dim: #005588;
  --fg-bright: #44ccff;
  --amber: #ffb000;
  --amber-dim: #805800;
  --amber-bright: #ffc033;
  --red: #ff3333;
  --panel-bg: #0a0a14;
  --border: #1a2a3a;
  --glow: 0 0 10px var(--fg), 0 0 20px rgba(0, 170, 255, 0.3);
  --glow-amber: 0 0 10px var(--amber), 0 0 20px rgba(255, 176, 0, 0.3);
}

/* Amber theme */
body.amber {
  --fg: #ffb000;
  --fg-dim: #805800;
  --fg-bright: #ffc033;
  --panel-bg: #1a140a;
  --border: #3a2a1a;
  --glow: var(--glow-amber);
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
  font-size: 14px;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

/* Mic Init Overlay (on spectrogram) */
#mic-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

#mic-overlay.hidden {
  display: none;
}

#init-mic-btn {
  background: transparent;
  color: var(--fg);
  border: 2px solid var(--fg);
  padding: 0.75rem 1.5rem;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-shadow: var(--glow);
  box-shadow: var(--glow);
}

#init-mic-btn:hover {
  background: var(--fg);
  color: var(--bg);
  text-shadow: none;
}

#init-mic-btn:focus {
  outline: 2px solid var(--fg-bright);
  outline-offset: 4px;
}

/* Main App */
#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  display: flex;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--bg-dim);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.prompt {
  color: var(--fg);
  margin-right: 0.5rem;
}

.cursor {
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.header-controls {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

#theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  width: 24px;
  height: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.theme-indicator {
  width: 12px;
  height: 12px;
  background: var(--fg);
  border-radius: 50%;
}

/* Main content */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* Spectrogram */
#spectrogram-section {
  height: 200px;
  position: relative;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#waterfall {
  width: 100%;
  height: 100%;
  display: block;
}

.spectrogram-overlay {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  right: 0.5rem;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

#status-text {
  background: rgba(0, 0, 0, 0.7);
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

#status-text.listening {
  color: var(--fg);
  text-shadow: var(--glow);
}

#status-text.transmitting {
  color: var(--amber);
  text-shadow: var(--glow-amber);
}

#status-text.receiving {
  color: var(--fg-bright);
  animation: pulse 0.5s ease infinite;
}

@keyframes pulse {
  50% { opacity: 0.5; }
}

#signal-strength {
  background: rgba(0, 0, 0, 0.7);
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-family: monospace;
}

/* Terminal section */
#terminal {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

@media (min-width: 768px) {
  #terminal {
    flex-direction: row;
  }
}

/* TX Panel */
#tx-panel {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border);
  flex: 1;
  min-height: 150px;
}

@media (min-width: 768px) {
  #tx-panel {
    border-bottom: none;
    border-right: 1px solid var(--border);
    flex: 0 0 50%;
  }
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.label {
  font-weight: 500;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
}

.size-indicator {
  font-size: 0.75rem;
  color: var(--fg-dim);
}

#tx-input {
  flex: 1;
  width: 100%;
  background: var(--bg);
  color: var(--fg);
  border: none;
  padding: 1rem;
  font-family: inherit;
  font-size: 0.9rem;
  resize: none;
  min-height: 80px;
}

#tx-input::placeholder {
  color: var(--fg-dim);
}

#tx-input:focus {
  outline: none;
  background: var(--bg-dim);
}

.tx-controls {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--panel-bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.tx-controls button {
  flex: 1;
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

#tx-btn {
  background: var(--fg);
  color: var(--bg);
  border: none;
}

#tx-btn:disabled {
  background: var(--fg-dim);
  cursor: not-allowed;
  opacity: 0.5;
}

#tx-btn:not(:disabled):hover {
  background: var(--fg-bright);
  box-shadow: var(--glow);
}

#clear-tx-btn {
  background: transparent;
  color: var(--fg-dim);
  border: 1px solid var(--border);
}

#clear-tx-btn:hover {
  color: var(--fg);
  border-color: var(--fg-dim);
}

/* RX Panel */
#rx-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 150px;
  overflow: hidden;
}

@media (min-width: 768px) {
  #rx-panel {
    flex: 0 0 50%;
  }
}

#rx-panel .panel-header button {
  background: transparent;
  color: var(--fg-dim);
  border: 1px solid var(--border);
  padding: 0.25rem 0.5rem;
  font-family: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

#rx-panel .panel-header button:hover {
  color: var(--fg);
  border-color: var(--fg-dim);
}

#rx-log {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 1rem;
  background: var(--bg);
  font-size: 0.85rem;
}

.log-entry {
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--border);
  word-break: break-all;
}

.log-entry:last-child {
  border-bottom: none;
}

.log-entry.system {
  color: var(--fg-dim);
}

.log-entry.received {
  color: var(--fg-bright);
}

.log-entry.error {
  color: var(--red);
}

.log-entry .timestamp {
  color: var(--fg-dim);
  margin-right: 0.5rem;
  font-size: 0.75rem;
}

.log-entry .data {
  cursor: pointer;
  padding: 0.25rem;
  margin-top: 0.25rem;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  display: block;
}

.log-entry .data:hover {
  border-color: var(--fg-dim);
}

.log-entry .copy-hint {
  font-size: 0.7rem;
  color: var(--fg-dim);
  margin-left: 0.5rem;
}

/* Last Received Display */
#last-received {
  padding: 1rem;
  background: var(--panel-bg);
  border-bottom: 2px solid var(--fg);
}

#last-received.flash {
  animation: receivedFlash 0.5s ease;
}

@keyframes receivedFlash {
  0%, 100% { background: var(--panel-bg); }
  50% { background: rgba(0, 170, 255, 0.2); }
}

body.amber #last-received.flash {
  animation: receivedFlashAmber 0.5s ease;
}

@keyframes receivedFlashAmber {
  0%, 100% { background: var(--panel-bg); }
  50% { background: rgba(255, 176, 0, 0.2); }
}

.last-received-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.received-label {
  font-weight: 600;
  color: var(--fg-bright);
  text-shadow: var(--glow);
  letter-spacing: 0.1em;
}

#received-meta {
  font-size: 0.75rem;
  color: var(--fg-dim);
}

#received-data {
  background: var(--bg);
  border: 1px solid var(--fg-dim);
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--fg-bright);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 150px;
  overflow-y: auto;
}

#copy-received-btn {
  width: 100%;
  padding: 0.75rem;
  background: var(--fg);
  color: var(--bg);
  border: none;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

#copy-received-btn:hover {
  background: var(--fg-bright);
  box-shadow: var(--glow);
}

#copy-received-btn.copied {
  background: var(--fg-dim);
}

/* RX Waiting Indicator */
#rx-waiting {
  padding: 2rem;
  text-align: center;
  color: var(--fg-dim);
}

.waiting-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.pulse-dot {
  width: 10px;
  height: 10px;
  background: var(--fg);
  border-radius: 50%;
  animation: pulseDot 2s ease-in-out infinite;
}

@keyframes pulseDot {
  0%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
    box-shadow: 0 0 10px var(--fg);
  }
}

/* Footer */
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: var(--bg-dim);
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--fg-dim);
  flex-shrink: 0;
}

.status-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
}

.status-indicator.on {
  background: var(--fg);
  box-shadow: 0 0 8px var(--fg);
}

footer a {
  color: var(--fg-dim);
  text-decoration: none;
}

footer a:hover {
  color: var(--fg);
  text-decoration: underline;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--fg-dim);
}

/* Focus visible for accessibility */
:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

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