/* TikTok Content Hub — Premium Responsive Design System */
:root {
  --brand: #fe2c55;
  --brand-dark: #e0264a;
  --brand-glow: rgba(254, 44, 85, 0.25);
  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;
  --accent-emerald: #10b981;
  --bg-dark: #08090a;
  --card-bg: rgba(18, 18, 22, 0.75);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-border-hover: rgba(254, 44, 85, 0.35);
  --text-muted: #94a3b8;
}

html {
  -webkit-text-size-adjust: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body.hub {
  background-color: var(--bg-dark);
  background-image:
    radial-gradient(circle at 50% 0%, rgba(254, 44, 85, 0.14), transparent 50%),
    radial-gradient(circle at 90% 20%, rgba(6, 182, 212, 0.08), transparent 45%),
    radial-gradient(circle at 10% 80%, rgba(139, 92, 246, 0.08), transparent 50%);
  background-attachment: fixed;
  color: #f8fafc;
  min-height: 100vh;
  overflow-anchor: none;
}

#posts { overflow-anchor: none; }

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-flash { animation: cardFlash 1.2s ease-out; }
.card-leave { animation: cardLeave 0.35s ease-in forwards; }

@keyframes cardFlash {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  30% { box-shadow: 0 0 0 2px #fbbf24, 0 0 24px rgba(251, 191, 36, 0.25); }
}

@keyframes cardLeave {
  to { opacity: 0; transform: scale(0.96); max-height: 0; margin: 0; padding: 0; overflow: hidden; }
}

#toast-container .toast-enter { opacity: 0; transform: translateY(12px) scale(0.95); transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1); }
#toast-container .toast-visible { opacity: 1; transform: translateY(0) scale(1); }
#toast-container .toast-exit { opacity: 0; transform: translateY(-8px) scale(0.95); }

.copied {
  background: linear-gradient(135deg, #059669, #10b981) !important;
  color: #ffffff !important;
  border-color: rgba(16, 185, 129, 0.5) !important;
  transform: scale(0.98);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.4) !important;
}

.copy-error {
  background: linear-gradient(135deg, #dc2626, #b91c1c) !important;
  color: #ffffff !important;
}

button, a {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

/* Touch-optimized button chip */
.btn-chip {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  min-height: 42px;
  padding: 8px 12px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.btn-chip:active {
  transform: scale(0.96);
}

/* Specific button styles */
.btn-media-download {
  background: linear-gradient(135deg, #fe2c55, #e0264a);
  color: #ffffff;
  border-color: rgba(254, 44, 85, 0.4);
  box-shadow: 0 4px 14px rgba(254, 44, 85, 0.25);
}
.btn-media-download:hover {
  background: linear-gradient(135deg, #ff4167, #fe2c55);
  box-shadow: 0 6px 18px rgba(254, 44, 85, 0.35);
}

.btn-media-share {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #ffffff;
  border-color: rgba(124, 58, 237, 0.4);
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.25);
}
.btn-media-share:hover {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.35);
}

.btn-copy-title {
  background: rgba(30, 41, 59, 0.7);
  color: #cbd5e1;
  border-color: rgba(255, 255, 255, 0.1);
}
.btn-copy-title:hover {
  background: rgba(51, 65, 85, 0.8);
  color: #ffffff;
}

.btn-copy-caption {
  background: rgba(6, 78, 59, 0.35);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.3);
}
.btn-copy-caption:hover {
  background: rgba(4, 120, 87, 0.5);
  color: #ffffff;
  border-color: rgba(16, 185, 129, 0.5);
}

.toggle-used-btn {
  background: rgba(15, 23, 42, 0.6);
  color: #94a3b8;
  border-color: rgba(255, 255, 255, 0.08);
}
.toggle-used-btn:hover {
  background: rgba(30, 41, 59, 0.8);
  color: #f1f5f9;
}

.filter-segment {
  display: flex;
  width: 100%;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 4px;
  gap: 4px;
}

.filter-segment .filter-btn {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  min-height: 38px;
  padding: 6px 12px;
  border-radius: 10px;
  transition: all 0.2s ease;
  white-space: nowrap;
  color: var(--text-muted);
  border: none;
  cursor: pointer;
}

.filter-segment .filter-btn.is-active {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  box-shadow: 0 4px 12px var(--brand-glow);
}

.filter-segment .filter-btn:not(.is-active):hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

/* Header & Navigation */
.site-header {
  margin-bottom: 1rem;
}

.site-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.site-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

@media (max-width: 640px) {
  html, body {
    max-width: 100vw;
    overflow-x: hidden;
  }
  .page-wrap {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    overflow-x: hidden;
  }
  .site-title {
    font-size: 0.95rem;
  }
  .site-top {
    gap: 0.375rem;
  }
  .creator-action {
    display: none !important;
  }
}

@media (min-width: 641px) {
  .creator-action {
    display: inline-flex !important;
  }
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  flex-shrink: 0;
  background: rgba(15, 23, 42, 0.6);
  padding: 4px 10px;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #64748b;
  flex-shrink: 0;
}

.sync-dot.dot-green { background: #10b981; box-shadow: 0 0 8px rgba(16, 185, 129, 0.5); }
.sync-dot.dot-amber { background: #f59e0b; box-shadow: 0 0 8px rgba(245, 158, 11, 0.5); }
.sync-dot.dot-red { background: #ef4444; box-shadow: 0 0 8px rgba(239, 68, 68, 0.5); }
.sync-dot.dot-pulse { animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }

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

.site-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.stats-inline {
  display: none;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.stat-pill {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
}

.stat-pill strong { color: #f8fafc; font-weight: 700; }
.stat-pill.stat-new strong { color: #f43f5e; }

@media (min-width: 768px) {
  .site-title { font-size: 1.35rem; }
  .site-toolbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
  }
  .filter-segment { width: auto; flex-shrink: 0; }
  .stats-inline { display: flex; }
}

.hidden { display: none !important; }

/* Login gate */
.login-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 340px;
  background: rgba(18, 18, 22, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 2.25rem 1.75rem;
  text-align: center;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
}

.login-logo {
  width: 52px;
  height: 52px;
  margin: 0 auto 1.25rem;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  font-weight: 800;
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 28px rgba(254, 44, 85, 0.4);
}

.login-title {
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 0.35rem;
}

.login-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.login-input {
  width: 100%;
  min-height: 50px;
  padding: 0 1.15rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(8, 9, 10, 0.9);
  color: #f8fafc;
  font-size: 1rem;
  outline: none;
  transition: all 0.2s ease;
}

.login-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(254, 44, 85, 0.25);
}

.login-submit {
  min-height: 50px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(254, 44, 85, 0.3);
  transition: all 0.2s ease;
}

.login-submit:hover { opacity: 0.95; transform: translateY(-1px); }
.login-submit:disabled { opacity: 0.5; transform: none; }

.login-error {
  margin-top: 0.75rem;
  font-size: 0.8125rem;
  color: #f87171;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3.5rem 1.5rem;
  color: var(--text-muted);
  background: rgba(18, 18, 22, 0.5);
  backdrop-filter: blur(10px);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 20px;
}

/* Post Cards Layout */
.posts-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.post-card {
  display: flex;
  flex-direction: row;
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.post-card.is-used {
  opacity: 0.55;
  filter: grayscale(0.2);
}

.post-card .preview-btn {
  position: relative;
  flex-shrink: 0;
  padding: 0.75rem;
  padding-right: 0;
  background: transparent;
  border: none;
  cursor: pointer;
}

.post-card .card-thumb {
  width: 110px;
  height: 146px;
  object-fit: cover;
  border-radius: 14px;
  background: #1e293b;
  display: block;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.post-card .card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.625rem;
  padding: 0.75rem;
}

.post-card .card-mobile-head { display: flex; align-items: flex-start; gap: 0.5rem; }
.post-card .card-desktop-head { display: none; }
.post-card .card-story { display: none; }
.post-card .preview-overlay,
.post-card .preview-badges { display: none; }

/* Desktop: Ultra-compact Fixed Grid (3–6 Columns) */
@media (min-width: 768px) {
  .filter-segment .filter-btn { flex: none; padding: 6px 14px; font-size: 12px; }

  .empty-state { padding: 3rem 1.5rem; }

  .posts-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
  }

  .post-card {
    flex-direction: column;
    height: 100%;
    border-radius: 14px;
  }

  .post-card:hover {
    border-color: var(--card-border-hover);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 14px rgba(254, 44, 85, 0.15);
    transform: translateY(-2px);
  }

  .post-card .preview-btn {
    width: 100%;
    padding: 0;
  }

  .post-card .card-thumb {
    width: 100%;
    height: 125px;
    aspect-ratio: auto;
    object-fit: cover;
    object-position: top center;
    border-radius: 0;
    box-shadow: none;
  }

  .post-card .card-body {
    flex: 1;
    padding: 0.625rem;
    gap: 0.4rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }

  .post-card .card-mobile-head { display: none; }
  .post-card .card-desktop-head {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #f1f5f9;
  }

  /* Hide long story text on PC for super compact uniform grid */
  .post-card .card-story {
    display: none !important;
  }

  /* Compact aligned PC buttons */
  .post-card .btn-chip {
    min-height: 30px;
    font-size: 11px;
    padding: 3px 6px;
    border-radius: 8px;
  }

  .post-card .preview-overlay {
    display: flex;
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
  }

  .post-card .preview-btn:hover .preview-overlay {
    background: rgba(0, 0, 0, 0.35);
  }

  .post-card .preview-hint {
    opacity: 0;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform: translateY(4px);
  }

  .post-card .preview-btn:hover .preview-hint {
    opacity: 1;
    transform: translateY(0);
  }

  .post-card .preview-badges {
    display: flex;
    position: absolute;
    top: 0.4rem;
    left: 0.4rem;
    right: 0.4rem;
    align-items: center;
    justify-content: space-between;
    gap: 0.3rem;
    pointer-events: none;
  }
}

@media (min-width: 1100px) {
  .posts-list { grid-template-columns: repeat(4, 1fr); gap: 0.75rem; }
}

@media (min-width: 1400px) {
  .posts-list { grid-template-columns: repeat(5, 1fr); gap: 0.75rem; }
}

@media (min-width: 1750px) {
  .posts-list { grid-template-columns: repeat(6, 1fr); gap: 0.75rem; }
}
