/* ============================================================
   PROJECT FACTORY — Design System
   Dark mode, glassmorphism, premium mobile-first
   ============================================================ */

/* --- CSS Variables --- */
:root {
  --bg-primary: #07070c;
  --bg-secondary: #0e0e16;
  --bg-card: #141420;
  --bg-elevated: #1a1a28;
  --bg-glass: rgba(255, 255, 255, 0.04);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-active: rgba(99, 102, 241, 0.4);

  --accent-primary: #6366f1;
  --accent-secondary: #8b5cf6;
  --accent-glow: rgba(99, 102, 241, 0.25);
  --gradient-accent: linear-gradient(135deg, #6366f1, #8b5cf6);

  --color-success: #22c55e;
  --color-danger: #ef4444;
  --color-warning: #f59e0b;

  --text-primary: #f0f0f6;
  --text-secondary: #7a7a96;
  --text-muted: #4a4a64;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;

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

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

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

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 430px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

/* --- Top Bar --- */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 8px) 16px 8px;
  background: linear-gradient(180deg, var(--bg-primary) 60%, transparent);
  position: relative;
  z-index: 100;
  flex-shrink: 0;
}

.project-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
  padding: 6px 14px 6px 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}

.project-selector:active {
  transform: scale(0.96);
  border-color: var(--border-active);
}

.project-icon {
  font-size: 18px;
  line-height: 1;
}

.project-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-chevron {
  font-size: 10px;
  color: var(--text-secondary);
  transition: transform 0.2s ease;
}

.project-selector.open .project-chevron {
  transform: rotate(180deg);
}

.project-count {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
  padding: 4px 10px;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}

/* --- Project Dropdown --- */
.project-dropdown {
  position: absolute;
  top: calc(var(--safe-top) + 52px);
  left: 16px;
  right: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 6px;
  z-index: 200;
  opacity: 0;
  transform: translateY(-8px) scale(0.97);
  pointer-events: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  -webkit-backdrop-filter: blur(40px);
  backdrop-filter: blur(40px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.project-dropdown.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.project-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease;
}

.project-dropdown-item:active,
.project-dropdown-item.active {
  background: var(--bg-elevated);
}

.project-dropdown-item .item-icon { font-size: 20px; }
.project-dropdown-item .item-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
}
.project-dropdown-item .item-count {
  font-size: 12px;
  color: var(--text-secondary);
}
.project-dropdown-item.active .item-name {
  color: var(--accent-primary);
}

/* --- Main Content (Swipe Area) --- */
.main-content {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Tinder Cards (preserving user's class names) --- */
.tinder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.loaded.tinder { opacity: 1; }

.tinder--status {
  position: absolute;
  top: 38%;
  margin-top: -50px;
  z-index: 2;
  width: 100%;
  text-align: center;
  pointer-events: none;
}

.tinder--status i {
  font-size: 100px;
  opacity: 0;
  transform: scale(0.3);
  transition: all 0.2s ease-in-out;
  position: absolute;
  width: 100px;
  margin-left: -50px;
  text-shadow: 0 0 40px currentColor;
}

.tinder_love .fa-heart {
  opacity: 0.85;
  transform: scale(1);
  color: var(--color-success);
}

.tinder_nope .fa-remove {
  opacity: 0.85;
  transform: scale(1);
  color: var(--color-danger);
}

.tinder--cards {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 4px 14px 0;
  z-index: 1;
}

.tinder--card {
  display: block;
  width: calc(100% - 28px);
  max-width: 400px;
  height: calc(100% - 10px);
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: absolute;
  will-change: transform;
  transition: all 0.3s ease-in-out;
  cursor: grab;
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.3),
    0 20px 60px rgba(0, 0, 0, 0.2);
}

.moving.tinder--card {
  transition: none;
  cursor: grabbing;
}

.tinder--card img {
  width: 100%;
  height: 78%;
  object-fit: cover;
  pointer-events: none;
  display: block;
}

.tinder--card .card-info {
  padding: 14px 16px;
}

.tinder--card h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  pointer-events: none;
  margin-bottom: 4px;
}

