/* ============================================
   Virtual Phone Camera — Mobile Page Styles
   Mobile-first responsive dark theme
   ============================================ */

:root {
  --bg-primary: #0F0F1A;
  --bg-secondary: #1A1A2E;
  --bg-tertiary: #252540;
  --bg-glass: rgba(30, 30, 55, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-glow: rgba(139, 92, 246, 0.3);

  --text-primary: #F1F1F6;
  --text-secondary: #9CA3AF;
  --text-muted: #6B7280;

  --accent-purple: #8B5CF6;
  --accent-cyan: #06B6D4;
  --accent-green: #10B981;
  --accent-amber: #F59E0B;
  --accent-red: #EF4444;

  --gradient-primary: linear-gradient(135deg, #8B5CF6 0%, #06B6D4 100%);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* ---- Header ---- */
.app-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  flex-shrink: 0;
}

.app-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-title {
  font-size: 18px;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ---- Camera Section ---- */
.camera-section {
  flex: 1;
  padding: 0 16px;
  min-height: 0;
}

.camera-container {
  position: relative;
  width: 100%;
  height: 100%;
  max-height: 50vh;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
}

.camera-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* Mirror front camera */
}

.camera-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  transition: opacity var(--transition-normal);
  z-index: 2;
}

.camera-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.camera-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 14px;
}

.camera-controls {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 3;
  display: flex;
  gap: 8px;
}

.cam-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.cam-btn:active {
  transform: scale(0.9);
  background: rgba(139, 92, 246, 0.5);
}

/* ---- Connection Section ---- */
.connection-section {
  flex-shrink: 0;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Status */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  backdrop-filter: blur(10px);
  transition: all var(--transition-normal);
}

.status-indicator.connected {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.08);
}

.status-indicator.connecting {
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.08);
}

.status-indicator.error {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.08);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.status-indicator.connected .status-dot {
  background: var(--accent-green);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
  animation: pulse 2s infinite;
}

.status-indicator.connecting .status-dot {
  background: var(--accent-amber);
  animation: pulse 1s infinite;
}

.status-indicator.error .status-dot {
  background: var(--accent-red);
}

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

.status-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.status-indicator.connected .status-text { color: var(--accent-green); }
.status-indicator.connecting .status-text { color: var(--accent-amber); }
.status-indicator.error .status-text { color: var(--accent-red); }

/* Input */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.input-row {
  display: flex;
  gap: 8px;
}

.peer-input {
  flex: 1;
  height: 44px;
  padding: 0 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 15px;
  outline: none;
  transition: border-color var(--transition-fast);
  -webkit-appearance: none;
}

.peer-input:focus {
  border-color: var(--accent-purple);
}

.peer-input::placeholder {
  color: var(--text-muted);
}

.btn-paste {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.btn-paste:active {
  background: rgba(139, 92, 246, 0.2);
  border-color: var(--accent-purple);
  color: var(--accent-purple);
}

/* Buttons */
.btn-primary {
  height: 48px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--gradient-primary);
  color: white;
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all var(--transition-normal);
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.3);
  position: relative;
  overflow: hidden;
}

.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.btn-primary:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.2);
}

.btn-primary:active::after {
  opacity: 1;
}

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

.btn-secondary {
  height: 44px;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  background: rgba(239, 68, 68, 0.1);
  color: var(--accent-red);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-secondary:active {
  background: rgba(239, 68, 68, 0.2);
  transform: scale(0.98);
}

/* ---- Info Section ---- */
.info-section {
  flex-shrink: 0;
  padding: 0 20px 8px;
}

.info-card {
  display: flex;
  gap: 10px;
  padding: 12px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.info-icon {
  flex-shrink: 0;
  color: var(--accent-cyan);
  margin-top: 2px;
}

.info-text p {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.info-text strong {
  color: var(--text-primary);
}

.info-sub {
  margin-top: 4px;
  font-size: 11px !important;
  color: var(--text-muted) !important;
}

/* ---- Footer ---- */
.app-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 20px 12px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ---- Loading Spinner ---- */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- Landscape adjustments ---- */
@media (orientation: landscape) {
  .app {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .app-header {
    width: 100%;
    padding: 8px 16px;
  }

  .camera-section {
    flex: 1;
    min-width: 50%;
    padding: 0 8px 8px 16px;
  }

  .camera-container {
    max-height: calc(100vh - 60px);
  }

  .connection-section {
    flex: 1;
    min-width: 40%;
    padding: 0 16px 8px 8px;
    justify-content: center;
  }

  .info-section {
    display: none;
  }

  .app-footer {
    display: none;
  }
}
