﻿/* TikClone Global Styles */
:root {
  --bg: #000000;
  --bg-card: #121212;
  --bg-elevated: #1e1e1e;
  --bg-input: #2a2a2a;
  --text-primary: #ffffff;
  --text-secondary: #a0a0a0;
  --text-muted: #666666;
  --accent: #fe2c55;
  --accent-hover: #e8254c;
  --accent-light: rgba(254, 44, 85, 0.15);
  --green: #25d366;
  --blue: #25f4ee;
  --gold: #ffc107;
  --border: #2a2a2a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.5);
  --nav-height: 56px;
  --header-height: 52px;
}

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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 24px; border-radius: var(--radius-sm); font-size: 15px; font-weight: 600;
  border: none; cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); transform: scale(1.02); }
.btn-outline { background: transparent; color: var(--text-primary); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--text-secondary); }
.btn-ghost { background: transparent; color: var(--text-secondary); padding: 8px 12px; }
.btn-ghost:hover { color: var(--text-primary); }
.btn-sm { padding: 6px 16px; font-size: 13px; }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: 50%; }

/* ---- Form ---- */
.input-group { margin-bottom: 16px; }
.input-group label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.input {
  width: 100%; padding: 12px 16px; background: var(--bg-input); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary); font-size: 15px; transition: border 0.2s;
}
.input:focus { outline: none; border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 80px; font-family: inherit; }

/* ---- Layout ---- */
.container { max-width: 480px; margin: 0 auto; padding: 0 16px; }
.header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-height);
  background: rgba(0,0,0,0.9); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
  z-index: 100; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.header-title { font-size: 18px; font-weight: 700; }
.header-logo { font-size: 22px; font-weight: 800; background: linear-gradient(135deg, var(--accent), var(--blue)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-height);
  background: rgba(0,0,0,0.95); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  display: flex; align-items: center; justify-content: space-around;
  z-index: 100; border-top: 1px solid rgba(255,255,255,0.06);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 10px; color: var(--text-muted); transition: color 0.2s; padding: 6px 12px;
}
.nav-item.active { color: var(--text-primary); }
.nav-item svg { width: 24px; height: 24px; }
.nav-item-add {
  width: 44px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--blue), var(--accent));
  display: flex; align-items: center; justify-content: center;
}

/* ---- Feed (TikTok-style vertical scroll) ---- */
.feed-container {
  height: 100vh; overflow-y: scroll; scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.feed-container::-webkit-scrollbar { display: none; }
.feed-item {
  height: 100vh; scroll-snap-align: start; position: relative;
  display: flex; align-items: center; justify-content: center;
  background: #0a0a0a;
}
.feed-item video {
  width: 100%; height: 100%; object-fit: contain; background: #000;
}
.video-overlay {
  position: absolute; bottom: 80px; left: 0; right: 60px;
  padding: 16px; pointer-events: none;
}
.video-author {
  font-weight: 700; font-size: 16px; margin-bottom: 4px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}
.video-desc {
  font-size: 14px; color: rgba(255,255,255,0.9);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.video-actions {
  position: absolute; right: 12px; bottom: 100px;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
}
.action-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: #fff; cursor: pointer; pointer-events: auto; border: none; background: none;
  font-size: 11px; transition: transform 0.2s;
}
.action-btn:active { transform: scale(0.9); }
.action-btn svg { width: 32px; height: 32px; filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5)); }
.action-btn.liked svg { color: var(--accent); }
.action-avatar {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid #fff;
  overflow: hidden; background: var(--bg-elevated);
}
.action-avatar img { width: 100%; height: 100%; object-fit: cover; }
.action-avatar-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), #6366f1); font-size: 18px; font-weight: 700;
}

