/* ============================================
   CLIPPY — Design System & Styles
   Premium dark glassmorphism theme
   ============================================ */

/* ---- CSS Custom Properties ---- */
:root {
  /* Background */
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.6);
  --bg-card-hover: rgba(17, 24, 39, 0.8);
  --bg-input: rgba(15, 23, 42, 0.8);

  /* Glass */
  --glass-bg: rgba(255, 255, 255, 0.03);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-border-hover: rgba(255, 255, 255, 0.15);

  /* Accent colors */
  --accent-primary: #3b82f6;
  --accent-primary-glow: rgba(59, 130, 246, 0.3);
  --accent-secondary: #8b5cf6;
  --accent-gradient: linear-gradient(135deg, #3b82f6, #8b5cf6);
  --accent-gradient-hover: linear-gradient(135deg, #60a5fa, #a78bfa);

  /* Status colors */
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.3);
  --warning: #f59e0b;
  --error: #ef4444;
  --error-glow: rgba(239, 68, 68, 0.3);

  /* Text */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-accent: #60a5fa;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

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

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--accent-primary-glow);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ---- Animated Background ---- */
.bg-gradient {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(16, 185, 129, 0.05) 0%, transparent 50%);
  animation: gradientShift 15s ease-in-out infinite alternate;
}

@keyframes gradientShift {
  0% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
  100% { opacity: 0.8; transform: scale(1); }
}

.bg-noise {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  opacity: 0.015;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* ---- Status Bar ---- */
.status-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: rgba(10, 14, 26, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--glass-border);
  z-index: 100;
  font-size: 0.8rem;
}

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

.status-dot.connected {
  background: var(--success);
  box-shadow: 0 0 8px var(--success-glow);
  animation: pulse-dot 2s ease-in-out infinite;
}

.status-dot.disconnected {
  background: var(--error);
  box-shadow: 0 0 8px var(--error-glow);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

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

/* ---- App Container ---- */
.app-container {
  max-width: 560px;
  margin: 0 auto;
  padding: 70px 20px 40px;
  min-height: 100vh;
}

/* ---- Views ---- */
.view {
  display: none;
  animation: fadeIn 0.4s ease-out;
}

.view.active {
  display: block;
}

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

/* ---- HOME VIEW ---- */
.hero {
  text-align: center;
  padding: 40px 0 36px;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

.logo-icon {
  font-size: 2.5rem;
  filter: drop-shadow(0 0 12px var(--accent-primary-glow));
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.logo h1 {
  font-size: 2.5rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.tagline {
  font-size: 1.15rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 400;
}

.tagline .accent {
  color: var(--text-accent);
  font-weight: 600;
}

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

/* ---- Action Cards ---- */
.action-cards {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all var(--transition-base);
}

.card-create {
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.card-create::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--accent-gradient);
  opacity: 0;
  transition: opacity var(--transition-base);
  border-radius: var(--radius-lg);
}

.card-create:hover {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.card-create:hover::before {
  opacity: 0.06;
}

.card-create:active {
  transform: translateY(0);
}

.card-icon {
  font-size: 1.8rem;
  margin-bottom: 12px;
}

.glass-card h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 6px;
  position: relative;
}

.glass-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  position: relative;
}

.card-arrow {
  position: absolute;
  top: 28px;
  right: 28px;
  font-size: 1.4rem;
  color: var(--text-muted);
  transition: all var(--transition-base);
}

.card-create:hover .card-arrow {
  color: var(--accent-primary);
  transform: translateX(4px);
}

/* Divider */
.divider-or {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 0;
}

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

.divider-or span {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
}

/* Join Card */
.card-join {
  border-color: transparent;
  background: var(--glass-bg);
}

.join-input-group {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  position: relative;
}

.code-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-align: center;
  text-transform: uppercase;
  outline: none;
  transition: all var(--transition-base);
}

.code-input::placeholder {
  color: var(--text-muted);
  letter-spacing: 0.1em;
  font-size: 1rem;
}

.code-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.btn-join {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 20px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
}

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

.btn-join:not(:disabled):hover {
  background: var(--accent-gradient-hover);
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

.btn-join:not(:disabled):active {
  transform: translateY(0);
}

/* ---- WAITING VIEW ---- */
.waiting-content {
  text-align: center;
  padding: 60px 0;
}

.pulse-ring {
  width: 80px;
  height: 80px;
  margin: 0 auto 32px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pulse-ring::before,
.pulse-ring::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--accent-primary);
  animation: pulse-ring 2s ease-out infinite;
}

.pulse-ring::after {
  animation-delay: 0.5s;
}

@keyframes pulse-ring {
  0% { transform: scale(0.5); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}

.pulse-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-primary);
  box-shadow: 0 0 16px var(--accent-primary-glow);
}

