@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&display=swap");

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

:root {
  --bg-primary: #ffffff;
  --bg-secondary: #fafafa;
  --bg-tertiary: #f0f0f0;
  --text-primary: #000000;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --border-primary: #e0e0e0;
  --border-light: #e0e0e0;
  --accent-primary: #000000;
  --accent-hover: #333333;
  --error: #ff0000;
  --success: #00aa00;
  --warning: #ff9900;
  --keyboard-bg: #f5f5f5;
  --keyboard-text: #000000;
  --shadow: rgba(0, 0, 0, 0.1);
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
}

.dark-mode {
  --bg-primary: #1a1a1a;
  --bg-secondary: #242424;
  --bg-tertiary: #2e2e2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0a0;
  --text-tertiary: #707070;
  --border-primary: #3a3a3a;
  --border-light: #2e2e2e;
  --accent-primary: #4a9eff;
  --accent-hover: #6bb3ff;
  --error: #ff6b6b;
  --success: #4ade80;
  --warning: #fbbf24;
  --keyboard-bg: #2e2e2e;
  --keyboard-text: #ffffff;
  --shadow: rgba(0, 0, 0, 0.3);
}

body {
  font-family: "JetBrains Mono", "Menlo", monospace;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background-color var(--transition-normal),
    color var(--transition-normal);
}

.header {
  position: sticky;
  top: 0;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-primary);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
}

.header-title {
  font-size: 1rem;
  font-weight: 700;
}

.header-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.theme-toggle,
.help-toggle {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text-primary);
  transition: background-color var(--transition-fast);
}

.theme-toggle:hover,
.help-toggle:hover {
  background: var(--bg-secondary);
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 3rem 2rem;
}

/* Views */
.view {
  display: none;
}

.view.active {
  display: block;
}

/* Home View */
.home-view {
  text-align: center;
}

.home-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.home-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 3rem;
}

.connection-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

.connection-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  padding: 2rem;
  text-align: left;
}

.connection-card-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.connection-card-icon {
  font-size: 1.5rem;
}

.btn {
  padding: 0.75rem 1.5rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 400;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: 2px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color var(--transition-fast),
    border-color var(--transition-fast);
  width: 100%;
}

.btn:hover {
  background: var(--bg-secondary);
  border-color: var(--accent-primary);
}

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

.btn-primary {
  background: var(--accent-primary);
  color: var(--bg-primary);
  border-color: var(--accent-primary);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* Code Display */
.code-section {
  margin-top: 1.5rem;
  display: none;
}

.code-section.active {
  display: block;
}

.code-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.code-display {
  width: 100%;
  min-height: 120px;
  max-height: 200px;
  padding: 1rem;
  font-family: inherit;
  font-size: 0.75rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: 2px;
  color: var(--text-primary);
  resize: vertical;
  word-break: break-all;
  line-height: 1.4;
}

.code-display:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.code-display[readonly] {
  background: var(--bg-tertiary);
}

.code-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.code-actions .btn {
  width: auto;
  flex: 1;
}

/* Status Messages */
.status-message {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  border-radius: 2px;
  display: none;
}

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

.status-message.info {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-primary);
}

.status-message.success {
  background: rgba(0, 170, 0, 0.1);
  color: var(--success);
  border: 1px solid var(--success);
}

.status-message.error {
  background: rgba(255, 0, 0, 0.1);
  color: var(--error);
  border: 1px solid var(--error);
}

.status-icon {
  font-size: 1rem;
}

/* Connected View */
.connected-view .peer-section {
  margin-bottom: 3rem;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.peer-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.peer-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 2px;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.peer-card:hover {
  border-color: var(--accent-primary);
}

.peer-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.peer-avatar {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border-radius: 2px;
  font-size: 1.5rem;
}

.peer-details {
  text-align: left;
}

.peer-name {
  font-weight: 700;
  font-size: 0.875rem;
}

.peer-status {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-tertiary);
}

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

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

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

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

