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

:root {
  --primary: #6C5CE7;
  --primary-light: #A29BFE;
  --primary-dark: #5A4BD1;
  --accent: #00CEC9;
  --bg: #0F0F1A;
  --bg-card: #1A1A2E;
  --bg-card-hover: #222240;
  --text: #EEEEF0;
  --text-muted: #8888A0;
  --border: #2A2A45;
  --success: #00B894;
  --danger: #FF7675;
  --warning: #FDCB6E;
  --radius: 16px;
  --radius-sm: 10px;
}

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'SF Pro', 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  text-align: center;
  padding: 24px 0 16px;
}

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

.logo-icon {
  font-size: 32px;
}

h1 {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

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

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  transition: border-color 0.2s;
}

.card:hover {
  border-color: var(--primary);
}

.card.center {
  text-align: center;
}

.card h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}

.card p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 16px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  width: 100%;
  box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(108, 92, 231, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--accent);
  color: #0F0F1A;
  padding: 12px 24px;
}

.btn-secondary:hover {
  background: #00E0DB;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  margin-top: 16px;
}

.btn-ghost:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Divider */
.divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 8px 0;
  color: var(--text-muted);
  font-size: 14px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Code Input */
.code-input-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

#input-code {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 6px;
  text-align: center;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

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

#input-code::placeholder {
  color: var(--border);
  letter-spacing: 8px;
}

/* Room Code Display */
.room-code {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 8px;
  color: var(--accent);
  padding: 16px;
  background: rgba(0, 206, 201, 0.08);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-family: 'SF Mono', 'Consolas', monospace;
  word-break: break-all;
}

/* QR Container */
#qr-container {
  display: flex;
  justify-content: center;
  margin: 20px 0;
}

#qr-container canvas {
  border-radius: 12px;
  border: 3px solid var(--border);
}

/* Pulse animation */
.status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 14px;
  margin: 12px 0;
}

.pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  font-size: 14px;
  opacity: 0;
  transition: all 0.3s;
  z-index: 999;
  max-width: 90%;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  border-color: var(--danger);
  color: var(--danger);
}

.toast.success {
  border-color: var(--success);
  color: var(--success);
}

/* Utility */
.hidden {
  display: none !important;
}

/* ========== ROOM PAGE ========== */

/* Connection status bar */
.connection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.connection-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
}

.status-dot.connected {
  background: var(--success);
  box-shadow: 0 0 8px rgba(0, 184, 148, 0.5);
}

.room-code-small {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 2px;
}

/* Tab navigation */
.tabs {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 16px;
}

.tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
}

.tab.active {
  background: var(--primary);
  color: white;
}

.tab:not(.active):hover {
  color: var(--text);
}

/* Tab panels */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(108, 92, 231, 0.05);
}

.drop-zone-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.drop-zone-text {
  color: var(--text-muted);
  font-size: 14px;
}

.drop-zone-text strong {
  color: var(--primary-light);
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* Photo options */
.photo-options {
  display: flex;
  gap: 12px;
}

.photo-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 16px;
  background: var(--bg-card);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.photo-option:hover {
  border-color: var(--primary);
}

.photo-option-icon {
  font-size: 36px;
}

.photo-option input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* Text send */
.text-area-wrapper {
  position: relative;
}

.text-area-wrapper textarea {
  width: 100%;
  min-height: 140px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 16px;
  color: var(--text);
  resize: vertical;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}

.text-area-wrapper textarea:focus {
  border-color: var(--primary);
}

.text-area-wrapper textarea::placeholder {
  color: var(--text-muted);
}

.btn-send-text {
  margin-top: 12px;
  width: 100%;
}

/* Transfer list */
.transfer-list {
  margin-top: 20px;
}

.transfer-list h3 {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-weight: 500;
}

.transfer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 8px;
}

.transfer-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.transfer-info {
  flex: 1;
  min-width: 0;
}

.transfer-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.transfer-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
}

.transfer-progress {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.transfer-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 2px;
  transition: width 0.15s;
}

.transfer-status {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
}

.transfer-status.done {
  color: var(--success);
}

.transfer-status.sending {
  color: var(--primary-light);
}

/* Received items */
.received-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 8px;
}

.received-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
  line-height: 1.6;
}

.received-text-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.btn-small {
  padding: 6px 14px;
  font-size: 12px;
  border-radius: 6px;
}

