/* app.css — p2p-share */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* ── Theme tokens ──────────────────────────────────────────────────────────── */
:root {
  /* dark (default) */
  --bg:           #0f0f0f;
  --bg-panel:     #1a1a1a;
  --bg-raised:    #222222;
  --bg-hover:     #2a2a2a;
  --border:       #2e2e2e;
  --border-focus: #555;

  --text:         #f0f0f0;
  --text-muted:   #888;
  --text-dim:     #555;

  --accent:       #6366f1;
  --accent-hover: #818cf8;
  --accent-text:  #fff;
  --accent-soft:  rgba(99, 102, 241, 0.12);

  --red:          #ef4444;
  --red-soft:     rgba(239, 68, 68, 0.1);
  --green:        #22c55e;
  --green-soft:   rgba(34, 197, 94, 0.1);

  --sans: 'Inter', sans-serif;
  --mono: 'IBM Plex Mono', monospace;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --shadow:    0 4px 24px rgba(0,0,0,0.4);
  --transition: 160ms ease;
}

[data-theme="light"] {
  --bg:           #f5f5f7;
  --bg-panel:     #ffffff;
  --bg-raised:    #f0f0f2;
  --bg-hover:     #e8e8ec;
  --border:       #e2e2e6;
  --border-focus: #aaa;

  --text:         #111111;
  --text-muted:   #777;
  --text-dim:     #aaa;

  --accent:       #6366f1;
  --accent-hover: #4f52d4;
  --accent-text:  #fff;
  --accent-soft:  rgba(99, 102, 241, 0.1);

  --red:          #dc2626;
  --red-soft:     rgba(220, 38, 38, 0.08);
  --green:        #16a34a;
  --green-soft:   rgba(22, 163, 74, 0.1);

  --shadow: 0 4px 24px rgba(0,0,0,0.08);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

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

/* ── Header ────────────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.logo-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
}

.logo-text span { color: var(--accent); }

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Connection status */
.conn-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  font-family: var(--mono);
}

.conn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
  transition: background var(--transition);
}

.conn-status.online .conn-dot  { background: var(--green); box-shadow: 0 0 6px var(--green); animation: pulse-dot 2.5s ease infinite; }
.conn-status.online            { color: var(--green); }
.conn-status.offline .conn-dot { background: var(--red); }
.conn-status.offline           { color: var(--red); }

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

/* Theme toggle + icon buttons */
.btn-icon {
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  font-size: 16px;
}
.btn-icon:hover {
  color: var(--text);
  border-color: var(--border);
  background: var(--bg-raised);
}

/* ── Offline banner ─────────────────────────────────────────────────────────── */
.conn-warning {
  background: var(--red-soft);
  border-bottom: 1px solid var(--red);
  padding: 9px 28px;
  font-size: 13px;
  color: var(--red);
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

/* ── Main ───────────────────────────────────────────────────────────────────── */
.app-main {
  flex: 1;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ── Tabs ───────────────────────────────────────────────────────────────────── */
.tab-strip {
  display: flex;
  background: var(--bg-raised);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 28px;
  gap: 4px;
}

.tab-btn {
  flex: 1;
  padding: 9px 16px;
  background: none;
  border: none;
  border-radius: 7px;
  color: var(--text-muted);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  background: var(--bg-panel);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

/* ── Panel / Card ───────────────────────────────────────────────────────────── */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}

.panel-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 16px;
  letter-spacing: 0.01em;
}

/* ── Drop zone ──────────────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-raised);
  user-select: none;
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-icon {
  font-size: 32px;
  margin-bottom: 10px;
  opacity: 0.5;
}
.drop-primary {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}
.drop-sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* File selected */
.file-selected {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-icon-wrap {
  width: 38px;
  height: 38px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--accent);
}

.file-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  word-break: break-all;
  line-height: 1.3;
}
.file-size {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: -0.1px;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99,102,241,0.35);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover {
  border-color: var(--border-focus);
  background: var(--bg-raised);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  padding: 6px 10px;
}
.btn-ghost:hover { color: var(--text); background: var(--bg-raised); }

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--border);
}
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); }

.btn-full { width: 100%; }

/* ── Code input (receive tab) ───────────────────────────────────────────────── */
/* ── Receive tab ─────────────────────────────────────────────────────────── */
.receive-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.receive-icon {
  width: 44px;
  height: 44px;
  background: var(--accent-soft);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--accent);
  flex-shrink: 0;
}

