/* ─── Google Fonts ─────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ─── CSS Variables ─────────────────────────────────────────────────────────── */
:root {
  --bg:           #0a0a0a;
  --card-bg:      #111111;
  --surface:      #181818;
  --border:       #222222;
  --accent-start: #4ABEFF;
  --accent-end:   #C6FF00;
  --text-primary: #ffffff;
  --text-secondary: #aaaaaa;
  --text-muted:   #666666;
  --danger:       #ff4b6e;
  --success:      #00e096;
  --sidebar-w:    240px;
  --comment-w:    380px;
  --transition:   0.2s ease;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

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

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  outline: none;
}

input, textarea {
  font-family: inherit;
  outline: none;
}

img {
  display: block;
  max-width: 100%;
}

/* ─── Gradient Utilities ────────────────────────────────────────────────────── */
.gradient-text {
  background: linear-gradient(90deg, var(--accent-start), var(--accent-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gradient-bg {
  background: linear-gradient(90deg, var(--accent-start), var(--accent-end));
}

/* ─── Spinner ───────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}

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

/* ─── Toast ─────────────────────────────────────────────────────────────────── */
.sysmoo-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transition: opacity var(--transition), transform var(--transition);
  pointer-events: none;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
}

.sysmoo-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

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

/* ─── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.modal-overlay.visible {
  opacity: 1;
}

.modal-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 36px 36px;
  max-width: 420px;
  width: 90%;
  position: relative;
  text-align: center;
  transform: translateY(16px);
  transition: transform 0.25s ease;
}

.modal-overlay.visible .modal-box {
  transform: translateY(0);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 24px;
  color: var(--text-secondary);
  line-height: 1;
  transition: color var(--transition);
}

.modal-close:hover { color: var(--text-primary); }

.modal-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 10px;
}

.modal-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 28px;
}

.modal-badges {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

.store-badge {
  height: 50px;
  width: auto;
  transition: transform var(--transition), opacity var(--transition);
}

.store-badge:hover {
  transform: scale(1.04);
  opacity: 0.9;
}

/* ─── ════════════════════════════════════════ ─── */
/* ─── AUTH PAGE ──────────────────────────────── ─── */
/* ─── ════════════════════════════════════════ ─── */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

/* Subtle background glow */
.auth-page::before {
  content: '';
  position: absolute;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(ellipse, rgba(74, 190, 255, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.auth-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo-text {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(90deg, var(--accent-start), var(--accent-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-logo-tagline {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

/* Tabs */
.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
  gap: 0;
}

.auth-tab {
  flex: 1;
  text-align: center;
  padding: 10px 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
  margin-bottom: -1px;
}

.auth-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent-start);
}

/* Forms */
.auth-form {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.auth-form.active {
  display: flex;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.form-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.form-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 15px;
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus {
  border-color: var(--accent-start);
  box-shadow: 0 0 0 3px rgba(74, 190, 255, 0.12);
}

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

.form-input.has-toggle {
  padding-right: 60px;
}

.toggle-password {
  position: absolute;
  right: 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition);
  user-select: none;
}

.toggle-password:hover {
  color: var(--accent-start);
}

.auth-error {
  display: none;
  color: var(--danger);
  font-size: 13px;
  background: rgba(255, 75, 110, 0.1);
  border: 1px solid rgba(255, 75, 110, 0.25);
  border-radius: 8px;
  padding: 10px 14px;
  line-height: 1.4;
}

.auth-submit-btn {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  background: linear-gradient(90deg, var(--accent-start), var(--accent-end));
  color: #000;
  font-size: 15px;
  font-weight: 700;
  transition: opacity var(--transition), transform var(--transition);
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
}

.auth-submit-btn:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
}

.auth-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ─── ════════════════════════════════════════ ─── */
/* ─── FEED PAGE ──────────────────────────────── ─── */
/* ─── ════════════════════════════════════════ ─── */

.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* ─── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 8px 12px 24px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--surface);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--surface);
  color: var(--text-primary);
}

.nav-item .nav-icon {
  font-size: 20px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.nav-upload:hover .nav-icon,
.nav-live:hover .nav-icon {
  background: linear-gradient(90deg, var(--accent-start), var(--accent-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--transition);
}

.sidebar-user:hover {
  background: var(--surface);
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface);
  flex-shrink: 0;
}

.sidebar-username {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logout {
  color: var(--danger);
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 8px;
  margin-top: 4px;
  transition: background var(--transition);
}

.sidebar-logout:hover {
  background: rgba(255, 75, 110, 0.1);
}

/* ─── Main content area ─────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ─── Feed ──────────────────────────────────────────────────────────────────── */
#feed {
  flex: 1;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  height: 100vh;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#feed::-webkit-scrollbar {
  display: none;
}

/* Feed loader */
#feed-loader {
  display: none;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

#feed-loader .spinner {
  width: 36px;
  height: 36px;
  border-width: 3px;
}

#feed-sentinel {
  height: 1px;
}

/* ─── Video Card ────────────────────────────────────────────────────────────── */
.video-card {
  scroll-snap-align: start;
  height: 100vh;
  display: flex;
  align-items: stretch;
  justify-content: center;
  position: relative;
  background: var(--bg);
}

.video-wrapper {
  position: relative;
  flex: 1;
  max-width: 520px;
  overflow: hidden;
  background: #000;
}

.post-video,
.post-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-tap-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  cursor: pointer;
}

/* Video info overlay */
.video-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 60px 16px 24px;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 50%, transparent 100%);
  z-index: 3;
  pointer-events: none;
}