.peer-action {
  color: var(--text-secondary);
  font-size: 0.75rem;
}

/* Transfer View */
.transfer-view .back-btn {
  margin-bottom: 2rem;
  width: auto;
}

.transfer-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.transfer-peer-name {
  font-size: 1.25rem;
  font-weight: 700;
}

/* Drop Zone */
.drop-zone {
  border: 2px dashed var(--border-primary);
  border-radius: 2px;
  padding: 4rem 2rem;
  text-align: center;
  transition: all var(--transition-fast);
  cursor: pointer;
  margin-bottom: 2rem;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent-primary);
  background: var(--bg-secondary);
}

.drop-zone-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.drop-zone-text {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.drop-zone-hint {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.file-input {
  display: none;
}

/* Transfer List */
.transfer-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.transfer-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  padding: 1rem 1.5rem;
  border-radius: 2px;
}

.transfer-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.transfer-file-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.transfer-file-icon {
  font-size: 1.25rem;
}

.transfer-file-name {
  font-weight: 700;
  font-size: 0.875rem;
}

.transfer-file-size {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.transfer-status {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.transfer-progress-bar {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.transfer-progress-fill {
  height: 100%;
  background: var(--accent-primary);
  transition: width 0.2s ease;
}

.transfer-progress-fill.completed {
  background: var(--success);
}

.transfer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.transfer-progress-text {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.transfer-cancel {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  background: transparent;
  border: 1px solid var(--border-primary);
  color: var(--error);
  cursor: pointer;
  font-family: inherit;
  border-radius: 2px;
  transition: all var(--transition-fast);
}

.transfer-cancel:hover {
  background: var(--error);
  color: var(--bg-primary);
}

.transfer-download {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  background: var(--accent-primary);
  border: 1px solid var(--accent-primary);
  color: var(--bg-primary);
  cursor: pointer;
  font-family: inherit;
  border-radius: 2px;
  transition: all var(--transition-fast);
}

.transfer-download:hover {
  background: var(--accent-hover);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 2rem;
  margin-bottom: 1rem;
}

.empty-state-text {
  font-size: 0.875rem;
}

/* Help Drawer */
.help-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal),
    visibility var(--transition-normal);
  z-index: 200;
}

.help-overlay.open {
  opacity: 1;
  visibility: visible;
}

.help-drawer {
  position: fixed;
  top: 0;
  right: -400px;
  width: 400px;
  max-width: 90vw;
  height: 100vh;
  background: var(--bg-primary);
  border-left: 1px solid var(--border-primary);
  padding: 2rem;
  transition: right var(--transition-normal);
  z-index: 201;
  overflow-y: auto;
}

.help-drawer.open {
  right: 0;
}

@media (max-width: 640px) {
  .help-drawer {
    width: 100vw;
    max-width: 100vw;
    right: -100vw;
  }

  .help-drawer.open {
    right: 0;
  }
}

.help-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-primary);
  padding: 0.5rem;
  line-height: 1;
}

.help-close:hover {
  opacity: 0.7;
}

.help-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  padding-right: 2rem;
}

.help-content {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.help-content h3 {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

.help-content h3:first-child {
  margin-top: 0;
}

.help-content p {
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.help-content ol,
.help-content ul {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

.help-content li {
  margin-bottom: 0.5rem;
}

.help-content code {
  background: var(--bg-tertiary);
  padding: 0.125rem 0.375rem;
  font-size: 0.75rem;
  border-radius: 2px;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  padding: 0.75rem 1.5rem;
  border-radius: 2px;
  box-shadow: 0 4px 12px var(--shadow);
  z-index: 300;
  opacity: 0;
  transition: all var(--transition-normal);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Responsive */
@media (max-width: 768px) {
  .connection-panel {
    grid-template-columns: 1fr;
  }

  .container {
    padding: 2rem 1rem;
  }
}

.hidden {
  display: none !important;
}