.waiting-content h2 {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.code-display {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-input);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px 28px;
  margin-bottom: 16px;
}

.code-text {
  font-family: var(--font-mono);
  font-size: 2.2rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.btn-copy-code {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-copy-code:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--glass-border-hover);
}

.waiting-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 32px;
}

/* TTL Progress Bar */
.ttl-bar {
  width: 200px;
  height: 3px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 2px;
  margin: 0 auto 8px;
  overflow: hidden;
}

.ttl-progress {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 2px;
  width: 100%;
  transition: width 1s linear;
}

.ttl-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.btn-cancel {
  background: none;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 10px 24px;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-base);
}

.btn-cancel:hover {
  border-color: var(--error);
  color: var(--error);
}

/* ---- CONNECTED VIEW ---- */
.connected-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.connected-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--success);
}

.connected-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success-glow);
  animation: pulse-dot 2s ease-in-out infinite;
}

.session-info {
  flex: 1;
  text-align: right;
}

.session-code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
}

.btn-disconnect {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-sm);
  padding: 8px;
  color: var(--error);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-disconnect:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--error);
}

/* Clip Sections */
.clip-section {
  margin-bottom: 20px;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.send-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.clip-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 16px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
  min-height: 80px;
}

.clip-textarea::placeholder {
  color: var(--text-muted);
  font-family: var(--font-sans);
}

.clip-textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.btn-send {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  align-self: flex-end;
}

.btn-send:hover {
  background: var(--accent-gradient-hover);
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

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

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

/* Clip Feed */
.clip-feed {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  min-height: 120px;
  max-height: 400px;
  overflow-y: auto;
}

.clip-feed::-webkit-scrollbar {
  width: 4px;
}

.clip-feed::-webkit-scrollbar-track {
  background: transparent;
}

.clip-feed::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 2px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  text-align: center;
}

.empty-icon {
  font-size: 2rem;
  margin-bottom: 12px;
  opacity: 0.6;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.empty-hint {
  font-size: 0.75rem !important;
  margin-top: 4px;
}

/* Individual Clip Item */
.clip-item {
  background: var(--bg-input);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 10px;
  animation: slideIn 0.3s ease-out;
  transition: border-color var(--transition-fast);
}

.clip-item:last-child {
  margin-bottom: 0;
}

.clip-item:hover {
  border-color: var(--glass-border-hover);
}

.clip-item.new {
  border-color: var(--accent-primary);
  box-shadow: 0 0 12px var(--accent-primary-glow);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.clip-content {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-primary);
  word-break: break-all;
  white-space: pre-wrap;
  margin-bottom: 10px;
}

.clip-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.clip-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.btn-copy-clip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-copy-clip:hover {
  background: rgba(59, 130, 246, 0.1);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.btn-copy-clip.copied {
  background: rgba(16, 185, 129, 0.1);
  border-color: var(--success);
  color: var(--success);
}

/* ---- Toast Notifications ---- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.85rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease-out;
  pointer-events: auto;
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--error); }
.toast.info { border-color: var(--accent-primary); }

.toast-exit {
  animation: toastOut 0.3s ease-in 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); }
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
  .app-container {
    padding: 60px 14px 30px;
  }

  .hero {
    padding: 24px 0 28px;
  }

  .logo h1 {
    font-size: 2rem;
  }

  .logo-icon {
    font-size: 2rem;
  }

  .tagline {
    font-size: 1rem;
  }

  .glass-card {
    padding: 20px;
  }

  .code-text {
    font-size: 1.8rem;
  }

  .code-display {
    padding: 16px 20px;
  }

  .toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }

  .toast {
    width: 100%;
  }
}