.received-image-preview {
  max-width: 100%;
  border-radius: 8px;
  margin-bottom: 8px;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn-save-photo {
  background: var(--success) !important;
}

.btn-save-photo:hover {
  background: #00d4a0 !important;
}

.received-image-preview,
.received-item video {
  max-width: 100%;
  border-radius: 8px;
  margin-bottom: 8px;
}

/* ========== ROOM QR CODE ========== */
.room-qr-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  overflow: hidden;
}

.room-qr-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s;
}

.room-qr-toggle:hover {
  color: var(--text);
}

.room-qr-arrow {
  font-size: 10px;
  transition: transform 0.2s;
}

.room-qr-arrow.open {
  transform: rotate(180deg);
}

.room-qr-body {
  text-align: center;
  padding: 0 16px 16px;
}

.room-qr-body.hidden {
  display: none;
}

#room-qr-canvas canvas {
  border-radius: 10px;
  border: 2px solid var(--border);
}

.room-qr-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ========== EBOOK BANNER ========== */
.ebook-banner {
  display: block;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #1a1a2e 100%);
  border: 1px solid #e8a838;
  border-top: 3px solid #e8a838;
  border-radius: var(--radius);
  margin-bottom: 16px;
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  transition: all 0.3s;
}

.ebook-banner:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(232, 168, 56, 0.15);
}

.ebook-banner-inner {
  display: flex;
  align-items: center;
  padding: 20px 18px 14px;
  gap: 16px;
}

.ebook-left {
  flex: 1;
  min-width: 0;
}

.ebook-tag {
  display: inline-block;
  background: #e53e3e;
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 10px;
}

.ebook-title {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  line-height: 1.4;
  margin: 0 0 6px;
}

.ebook-highlight {
  color: #e8a838;
}

.ebook-desc {
  font-size: 12px;
  color: #999;
  margin: 0 0 10px;
}

.ebook-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.ebook-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
}

.ebook-pill-gold {
  background: #e8a838;
  color: #1a1a2e;
}

.ebook-pill-outline {
  background: transparent;
  color: #ccc;
  border: 1px solid #555;
}

.ebook-cta {
  display: inline-block;
  background: #e8a838;
  color: #1a1a2e;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 20px;
  border-radius: 8px;
  transition: background 0.2s;
}

.ebook-banner:hover .ebook-cta {
  background: #f0b84d;
}

.ebook-right {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.ebook-play-icon {
  width: 52px;
  height: 52px;
  background: #e8a838;
  color: #1a1a2e;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.ebook-trend {
  color: #00c9a7;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.ebook-footer {
  padding: 8px 18px;
  font-size: 11px;
  color: #666;
  border-top: 1px solid #2a2a45;
}

@media (max-width: 380px) {
  .ebook-title { font-size: 15px; }
  .ebook-right { display: none; }
  .ebook-banner-inner { padding: 16px 14px 10px; }
}

/* ========== SHOPEE POPUP ========== */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

.popup-overlay.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.popup-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 360px;
  width: 100%;
  overflow: hidden;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.popup-header {
  background: linear-gradient(135deg, #EE4D2D, #FF6633);
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 700;
  color: white;
}

.popup-body {
  padding: 24px 20px;
  text-align: center;
}

.popup-body p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 16px;
}

.popup-link {
  background: linear-gradient(135deg, #EE4D2D, #FF6633) !important;
  box-shadow: 0 4px 15px rgba(238, 77, 45, 0.3) !important;
  text-decoration: none;
  display: inline-block;
}

.popup-link:hover {
  box-shadow: 0 6px 20px rgba(238, 77, 45, 0.4) !important;
}

/* ========== VIP INPUT ========== */
.vip-input-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.vip-input-group input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text);
  outline: none;
}

.vip-input-group input:focus {
  border-color: var(--primary);
}

.vip-input-group input::placeholder {
  color: var(--text-muted);
  font-size: 13px;
}

/* Responsive */
@media (max-width: 480px) {
  .container {
    padding: 12px 12px;
  }

  .card {
    padding: 18px 14px;
  }

  .code-input-group {
    flex-direction: column;
  }

  .code-input-group .btn-secondary {
    width: 100%;
    padding: 14px;
  }

  #input-code {
    font-size: 22px;
    letter-spacing: 6px;
    padding: 14px 12px;
  }

  .room-code {
    font-size: 36px;
    letter-spacing: 8px;
  }

  .photo-options {
    flex-direction: column;
  }

  .tabs {
    font-size: 13px;
  }

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