/* FilePortal — WeTransfer-inspired UI */
:root {
  --accent: #409cff;
  --accent-hover: #2b7de9;
  --accent-light: rgba(64,156,255,0.08);
  --danger: #ff4757;
  --danger-hover: #e0313f;
  --success: #2ed573;
  --warning: #ffa502;
  --bg: #0a0a1a;
  --bg-card: #15152a;
  --bg-surface: #1e1e38;
  --bg-input: #252545;
  --border: rgba(255,255,255,0.08);
  --border-focus: var(--accent);
  --text: #f0f0f5;
  --text-muted: #8888a8;
  --text-dim: #5a5a7a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.4);
  --transition: 0.2s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ===== LAYOUT ===== */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== NAVBAR ===== */
.navbar {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.navbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.brand {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.5px;
}
.brand span { color: var(--accent); }
.nav-right { display: flex; align-items: center; gap: 20px; }
.nav-right span { color: var(--text-muted); font-size: 0.85rem; }
.nav-right a {
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: color var(--transition);
}
.nav-right a:hover { color: var(--text); }

/* ===== STORAGE STATUS ===== */
.storage-status {
  display: flex;
  gap: 20px;
  padding: 16px 0;
}
.storage-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.status-dot.online { background: var(--success); box-shadow: 0 0 8px rgba(46,213,115,0.4); }
.status-dot.offline { background: var(--danger); box-shadow: 0 0 8px rgba(255,71,87,0.4); }

/* ===== UPLOAD HERO ===== */
.upload-hero {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 48px;
  margin: 32px 0;
  text-align: center;
  border: 1px solid var(--border);
}
.upload-hero h2 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}
.upload-hero .subtitle {
  color: var(--text-muted);
  margin-bottom: 32px;
  font-size: 0.95rem;
}
.upload-area {
  border: 2px dashed rgba(255,255,255,0.12);
  border-radius: 16px;
  padding: 48px 32px;
  transition: all var(--transition);
  cursor: pointer;
  margin-bottom: 24px;
}
.upload-area:hover, .upload-area.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
}
.upload-area input[type="file"] { display: none; }
.upload-area label {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.upload-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  transition: transform var(--transition);
}
.upload-area:hover .upload-icon { transform: scale(1.1); }
.upload-label-text {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}
.upload-label-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
}
#file-name {
  color: var(--accent);
  font-weight: 500;
  font-size: 0.95rem;
  min-height: 1.4em;
}

.upload-options {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.upload-options .form-group {
  margin: 0;
}
.upload-options select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  cursor: pointer;
  appearance: auto;
}
.upload-options select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Progress */
.upload-progress {
  display: none;
  margin-top: 24px;
}
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #6dd5fa);
  border-radius: 3px;
  transition: width 0.3s;
  width: 0%;
}
.progress-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 28px;
  border: none;
  border-radius: 50px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  gap: 8px;
}
.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 16px rgba(64,156,255,0.3);
}
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(64,156,255,0.4);
}
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-sm { padding: 6px 16px; font-size: 0.8rem; }
.btn-ghost {
  background: rgba(255,255,255,0.06);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text);
}
.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  font-size: 0.9rem;
}

/* ===== CARDS / SECTIONS ===== */
.section {
  margin-bottom: 32px;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.section-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}
.section-header .count {
  background: var(--bg-surface);
  color: var(--text-muted);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  margin-left: 8px;
}

/* ===== FILE / LINK ITEMS ===== */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color var(--transition);
}
.item:hover {
  border-color: rgba(255,255,255,0.15);
}
.item-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.item-icon.synology { background: rgba(46,213,115,0.1); }
.item-icon.unas { background: rgba(255,165,2,0.1); }
.item-info {
  flex: 1;
  min-width: 0;
}
.item-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-meta {
  display: flex;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-success { background: rgba(46,213,115,0.15); color: var(--success); }
.badge-danger { background: rgba(255,71,87,0.15); color: var(--danger); }
.badge-warning { background: rgba(255,165,2,0.15); color: var(--warning); }
.badge-info { background: var(--accent-light); color: var(--accent); }

/* ===== LINK ITEM ===== */
.link-url {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  margin-top: 8px;
  max-width: 400px;
}
.link-url input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  outline: none;
  min-width: 0;
}
.link-url .btn-copy {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 2px 8px;
}
.link-url .btn-copy:hover { color: var(--accent-hover); }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="datetime-local"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color var(--transition);
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(64,156,255,0.15);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-group input[type="checkbox"] {
  accent-color: var(--accent);
  margin-right: 6px;
}

/* ===== LOGIN PAGE ===== */
.login-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: var(--bg);
}
.login-card {
  background: var(--bg-card);
  padding: 36px 32px;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 360px;
}
.login-card .form-group { margin-bottom: 12px; }
.login-card .form-group label { font-size: 0.8rem; margin-bottom: 4px; }
.login-card .form-group input { padding: 9px 12px; font-size: 0.88rem; }
.login-card h1 {
  text-align: center;
  margin-bottom: 4px;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.login-card h1 span { color: var(--accent); }
.login-card .subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 24px;
  font-size: 0.82rem;
}

/* ===== DOWNLOAD PAGE ===== */
.download-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: var(--bg);
}
.download-card {
  background: var(--bg-card);
  padding: 48px 40px;
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  text-align: center;
}
.download-card .file-icon {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 20px;
}
.download-card h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 8px;
  word-break: break-all;
  border: none;
  padding: 0;
}
.download-card .file-meta {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

/* ===== ALERTS ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.alert-error { background: rgba(255,71,87,0.1); color: #ff6b7a; border: 1px solid rgba(255,71,87,0.2); }
.alert-success { background: rgba(46,213,115,0.1); color: var(--success); border: 1px solid rgba(46,213,115,0.2); }

/* ===== MODAL ===== */
.modal-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  justify-content: center;
  align-items: center;
}
.modal-backdrop.active { display: flex; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  width: 90%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
}
.modal h3 {
  margin-bottom: 20px;
  font-size: 1.2rem;
  font-weight: 700;
}
.modal-close {
  float: right;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text); }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ===== FOOTER ===== */