.tinder--card p {
  font-size: 13px;
  color: var(--text-secondary);
  pointer-events: none;
}

.tinder--card.removed { display: none; }

.no-images-msg {
  text-align: center;
  padding: 40px 20px;
  display: none;
}

.no-images-msg .empty-icon {
  font-size: 56px;
  margin-bottom: 16px;
  opacity: 0.6;
}

.no-images-msg h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.no-images-msg p {
  font-size: 14px;
  color: var(--text-secondary);
}

/* --- Bottom Bar --- */
.bottom-bar {
  padding: 10px 20px calc(var(--safe-bottom) + 10px);
  flex-shrink: 0;
  position: relative;
  z-index: 50;
}

.swipe-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.action-btn {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border-glass);
  background: var(--bg-glass);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  font-size: 20px;
}

.action-btn:active {
  transform: scale(0.9);
}

.action-btn.nope-btn {
  color: var(--color-danger);
  border-color: rgba(239, 68, 68, 0.2);
}
.action-btn.nope-btn:active {
  background: rgba(239, 68, 68, 0.15);
  box-shadow: 0 0 24px rgba(239, 68, 68, 0.2);
}

.action-btn.like-btn {
  color: var(--color-success);
  border-color: rgba(34, 197, 94, 0.2);
}
.action-btn.like-btn:active {
  background: rgba(34, 197, 94, 0.15);
  box-shadow: 0 0 24px rgba(34, 197, 94, 0.2);
}

/* --- Voice Button (the star of the show) --- */
.voice-btn {
  width: 68px;
  height: 68px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--gradient-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow:
    0 4px 20px var(--accent-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.voice-btn:active {
  transform: scale(0.92);
}

.voice-btn .mic-icon {
  font-size: 26px;
  color: white;
  z-index: 2;
  transition: opacity 0.2s ease;
}

.voice-btn .stop-icon {
  font-size: 22px;
  color: white;
  z-index: 2;
  display: none;
}

/* Voice button glow ring animation */
.voice-btn::before,
.voice-btn::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: var(--radius-full);
  border: 2px solid var(--accent-primary);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.voice-btn.recording {
  animation: voice-pulse 1.5s ease-in-out infinite;
  box-shadow:
    0 4px 30px rgba(239, 68, 68, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

.voice-btn.recording .mic-icon { display: none; }
.voice-btn.recording .stop-icon { display: block; }

.voice-btn.recording::before {
  opacity: 1;
  border-color: rgba(239, 68, 68, 0.5);
  animation: ring-expand 1.5s ease-out infinite;
}

.voice-btn.recording::after {
  opacity: 1;
  border-color: rgba(239, 68, 68, 0.3);
  animation: ring-expand 1.5s ease-out 0.5s infinite;
}

.voice-btn.processing {
  background: linear-gradient(135deg, var(--color-warning), #d97706);
  animation: voice-pulse 0.8s ease-in-out infinite;
}

/* --- Voice Overlay --- */
.voice-overlay {
  position: absolute;
  inset: 0;
  background: rgba(7, 7, 12, 0.92);
  -webkit-backdrop-filter: blur(30px);
  backdrop-filter: blur(30px);
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.voice-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.voice-avatar {
  width: 200px;
  height: 200px;
  border-radius: var(--radius-lg);
  object-fit: cover;
  border: 2px solid var(--border-glass);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  margin-bottom: 20px;
}

.voice-status-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.voice-sub-text {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.voice-close-btn {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-glass);
  background: var(--bg-glass);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}

.voice-audio-player {
  width: 80%;
  max-width: 300px;
  margin-top: 16px;
  display: none;
  border-radius: var(--radius-sm);
}

/* --- Animations --- */
@keyframes voice-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

@keyframes ring-expand {
  0% {
    transform: scale(1);
    opacity: 0.6;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(100%); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

/* --- Loading skeleton --- */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-card) 25%,
    var(--bg-elevated) 50%,
    var(--bg-card) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

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

.glass-panel {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-md);
}

/* --- Overlay backdrop --- */
.dropdown-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: none;
}

.dropdown-backdrop.visible {
  display: block;
}
