/* ============================================================
   AirDrop - Cyberpunk Terminal Theme
   ============================================================ */

/* --- CSS Variables --- */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #16213e;
  --accent: #00ff88;
  --accent-dim: #00cc6a;
  --text-primary: #e0e0e0;
  --text-secondary: #8892a4;
  --border: #2a2a3e;
  --danger: #ff4757;
  --warning: #ffa502;
  --font-display: 'JetBrains Mono', monospace;
  --font-body: 'Space Grotesk', sans-serif;
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
  --transition: 0.3s ease;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* --- Scanline Overlay --- */
.scanline-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 255, 136, 0.015) 2px,
    rgba(0, 255, 136, 0.015) 4px
  );
}

/* --- Custom Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--accent-dim);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--accent-dim) var(--bg-primary);
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-dim);
}

/* --- Icon --- */
.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  vertical-align: middle;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  background: transparent;
  color: var(--text-primary);
  white-space: nowrap;
  user-select: none;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg-primary);
  border-color: var(--accent);
  font-weight: 700;
}

.btn-primary:hover {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  color: var(--bg-primary);
  box-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
}

.btn-glow {
  box-shadow: 0 0 10px rgba(0, 255, 136, 0.15);
}

.btn-glow:hover {
  box-shadow: 0 0 25px rgba(0, 255, 136, 0.35), 0 0 50px rgba(0, 255, 136, 0.1);
}

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text-secondary);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 12px rgba(0, 255, 136, 0.15);
}

.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 0 15px rgba(255, 71, 87, 0.3);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
  gap: 5px;
}

.btn-sm .icon {
  width: 14px;
  height: 14px;
}

.btn-block {
  width: 100%;
}

/* ============================================================
   Inputs
   ============================================================ */
.input {
  padding: 12px 16px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition);
  width: 100%;
}

.input::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(0, 255, 136, 0.15);
}

.input-glow {
  box-shadow: 0 0 6px rgba(0, 255, 136, 0.08);
}

.input-glow:focus {
  box-shadow: 0 0 20px rgba(0, 255, 136, 0.2);
}

/* ============================================================
   Toast Notifications
   ============================================================ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
  animation: toastIn 0.3s ease forwards;
  max-width: 360px;
  word-break: break-word;
}

.toast.toast-success {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(0, 255, 136, 0.15);
}

.toast.toast-error {
  border-color: var(--danger);
  box-shadow: 0 4px 20px rgba(255, 71, 87, 0.15);
}

.toast.toast-warning {
  border-color: var(--warning);
  box-shadow: 0 4px 20px rgba(255, 165, 2, 0.15);
}

.toast.toast-out {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(40px);
  }
}

/* ============================================================
   HOME VIEW
   ============================================================ */

/* --- Hero --- */
.hero {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  padding: 60px 20px;
  text-align: center;
  position: relative;
}

.hero-content {
  max-width: 680px;
}

.hero-title {
  font-size: clamp(3rem, 8vw, 5.5rem);
  color: var(--accent);
  text-shadow:
    0 0 10px rgba(0, 255, 136, 0.5),
    0 0 30px rgba(0, 255, 136, 0.3),
    0 0 60px rgba(0, 255, 136, 0.15);
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}

.hero-subtitle {
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  color: var(--text-secondary);
  margin-bottom: 40px;
  letter-spacing: 0.02em;
}

.hero .btn-primary {
  padding: 16px 40px;
  font-size: 1.1rem;
}

/* --- Section Title --- */
.section-title {
  text-align: center;
  font-size: 1.5rem;
  color: var(--accent);
  margin-bottom: 40px;
  letter-spacing: 0.03em;
  text-shadow: 0 0 10px rgba(0, 255, 136, 0.2);
}

/* --- How It Works --- */
.how-it-works {
  padding: 60px 20px;
  max-width: 960px;
  margin: 0 auto;
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.step-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 24px;
  text-align: center;
  transition: all var(--transition);
}

.step-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(0, 255, 136, 0.1);
  transform: translateY(-4px);
}

.step-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0, 255, 136, 0.08);
  border: 1px solid rgba(0, 255, 136, 0.2);
}

.step-icon svg {
  width: 28px;
  height: 28px;
  stroke: var(--accent);
}