.footer {
  text-align: center;
  padding: 32px 0;
  color: var(--text-dim);
  font-size: 0.8rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .upload-hero { padding: 32px 20px; }
  .upload-hero h2 { font-size: 1.4rem; }
  .upload-area { padding: 32px 16px; }
  .form-row { grid-template-columns: 1fr; }
  .item { flex-wrap: wrap; }
  .item-actions { width: 100%; justify-content: flex-end; }
  .upload-options { flex-direction: column; align-items: stretch; }
  .container { padding: 0 16px; }
  .p2p-pin-digit { width: 40px; height: 52px; font-size: 1.5rem; }
  .p2p-pin-input { width: 40px; height: 48px; font-size: 1.2rem; }
  .p2p-transfer-stats { flex-direction: column; gap: 4px; text-align: center; }
  .transfers-toolbar { flex-direction: column; }
  .search-box { min-width: 100%; }
  .filter-group { width: 100%; flex-wrap: wrap; }
  .filter-group select { flex: 1; min-width: 0; }
  .transfer-mode-selector { grid-template-columns: 1fr; }
  .mode-card { flex-direction: row; padding: 14px 16px; }
  .mode-card-desc { text-align: left; }
}

/* ===== TRANSFERS PAGE ===== */
.transfers-header {
  margin: 32px 0 24px;
}
.transfers-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.transfers-header h2 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.transfers-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.search-box {
  flex: 1;
  min-width: 200px;
  position: relative;
}
.search-box .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-dim);
  pointer-events: none;
}
.search-box input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition);
}
.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(64,156,255,0.1);
}
.search-box input::placeholder {
  color: var(--text-dim);
}
.filter-group {
  display: flex;
  gap: 8px;
}
.filter-group select {
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  outline: none;
  appearance: auto;
  transition: border-color var(--transition);
}
.filter-group select:focus {
  border-color: var(--accent);
}

/* ===== P2P ===== */
/* P2P Mode Selector — two cards */
.transfer-mode-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 28px;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}
.mode-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 16px;
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}
.mode-card:hover {
  border-color: rgba(255,255,255,0.15);
  background: rgba(30,30,56,0.8);
}
.mode-card.active {
  border-color: var(--accent);
  background: rgba(64,156,255,0.06);
  box-shadow: 0 0 0 1px var(--accent), 0 4px 16px rgba(64,156,255,0.1);
}
.mode-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.mode-card.active .mode-card-icon {
  background: rgba(64,156,255,0.15);
}
.mode-card-icon svg {
  width: 22px;
  height: 22px;
}
.mode-card-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  transition: color var(--transition);
}
.mode-card-desc {
  font-size: 0.75rem;
  color: var(--text-dim);
  line-height: 1.4;
  text-align: center;
}
.mode-card.active .mode-card-title { color: var(--accent); }
.mode-card-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.mode-card.active .mode-card-check {
  border-color: var(--accent);
  background: var(--accent);
}
.mode-card-check::after {
  content: '';
  display: none;
}
.mode-card.active .mode-card-check::after {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: white;
}

/* Login P2P section */
.login-p2p-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 24px 0;
  color: var(--text-dim);
  font-size: 0.8rem;
}
.login-p2p-divider::before,
.login-p2p-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* P2P PIN Display (sender) */
.p2p-pin-display {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 24px 0 20px;
}
.p2p-pin-digit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 64px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 2rem;
  font-weight: 800;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text);
}
.p2p-pin-separator {
  font-size: 1.5rem;
  color: var(--text-dim);
  margin: 0 4px;
}

/* P2P PIN Input (receiver) */
.p2p-pin-input-group {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 24px 0 8px;
}
.p2p-pin-input {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  font-family: 'SF Mono', 'Fira Code', monospace;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}
.p2p-pin-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(64,156,255,0.15);
}

/* P2P Status */
.p2p-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 20px 0 8px;
}
.p2p-pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: p2p-pulse-anim 1.5s ease-in-out infinite;
}
@keyframes p2p-pulse-anim {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(64,156,255,0.4); }
  50% { opacity: 0.7; box-shadow: 0 0 0 8px rgba(64,156,255,0); }
}

/* P2P Connection badge */
.p2p-connection-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(46,213,115,0.1);
  border: 1px solid rgba(46,213,115,0.2);
  border-radius: 50px;
  font-size: 0.85rem;
  color: var(--success);
  margin-bottom: 24px;
}

/* P2P Complete icon */
.p2p-complete-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(46,213,115,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--success);
  margin: 0 auto 16px;
  animation: p2p-pop 0.3s ease-out;
}
@keyframes p2p-pop {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* P2P Phase transitions */
.p2p-phase {
  animation: p2p-fade-in 0.25s ease-out;
}
@keyframes p2p-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* P2P Spinner */
.p2p-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--bg-surface);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: p2p-spin 0.8s linear infinite;
  margin: 24px auto;
}
@keyframes p2p-spin {
  to { transform: rotate(360deg); }
}

/* P2P Transfer stats */
.p2p-transfer-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg-surface); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ===== TABLES (legacy fallback) ===== */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-weight: 600; color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; }
tr:hover { background: var(--bg-surface); }