.receive-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.receive-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Individual code character boxes */
.code-boxes {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.code-box {
  width: 48px;
  height: 58px;
  background: var(--bg-raised);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
  caret-color: transparent;
  -webkit-tap-highlight-color: transparent;
}

.code-box:focus {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.code-sep {
  color: var(--text-dim);
  font-size: 18px;
  font-weight: 300;
  flex-shrink: 0;
  margin: 0 2px;
  user-select: none;
}

@media (max-width: 400px) {
  .code-box { width: 42px; height: 52px; font-size: 20px; }
  .code-boxes { gap: 6px; }
}

/* ── Settings panel ─────────────────────────────────────────────────────────── */
.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 62px 20px 20px;
  pointer-events: none;
}

.settings-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 300px;
  pointer-events: all;
  animation: slide-in 150ms ease;
  box-shadow: var(--shadow);
}
@keyframes slide-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.settings-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.settings-body { padding: 16px 18px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition);
}
.form-input:focus { border-color: var(--accent); }

.form-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
  line-height: 1.5;
}

/* ── Transfer modal ─────────────────────────────────────────────────────────── */
.transfer-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.transfer-modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: modal-in 200ms ease;
  color: var(--text);
  font-family: var(--sans);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.transfer-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--border);
}

.transfer-modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.transfer-modal-body {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.transfer-modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

/* ── Code display ───────────────────────────────────────────────────────────── */
.code-display {
  text-align: center;
  padding: 22px 16px;
  background: var(--bg-raised);
  border-radius: var(--radius);
}

.code-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 500;
}

.code-value {
  font-size: 38px;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--accent);
  font-family: var(--mono);
  margin-bottom: 16px;
}

/* ── Progress ───────────────────────────────────────────────────────────────── */
.progress-wrap {
  background: var(--bg-raised);
  border-radius: var(--radius);
  padding: 16px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.progress-label { font-size: 13px; color: var(--text-muted); }
.progress-pct   { font-size: 13px; font-weight: 600; color: var(--accent); font-family: var(--mono); }

.progress-track {
  height: 4px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 300ms ease;
}

.progress-bytes {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
  text-align: right;
  font-family: var(--mono);
}

/* ── Meta grid ──────────────────────────────────────────────────────────────── */
.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.meta-cell {
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.meta-key {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 500;
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.meta-val {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  word-break: break-all;
  font-family: var(--mono);
}

/* ── Error / success ────────────────────────────────────────────────────────── */
.error-box {
  background: var(--red-soft);
  border: 1px solid var(--red);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--red);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-weight: 500;
}

.success-box {
  background: var(--green-soft);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
}
.success-icon { font-size: 28px; margin-bottom: 6px; }
.success-text { font-size: 14px; font-weight: 500; color: var(--green); }

/* ── Waiting dots ───────────────────────────────────────────────────────────── */
.status-waiting {
  display: flex;
  justify-content: center;
  gap: 7px;
  padding: 16px 0 8px;
}
.waiting-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: waiting-bounce 1.3s ease-in-out infinite;
}
.waiting-dot:nth-child(2) { animation-delay: 0.18s; }
.waiting-dot:nth-child(3) { animation-delay: 0.36s; }
@keyframes waiting-bounce {
  0%, 80%, 100% { opacity: 0.2; transform: scale(0.75); }
  40%            { opacity: 1;   transform: scale(1.2); }
}

/* ── Utilities ──────────────────────────────────────────────────────────────── */
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: 13px; }
[x-cloak]    { display: none !important; }


/* ── Mobile responsive ───────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .app-header  { padding: 12px 16px; }
  .app-main    { padding: 24px 16px 80px; }
  .panel       { padding: 18px 16px; }

  .tab-btn     { font-size: 13px; padding: 8px 12px; }

  .drop-zone   { padding: 28px 16px; }
  .drop-icon   { font-size: 26px; }

  .btn         { padding: 13px 16px; font-size: 14px; }

  .transfer-modal-overlay { padding: 0; align-items: flex-end; }
  .transfer-modal {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-width: 100%;
    animation: modal-in-mobile 220ms ease;
  }
  @keyframes modal-in-mobile {
    from { opacity: 0; transform: translateY(40px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  .code-value  { font-size: 30px; letter-spacing: 0.2em; }
  .meta-grid   { grid-template-columns: 1fr 1fr; gap: 6px; }
}