.step-title {
  font-size: 1.1rem;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.step-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* --- Join Room --- */
.join-room {
  padding: 60px 20px;
  max-width: 480px;
  margin: 0 auto;
}

.join-form {
  display: flex;
  gap: 12px;
}

.join-form .input {
  flex: 1;
  font-family: var(--font-display);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-align: center;
  font-size: 1.1rem;
}

/* --- Footer --- */
.footer {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

/* ============================================================
   ROOM VIEW
   ============================================================ */

/* --- Top Bar --- */
.room-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-left,
.topbar-center,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-center {
  flex: 1;
  justify-content: center;
}

.room-id-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.room-id-value {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--accent);
  letter-spacing: 0.2em;
  text-shadow: 0 0 8px rgba(0, 255, 136, 0.3);
}

/* --- Connection Status --- */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-secondary);
  flex-shrink: 0;
}

.status-indicator.connected .status-dot {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.5);
  animation: breathe 2s ease-in-out infinite;
}

.status-indicator.connecting .status-dot {
  background: var(--warning);
  box-shadow: 0 0 8px rgba(255, 165, 2, 0.5);
  animation: breathe 1s ease-in-out infinite;
}

.status-indicator.disconnected .status-dot {
  background: var(--danger);
  box-shadow: 0 0 8px rgba(255, 71, 87, 0.5);
}

.status-indicator.waiting .status-dot {
  background: var(--text-secondary);
  animation: breathe 3s ease-in-out infinite;
}

.status-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.status-indicator.connected .status-text {
  color: var(--accent);
}

.status-indicator.connecting .status-text {
  color: var(--warning);
}

.status-indicator.disconnected .status-text {
  color: var(--danger);
}

@keyframes breathe {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(0.85);
  }
}

/* --- Mobile Tabs --- */
.mobile-tabs {
  display: none;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.mobile-tab {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  border-bottom: 2px solid transparent;
}

.mobile-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.mobile-tab:hover {
  color: var(--text-primary);
}

/* --- Room Main --- */
.room-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* --- Panel --- */
.panel {
  display: flex;
  flex-direction: column;
  padding: 24px;
  overflow-y: auto;
}

.panel-send {
  border-right: 1px solid var(--border);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.panel-title .icon {
  stroke: var(--accent);
}

/* --- Drop Zone --- */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: rgba(0, 255, 136, 0.02);
  margin-bottom: 16px;
}

.drop-zone:hover {
  border-color: var(--accent-dim);
  background: rgba(0, 255, 136, 0.04);
}

.drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(0, 255, 136, 0.08);
  box-shadow: 0 0 30px rgba(0, 255, 136, 0.15);
}

.drop-zone-content {
  pointer-events: none;
}

.drop-zone-icon {
  width: 48px;
  height: 48px;
  stroke: var(--text-secondary);
  margin-bottom: 12px;
  transition: stroke var(--transition);
}

.drop-zone:hover .drop-zone-icon,
.drop-zone.dragover .drop-zone-icon {
  stroke: var(--accent);
}

.drop-zone-text {
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.drop-zone-hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* --- File List --- */
.file-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  margin-bottom: 16px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  transition: all var(--transition);
}

.file-item:hover {
  border-color: var(--accent-dim);
  box-shadow: 0 0 10px rgba(0, 255, 136, 0.06);
}

.file-item-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(0, 255, 136, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.file-item-icon svg {
  width: 18px;
  height: 18px;
  stroke: var(--accent);
}

.file-item-info {
  flex: 1;
  min-width: 0;
}

.file-item-name {
  font-size: 0.875rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.file-item-size {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.file-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* --- Progress Bar --- */
.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent), var(--accent-dim));
  background-size: 200% 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
  animation: flowGlow 2s linear infinite;
}

@keyframes flowGlow {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.file-item-progress {
  font-size: 0.7rem;
  color: var(--accent);
  font-family: var(--font-display);
  white-space: nowrap;
}

.file-item-complete .file-item-name {
  color: var(--accent);
}

/* --- Empty State --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-secondary);
  text-align: center;
  flex: 1;
}

.empty-icon {
  width: 48px;
  height: 48px;
  stroke: var(--border);
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 0.875rem;
}

/* ============================================================
   Chat Drawer
   ============================================================ */
.chat-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  transition: transform var(--transition);
}

