/* --- Variables & Reset --- */
:root {
  --bg-body: #f3f4f6;
  --bg-card: #ffffff;
  --text-main: #111827;
  --text-muted: #6b7280;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-light: #e0e7ff;
  --success: #10b981;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

/* --- App Wrapper --- */
.app-wrapper {
  width: 100%;
  max-width: 1000px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* --- Header --- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 30px;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: #f0fdf4;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid #bbf7d0;
}

.dot {
  width: 8px;
  height: 8px;
  background-color: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

/* --- Layout Body --- */
.app-body {
  display: flex;
  min-height: 500px;
}

/* --- Sidebar --- */
.sidebar {
  width: 280px;
  background: #fafafa;
  border-right: 1px solid var(--border);
  padding: 25px;
  display: flex;
  flex-direction: column;
}

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

.sidebar-header h2 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.badge {
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: bold;
  padding: 2px 8px;
  border-radius: 10px;
}

.peer-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.peer-list li {
  padding: 12px 16px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s ease;
}

.peer-list li::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

.peer-list li:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.peer-list li.selected {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.empty-state {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.85rem;
  cursor: default !important;
  border: none !important;
  background: transparent !important;
  justify-content: center;
}
.empty-state::before { display: none; }

/* --- Content Area --- */
.content {
  flex: 1;
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* --- Drop Zone --- */
.drop-zone {
  border: 2px dashed #d1d5db;
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  background: #f9fafb;
  transition: all 0.2s ease;
}

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

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
}

.drop-zone-content svg {
  color: var(--accent);
}

.drop-zone-content p {
  font-size: 0.95rem;
}

.drop-zone-content strong {
  color: var(--accent);
}

.file-hint {
  font-size: 0.75rem;
  color: #9ca3af;
}

/* --- Action Bar --- */
.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
  padding: 15px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.selected-info {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.btn-send {
  padding: 12px 24px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-send:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-send:disabled {
  background: #d1d5db;
  cursor: not-allowed;
}

/* --- Transfers Section --- */
.transfers-section h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 15px;
}

.transfers-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 250px;
  overflow-y: auto;
}

.received-file, .progress-item {
  background: #ffffff;
  border: 1px solid var(--border);
  padding: 15px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}

.received-file a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.received-file a:hover { text-decoration: underline; }

/* --- ANIMATED PROGRESS BAR --- */
.progress-wrapper {
  flex-grow: 1;
  margin: 0 15px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  border-radius: 4px;
  /* THE MAGIC: Smooth animated transition */
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-text {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: right;
}

/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .app-body {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 15px 20px;
    max-height: 200px;
    overflow-y: auto;
  }

  .peer-list {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .peer-list li {
    flex: 1 1 auto;
    justify-content: center;
  }

  .content {
    padding: 20px;
  }

  .action-bar {
    flex-direction: column;
    gap: 15px;
    align-items: stretch;
  }

  .btn-send {
    width: 100%;
  }

  .drop-zone {
    padding: 30px 15px;
  }
}

/* --- Pairing Section (Sidebar) --- */
.pairing-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.btn-pair {
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1px dashed var(--accent);
  color: var(--accent);
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-pair:hover {
  background: var(--accent-light);
}

.paired-devices-list {
  margin-top: 15px;
}

.paired-devices-list h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.paired-devices-list ul {
  list-style: none;
  padding: 0;
}

.paired-devices-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 5px;
  font-size: 0.8rem;
}

.empty-state-small {
  font-size: 0.75rem;
  color: #9ca3af;
  font-style: italic;
  background: transparent !important;
  border: none !important;
  justify-content: center;
}

.btn-unpair {
  background: transparent;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 0.7rem;
  padding: 2px 6px;
}

.btn-unpair:hover {
  text-decoration: underline;
}

/* --- Pairing Dialog --- */
.pairing-dialog {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.dialog-content {
  background: #ffffff;
  padding: 30px;
  border-radius: 12px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.dialog-content h3 {
  font-size: 1.2rem;
  margin-bottom: 15px;
  color: var(--text-main);
}

.dialog-content p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 15px;
}

.pairing-options {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 15px;
}

.pairing-options button {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}

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

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

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn-secondary:hover {
  background: var(--accent-light);
}

.pair-code {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 10px;
  color: var(--accent);
  margin: 20px 0;
  font-family: 'Courier New', monospace;
  background: #f9fafb;
  padding: 15px;
  border-radius: 8px;
  border: 2px dashed var(--border);
}

.hint {
  font-size: 0.75rem !important;
  color: #9ca3af !important;
}

#pair-code-input {
  font-size: 1.8rem;
  letter-spacing: 8px;
  text-align: center;
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  margin: 10px 0 15px 0;
  font-family: 'Courier New', monospace;
  outline: none;
}

#pair-code-input:focus {
  border-color: var(--accent);
}

.error-msg {
  color: #ef4444 !important;
  font-size: 0.8rem !important;
  min-height: 20px;
  margin: 10px 0 !important;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  margin-top: 10px;
  text-decoration: underline;
}

/* Mobile Responsive for Pairing */
@media (max-width: 768px) {
  .pairing-options {
    flex-direction: column;
  }
  .dialog-content {
    padding: 20px;
  }
  .pair-code {
    font-size: 2rem;
    letter-spacing: 6px;
  }
}
/* --- Header Right Layout --- */
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-rename {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.2s;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

/* --- Pairing Section (Sidebar) --- */
.pairing-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.btn-pair {
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1px dashed var(--accent);
  color: var(--accent);
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-pair:hover {
  background: var(--accent-light);
}

.paired-devices-list {
  margin-top: 15px;
}

.paired-devices-list h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.paired-devices-list ul {
  list-style: none;
  padding: 0;
}

.paired-devices-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 5px;
  font-size: 0.8rem;
}

.empty-state-small {
  font-size: 0.75rem;
  color: #9ca3af;
  font-style: italic;
  background: transparent !important;
  border: none !important;
  justify-content: center;
}

.btn-unpair {
  background: transparent;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 0.7rem;
  padding: 2px 6px;
}

.btn-unpair:hover {
  text-decoration: underline;
}

/* --- Pairing Dialog --- */
.pairing-dialog {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.dialog-content {
  background: #ffffff;
  padding: 30px;
  border-radius: 12px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.dialog-content h3 {
  font-size: 1.2rem;
  margin-bottom: 15px;
  color: var(--text-main);
}

.dialog-content p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 15px;
}

.pairing-options {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 15px;
}

.pairing-options button {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}

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

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

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn-secondary:hover {
  background: var(--accent-light);
}

.pair-code {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 10px;
  color: var(--accent);
  margin: 20px 0;
  font-family: 'Courier New', monospace;
  background: #f9fafb;
  padding: 15px;
  border-radius: 8px;
  border: 2px dashed var(--border);
}

.hint {
  font-size: 0.75rem !important;
  color: #9ca3af !important;
}

#pair-code-input {
  font-size: 1.8rem;
  letter-spacing: 8px;
  text-align: center;
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  margin: 10px 0 15px 0;
  font-family: 'Courier New', monospace;
  outline: none;
  box-sizing: border-box;
}

#pair-code-input:focus {
  border-color: var(--accent);
}

.error-msg {
  color: #ef4444 !important;
  font-size: 0.8rem !important;
  min-height: 20px;
  margin: 10px 0 !important;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  margin-top: 10px;
  text-decoration: underline;
}

@media (max-width: 768px) {
  .pairing-options {
    flex-direction: column;
  }
  .dialog-content {
    padding: 20px;
  }
  .pair-code {
    font-size: 2rem;
    letter-spacing: 6px;
  }
  .btn-rename {
    max-width: 120px;
    font-size: 0.7rem;
  }
}