.video-info {
  pointer-events: all;
}

.video-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  cursor: pointer;
}

.video-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.5);
  object-fit: cover;
  flex-shrink: 0;
}

.video-username {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.verified-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  background: linear-gradient(90deg, var(--accent-start), var(--accent-end));
  color: #000;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 900;
  flex-shrink: 0;
}

.video-description {
  font-size: 14px;
  color: rgba(255,255,255,0.9);
  line-height: 1.5;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.video-hashtags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.hashtag {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-start);
  cursor: pointer;
}

.hashtag:hover {
  text-decoration: underline;
}

/* ─── Video Actions (right column) ─────────────────────────────────────────── */
.video-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 0 12px 80px;
  gap: 20px;
  z-index: 5;
  min-width: 70px;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 14px;
  padding: 10px 8px;
  transition: transform var(--transition), background var(--transition);
  min-width: 52px;
}

.action-btn:hover {
  transform: scale(1.08);
  background: rgba(0, 0, 0, 0.6);
}

.action-icon {
  font-size: 24px;
  line-height: 1;
  display: block;
}

.action-count {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.like-btn.liked .action-icon {
  filter: drop-shadow(0 0 6px rgba(74, 190, 255, 0.6));
  animation: heartPop 0.3s ease;
}

@keyframes heartPop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.4); }
  100% { transform: scale(1); }
}

.action-views {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  min-width: 52px;
}

/* ─── Empty state ───────────────────────────────────────────────────────────── */
.empty-state {
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}

.empty-icon {
  font-size: 64px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 14px;
}

/* ─── Comment Panel ─────────────────────────────────────────────────────────── */
.comment-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.comment-overlay.visible {
  display: block;
  opacity: 1;
}

.comment-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--comment-w);
  background: var(--card-bg);
  border-left: 1px solid var(--border);
  z-index: 300;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.comment-panel.open {
  transform: translateX(0);
}

.comment-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.comment-panel-title {
  font-size: 17px;
  font-weight: 700;
}

.close-panel-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
}

.close-panel-btn:hover {
  background: var(--border);
  color: var(--text-primary);
}

#comment-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.comment-loading,
.no-comments {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 32px 0;
}

.comment-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.comment-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface);
}

.comment-body {
  flex: 1;
  min-width: 0;
}

.comment-username {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  display: block;
  margin-bottom: 3px;
}

.comment-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  word-break: break-word;
}

.comment-time {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
  margin-top: 4px;
}

.comment-likes {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: 11px;
  flex-shrink: 0;
  padding-top: 2px;
}

.comment-form-area {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#comment-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

#comment-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-primary);
  transition: border-color var(--transition);
}

#comment-input:focus {
  border-color: var(--accent-start);
}

#comment-input::placeholder {
  color: var(--text-muted);
}

#comment-submit-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  transition: transform var(--transition), opacity var(--transition);
  color: #000;
  font-weight: 700;
}

#comment-submit-btn:hover:not(:disabled) {
  transform: scale(1.08);
}

#comment-submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ─── Bottom Tab Bar (mobile) ───────────────────────────────────────────────── */
.bottom-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
}

.bottom-bar-inner {
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.bottom-bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 12px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--transition);
  background: none;
  border: none;
}

.bottom-bar-item:hover,
.bottom-bar-item.active {
  color: var(--text-primary);
}

.bottom-bar-item .bar-icon {
  font-size: 22px;
}

.bottom-bar-item.bottom-upload .bar-icon,
.bottom-bar-item.bottom-live .bar-icon {
  background: linear-gradient(90deg, var(--accent-start), var(--accent-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.bottom-bar-avatar-wrap {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--border);
}

.bottom-bar-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .video-wrapper {
    max-width: 420px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .main-content {
    margin-left: 0;
  }

  .bottom-bar {
    display: block;
  }

  .video-card {
    height: calc(100vh - 60px);
  }

  .video-wrapper {
    max-width: 100%;
  }

  #feed {
    height: calc(100vh - 60px);
  }

  .comment-panel {
    width: 100%;
    top: auto;
    height: 70vh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
  }

  .comment-panel.open {
    transform: translateY(0);
  }

  .video-actions {
    padding-bottom: 16px;
  }
}

@media (max-width: 480px) {
  .auth-card {
    padding: 32px 24px;
  }
}

/* ── Seek overlay (rewind / fast-forward) ─────────────────────────── */
.seek-overlay {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 33%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 20;
}
.seek-overlay.rewind  { left: 0; }
.seek-overlay.forward { right: 0; }
.seek-overlay.visible { opacity: 1; }

.seek-overlay-circle {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.seek-icon {
  font-size: 28px;
  color: #fff;
  line-height: 1;
}
.seek-label {
  font-size: 10px;
  color: #fff;
  font-family: Inter, sans-serif;
}