.chat-drawer.open {
  /* no transform needed, chat-body controls visibility */
}

.chat-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 20px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.875rem;
  cursor: pointer;
  transition: color var(--transition);
}

.chat-toggle:hover {
  color: var(--accent);
}

.chat-toggle .icon {
  stroke: currentColor;
}

.chat-toggle-text {
  flex: 1;
  text-align: left;
}

.chat-badge {
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.chat-chevron {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  transition: transform var(--transition);
}

.chat-drawer.open .chat-chevron {
  transform: rotate(180deg);
}

.chat-body {
  display: none;
  flex-direction: column;
  max-height: 280px;
  border-top: 1px solid var(--border);
  animation: chatSlideUp 0.3s ease;
}

.chat-drawer.open .chat-body {
  display: flex;
}

@keyframes chatSlideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-messages {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-msg {
  max-width: 70%;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  line-height: 1.4;
  word-break: break-word;
}

.chat-msg.self {
  align-self: flex-end;
  background: rgba(0, 255, 136, 0.12);
  border: 1px solid rgba(0, 255, 136, 0.2);
  color: var(--text-primary);
}

.chat-msg.peer {
  align-self: flex-start;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.chat-msg-sender {
  font-size: 0.7rem;
  color: var(--accent);
  margin-bottom: 2px;
  font-family: var(--font-display);
}

.chat-msg.peer .chat-msg-sender {
  color: var(--text-secondary);
}

.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.chat-input {
  flex: 1;
  padding: 8px 12px;
  font-size: 0.85rem;
}

.chat-input-area .btn-sm {
  padding: 8px 12px;
}

.chat-input-area .btn-sm .icon {
  width: 16px;
  height: 16px;
}

/* ============================================================
   Download Button (in receive file list)
   ============================================================ */
.btn-download {
  padding: 4px 12px;
  font-size: 0.75rem;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-download:hover {
  background: var(--accent);
  color: var(--bg-primary);
  box-shadow: 0 0 10px rgba(0, 255, 136, 0.2);
}

.btn-download .icon {
  width: 14px;
  height: 14px;
}

/* ============================================================
   File Remove Button
   ============================================================ */
.btn-remove {
  padding: 4px 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.75rem;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
}

.btn-remove:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-remove .icon {
  width: 14px;
  height: 14px;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
  /* Home view */
  .hero {
    min-height: 50vh;
    padding: 40px 16px;
  }

  .hero-title {
    font-size: clamp(2.5rem, 10vw, 3.5rem);
  }

  .steps {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .step-card {
    padding: 24px 16px;
  }

  .join-form {
    flex-direction: column;
  }

  /* Room view */
  .room-topbar {
    padding: 10px 12px;
  }

  .topbar-center {
    order: -1;
    flex-basis: 100%;
    justify-content: center;
    margin-bottom: 4px;
  }

  .mobile-tabs {
    display: flex;
  }

  .room-main {
    grid-template-columns: 1fr;
  }

  .panel-send {
    border-right: none;
  }

  .panel {
    padding: 16px;
  }

  /* Mobile tab switching */
  .panel-send,
  .panel-receive {
    display: none;
  }

  .panel-send.active,
  .panel-receive.active {
    display: flex;
  }

  /* Chat drawer full width on mobile */
  .chat-body {
    max-height: 50vh;
  }

  .chat-msg {
    max-width: 85%;
  }

  /* Toast adjustments */
  .toast-container {
    top: 10px;
    right: 10px;
    left: 10px;
  }

  .toast {
    max-width: 100%;
  }
}

/* ============================================================
   Utility Classes
   ============================================================ */
.hidden {
  display: none !important;
}

.text-accent {
  color: var(--accent);
}

.text-danger {
  color: var(--danger);
}

.text-warning {
  color: var(--warning);
}

.text-secondary {
  color: var(--text-secondary);
}

/* ============================================================
   View Transition
   ============================================================ */
.view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#room-view {
  min-height: 100vh;
  height: 100vh;
}

/* ============================================================
   Loading Spinner (for connection states)
   ============================================================ */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
