/* ═══════════════════════════════════════════════
   LocalDrop — style.css
   ═══════════════════════════════════════════════ */

:root {
  --bg: #111111;
  --surface: #1c1c1c;
  --surface2: #252525;
  --border: #2e2e2e;
  --accent: #22d3b5;
  --accent-dim: rgba(34,211,181,0.15);
  --danger: #ff5f5f;
  --warn: #f59e0b;
  --text: #f0f0f0;
  --text-sub: #888;
  --radius: 14px;
  --radius-sm: 8px;
}

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

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

/* ─── Screens ───────────────────────────────── */
.screen {
  display: none;
  height: 100%;
  overflow-y: auto;
  flex-direction: column;
}
.screen.active { display: flex; }

/* ─── Top Bar ───────────────────────────────── */
.top-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}

.bar-title {
  flex: 1;
  font-weight: 700;
  font-size: 16px;
}

.back-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 15px;
  cursor: pointer;
  padding: 4px 8px 4px 0;
  white-space: nowrap;
}

.peer-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot.green { background: var(--accent); box-shadow: 0 0 6px var(--accent); }

/* ─── Status Chips ──────────────────────────── */
.status-chip {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--surface2);
  color: var(--text-sub);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.status-chip.connected {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}
.status-chip.warn {
  background: rgba(245,158,11,0.15);
  color: var(--warn);
  border-color: var(--warn);
}

/* ─── Home Screen ───────────────────────────── */
#s-home {
  justify-content: center;
  align-items: center;
  gap: 32px;
  padding: 24px;
}

.hero {
  text-align: center;
}

.logo {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--text);
  margin-bottom: 8px;
}

.tagline {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.sub-tagline {
  font-size: 13px;
  color: var(--text-sub);
  margin-top: 4px;
}

.free-badge {
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  padding: 5px 14px;
  border-radius: 20px;
}

.connect-note {
  font-size: 13px;
  color: var(--text-sub);
  text-align: center;
  line-height: 1.7;
  max-width: 400px;
}
.connect-note strong { color: var(--text); }

.home-actions {
  display: flex;
  gap: 16px;
  width: 100%;
  max-width: 400px;
}

/* ─── Card Buttons ──────────────────────────── */
.card-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 22px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.1s;
  text-align: center;
}
.card-btn:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.card-btn:active { transform: scale(0.97); }
.card-btn.wide {
  flex: none;
  width: 100%;
  max-width: 400px;
  flex-direction: row;
  justify-content: center;
  gap: 12px;
}
.card-btn .btn-icon { font-size: 28px; }
.card-btn strong { font-size: 16px; }
.card-btn .btn-desc {
  font-size: 12px;
  color: var(--text-sub);
  display: block;
}

/* ─── Link / Danger buttons ─────────────────── */
.link-btn {
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 13px;
  cursor: pointer;
  padding: 6px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-btn.danger { color: var(--danger); }
.link-btn:hover { color: var(--text); }
.link-btn.danger:hover { opacity: 0.8; }

/* ─── Primary Button ────────────────────────── */
.primary-btn {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s;
}
.primary-btn:hover { opacity: 0.88; }
.primary-btn:active { opacity: 0.75; }

.send-btn {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.send-btn:hover { opacity: 0.88; }

/* ─── Divider ───────────────────────────────── */
.divider {
  width: 100%;
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-sub);
  font-size: 12px;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--border);
}

/* ─── Send Screen ───────────────────────────── */
#s-send {
  padding-bottom: 24px;
}

.qr-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 24px 18px;
}

@media (min-width: 540px) {
  .qr-area { flex-direction: row; align-items: flex-start; }
}

.qr-wrap {
  background: #fff;
  border-radius: var(--radius);
  padding: 12px;
  flex-shrink: 0;
}
.qr-wrap img, .qr-wrap canvas { display: block; }

.qr-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.hint { font-size: 14px; color: var(--text-sub); }
.hint-small { font-size: 12px; color: var(--text-sub); }

.url-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

.url-text {
  font-family: monospace;
  font-size: 12px;
  color: var(--accent);
  word-break: break-all;
  flex: 1;
}

.copy-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ─── Receive Screen ────────────────────────── */
#s-receive {
  padding-bottom: 24px;
}

.join-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 24px 18px;
}

.join-card {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.join-card h3 {
  font-size: 14px;
  color: var(--text-sub);
  margin-bottom: 12px;
  font-weight: 600;
}

.join-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.text-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.text-input::placeholder { color: var(--text-sub); }
.text-input:focus { border-color: var(--accent); }

#qr-reader {
  width: 300px;
  max-width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
}

/* ─── Connecting Screen ─────────────────────── */
#s-connecting {
  justify-content: center;
  align-items: center;
}

.center-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.conn-title { font-size: 18px; font-weight: 700; }
.conn-sub { font-size: 14px; color: var(--text-sub); }

/* ─── Transfer Screen ───────────────────────── */
#s-transfer { overflow: hidden; }

.transfer-layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr 280px;
  gap: 0;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

@media (min-width: 640px) {
  .transfer-layout {
    grid-template-columns: 1fr 320px;
    grid-template-rows: 1fr;
  }
}

/* ─── File Panel ────────────────────────────── */
.file-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px 20px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
  flex-shrink: 0;
  margin: 16px;
  text-align: center;
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.dz-icon { font-size: 32px; }
.dz-text { font-size: 15px; font-weight: 600; pointer-events: none; }
.dz-sub { font-size: 12px; color: var(--text-sub); pointer-events: none; }

.file-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ─── File Items ────────────────────────────── */
.file-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: grid;
  gap: 6px;
}

.fi-info {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.fi-name {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.fi-size { font-size: 12px; color: var(--text-sub); white-space: nowrap; }

.fi-progress {
  background: var(--border);
  border-radius: 4px;
  height: 4px;
  overflow: hidden;
}
.fi-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.15s;
}
.fi-bar.done { background: #4ade80; }

.fi-status {
  font-size: 12px;
  color: var(--text-sub);
}

/* ─── Chat Panel ────────────────────────────── */
.chat-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

@media (min-width: 640px) {
  .chat-panel { border-top: none; border-left: 1px solid var(--border); }
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-msg {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  word-break: break-word;
}
.chat-msg.me {
  background: var(--accent);
  color: #000;
  font-weight: 500;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.chat-msg.them {
  background: var(--surface2);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input { flex: 1; }

/* ─── Server Mode ───────────────────────────── */
#s-server {
  padding-bottom: 24px;
}

.server-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 16px;
}

@media (min-width: 640px) {
  .server-layout { grid-template-columns: 1fr 1fr; }
}

.server-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.server-card h3 {
  font-size: 15px;
  font-weight: 700;
}

.dl-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  flex-wrap: wrap;
}

/* ─── Flash Messages ────────────────────────── */
.flash-msg {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 14px;
  z-index: 9999;
  animation: fade-in-up 0.25s ease, fade-out 0.3s ease 1.7s forwards;
  white-space: nowrap;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}

@keyframes fade-in-up {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes fade-out {
  to { opacity: 0; }
}

/* ─── Scrollbar ─────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