/* ---- Comment Panel ---- */
.comment-panel {
  position: fixed; bottom: 0; left: 0; right: 0; height: 60vh;
  background: var(--bg-card); border-radius: 16px 16px 0 0;
  z-index: 200; transform: translateY(100%); transition: transform 0.3s ease;
  display: flex; flex-direction: column;
}
.comment-panel.open { transform: translateY(0); }
.comment-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border); font-weight: 700;
}
.comment-list { flex: 1; overflow-y: auto; padding: 0 16px; }
.comment-item { display: flex; gap: 12px; padding: 12px 0; }
.comment-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #6366f1, var(--accent));
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700;
}
.comment-body { flex: 1; }
.comment-name { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 2px; }
.comment-text { font-size: 14px; line-height: 1.4; }
.comment-time { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.comment-input-bar {
  display: flex; gap: 8px; padding: 12px 16px;
  border-top: 1px solid var(--border);
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
.comment-input-bar .input { flex: 1; padding: 10px 14px; }
.overlay-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 199;
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.overlay-bg.open { opacity: 1; pointer-events: auto; }

/* ---- Upload Page ---- */
.upload-area {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 48px 24px; text-align: center; cursor: pointer;
  transition: border-color 0.2s, background 0.2s; margin: 24px 0;
}
.upload-area:hover, .upload-area.dragover {
  border-color: var(--accent); background: var(--accent-light);
}
.upload-area svg { width: 48px; height: 48px; color: var(--text-muted); margin-bottom: 12px; }
.upload-area p { color: var(--text-secondary); font-size: 14px; }
.upload-area .hint { font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.upload-preview { margin: 16px 0; border-radius: var(--radius); overflow: hidden; }
.upload-preview video { width: 100%; max-height: 300px; background: #000; }
.upload-form { margin-top: 24px; }
.progress-bar {
  width: 100%; height: 4px; background: var(--bg-input); border-radius: 2px;
  overflow: hidden; margin: 16px 0;
}
.progress-bar-fill {
  height: 100%; background: var(--accent); width: 0%;
  transition: width 0.3s; border-radius: 2px;
}

/* ---- Profile ---- */
.profile-header {
  padding: 24px 16px; text-align: center;
  padding-top: calc(var(--header-height) + 24px);
}
.profile-avatar {
  width: 88px; height: 88px; border-radius: 50%; margin: 0 auto 12px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; font-weight: 700; overflow: hidden;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.profile-handle { font-size: 14px; color: var(--text-secondary); margin-bottom: 8px; }
.profile-bio { font-size: 14px; color: var(--text-secondary); margin-bottom: 16px; max-width: 280px; margin-left: auto; margin-right: auto; }
.profile-stats { display: flex; justify-content: center; gap: 32px; margin-bottom: 16px; }
.stat-item { text-align: center; }
.stat-num { font-size: 18px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--text-secondary); }
.profile-actions { display: flex; justify-content: center; gap: 8px; margin-bottom: 24px; }
.video-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px;
  padding: 0 2px 80px;
}
.video-grid-item {
  aspect-ratio: 9/12; background: var(--bg-elevated); position: relative;
  overflow: hidden; cursor: pointer; border-radius: 2px;
}
.video-grid-item video,
.video-grid-item img { width: 100%; height: 100%; object-fit: cover; }
.video-grid-item .grid-overlay {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 6px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  display: flex; align-items: center; gap: 4px; font-size: 12px;
}
.video-grid-item .grid-overlay svg { width: 14px; height: 14px; }

/* ---- Auth Pages ---- */
.auth-page {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px;
}
.auth-card {
  width: 100%; max-width: 380px; background: var(--bg-card);
  border-radius: var(--radius); padding: 32px 24px; box-shadow: var(--shadow);
}
.auth-logo {
  font-size: 32px; font-weight: 800; text-align: center; margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.auth-subtitle { text-align: center; color: var(--text-secondary); margin-bottom: 28px; font-size: 14px; }
.auth-footer { text-align: center; margin-top: 16px; font-size: 14px; color: var(--text-secondary); }
.auth-footer a { color: var(--accent); font-weight: 600; }
.error-msg { color: var(--accent); font-size: 13px; margin-top: 8px; text-align: center; }

/* ---- Toast ---- */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-100px);
  background: var(--bg-elevated); color: var(--text-primary); padding: 12px 24px;
  border-radius: var(--radius-sm); font-size: 14px; z-index: 999;
  box-shadow: var(--shadow); transition: transform 0.3s ease; border: 1px solid var(--border);
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ---- Loading ---- */
.spinner { width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; justify-content: center; padding: 48px; }

/* ---- Skeleton ---- */
.skeleton { background: var(--bg-elevated); border-radius: var(--radius-sm); animation: pulse 1.5s ease infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

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

/* ---- Page padding for fixed nav ---- */
.page-content {
  padding-top: var(--header-height);
  padding-bottom: var(--nav-height);
  min-height: 100vh;
}

/* ---- Tab bar ---- */
.tabs {
  display: flex; border-bottom: 1px solid var(--border);
  padding: 0 16px; margin-bottom: 8px;
}
.tab {
  padding: 12px 16px; font-size: 14px; font-weight: 600;
  color: var(--text-muted); cursor: pointer; position: relative; border: none; background: none;
}
.tab.active { color: var(--text-primary); }
.tab.active::after {
  content: ''; position: absolute; bottom: -1px; left: 0; right: 0;
  height: 2px; background: var(--accent); border-radius: 1px;
}

/* Empty state */
.empty-state {
  text-align: center; padding: 48px 24px; color: var(--text-muted);
}
.empty-state svg { width: 64px; height: 64px; margin-bottom: 16px; opacity: 0.3; }
.empty-state p { font-size: 14px; }
