/* --- DESIGN TOKENS --- */
:root {
  --bg-color: #080B11;
  --panel-bg: rgba(17, 24, 39, 0.7);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text-main: #F3F4F6;
  --text-muted: #9CA3AF;
  
  /* Brand colors */
  --tiktok-cyan: #00f2ea;
  --tiktok-pink: #ff0050;
  --gemini-purple: #7a5af8;
  --gemini-purple-glow: rgba(122, 90, 248, 0.15);
  
  --accent-gradient: linear-gradient(135deg, var(--tiktok-cyan) 0%, var(--gemini-purple) 50%, var(--tiktok-pink) 100%);
  --btn-gradient: linear-gradient(135deg, #7a5af8 0%, #ff0050 100%);
  
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  
  --font-body: 'Inter', sans-serif;
  --font-display: 'Outfit', sans-serif;
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Ambient glow blobs */
.glow-bg-1 {
  position: fixed;
  top: -10%;
  left: 20%;
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, rgba(0, 242, 234, 0.07) 0%, rgba(122, 90, 248, 0.05) 50%, rgba(0,0,0,0) 70%);
  filter: blur(80px);
  z-index: -1;
  pointer-events: none;
}

.glow-bg-2 {
  position: fixed;
  bottom: -10%;
  right: 10%;
  width: 45vw;
  height: 45vw;
  background: radial-gradient(circle, rgba(255, 0, 80, 0.06) 0%, rgba(122, 90, 248, 0.04) 50%, rgba(0,0,0,0) 70%);
  filter: blur(100px);
  z-index: -1;
  pointer-events: none;
}

/* --- UTILITIES --- */
.gradient-text {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.glass-card {
  background: var(--panel-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  transition: transform 0.3s ease, border-color 0.3s ease;
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.hidden {
  display: none !important;
}

/* --- LAYOUT --- */
.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --- HEADER --- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--panel-border);
  margin-bottom: 30px;
  flex-wrap: wrap;
  gap: 20px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 15px;
}

.logo-icon {
  position: relative;
  width: 42px;
  height: 42px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.logo-icon i {
  position: absolute;
  width: 22px;
  height: 22px;
}

.cyan-icon {
  color: var(--tiktok-cyan);
  transform: translate(-2px, -2px);
}

.pink-icon {
  color: var(--tiktok-pink);
  transform: translate(2px, 2px);
  mix-blend-mode: screen;
}

.logo-text h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
}

.logo-text p {
  font-size: 11px;
  color: var(--text-muted);
}

/* Nav Tabs */
.nav-tabs {
  display: flex;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  padding: 4px;
  border-radius: var(--radius-md);
  gap: 4px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.tab-btn i {
  width: 16px;
  height: 16px;
}

.tab-btn:hover:not(:disabled) {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.tab-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Status Badge */
.mode-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.mode-badge.demo-mode {
  background: rgba(255, 165, 0, 0.1);
  border-color: rgba(255, 165, 0, 0.2);
  color: #FFA500;
}

.mode-badge.live-mode {
  background: rgba(0, 242, 234, 0.1);
  border-color: rgba(0, 242, 234, 0.2);
  color: var(--tiktok-cyan);
}

.status-indicator {
  width: 8px;
  height: 8px;
  background-color: currentColor;
  border-radius: 50%;
  display: inline-block;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.6; }
}

/* --- MAIN CONTENT & TAB SYSTEM --- */
.app-main {
  flex-grow: 1;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* --- TAB 1: DASHBOARD --- */
.welcome-card h2 {
  font-family: var(--font-display);
  font-size: 28px;
  margin-bottom: 8px;
}

.welcome-card p {
  color: var(--text-muted);
  margin-bottom: 24px;
  font-size: 14px;
}

.search-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 20px;
  height: 20px;
  pointer-events: none;
}

.search-input-wrapper input {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  padding: 16px 140px 16px 52px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  color: var(--text-main);
  font-size: 15px;
  transition: all 0.3s ease;
}

.search-input-wrapper input:focus {
  outline: none;
  border-color: var(--gemini-purple);
  box-shadow: 0 0 15px var(--gemini-purple-glow);
}

.search-submit-btn {
  position: absolute;
  right: 6px;
  top: 6px;
  bottom: 6px;
  background: var(--btn-gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  padding: 0 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: opacity 0.2s ease;
}

.search-submit-btn:hover {
  opacity: 0.9;
}

.suggestions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
}

.suggestion-label {
  color: var(--text-muted);
}

.suggest-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 4px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 12px;
  transition: all 0.2s ease;
}

.suggest-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Search Results Area */
.search-results-area {
  margin-top: 30px;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding: 0 4px;
}

.results-header h3 {
  font-family: var(--font-display);
  font-size: 18px;
}

.results-count {
  font-size: 13px;
  color: var(--text-muted);
}

.products-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Product list item card */
.product-card {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
}

.product-thumb {
  width: 70px;
  height: 70px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.product-info {
  flex-grow: 1;
  min-width: 250px;
}

.product-info h4 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
  font-family: var(--font-display);
}

.product-shop {
  font-size: 12px;
  color: var(--text-muted);
}

.product-stats {
  display: flex;
  gap: 30px;
  min-width: 200px;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--tiktok-cyan);
  font-family: var(--font-display);
}

.stat-lbl {
  font-size: 11px;
  color: var(--text-muted);
}

.product-videos-panel {
  width: 100%;
  margin-top: 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 15px;
}

.videos-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 10px;
  letter-spacing: 0.05em;
}

.video-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.video-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 12px;
  border-radius: var(--radius-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s ease;
}

.video-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.video-details {
  display: flex;
  flex-direction: column;
}

.video-creator {
  font-weight: 600;
  font-size: 13px;
}

.video-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.video-meta span {
  color: #FFA500;
  font-weight: 600;
}

.btn-analyze {
  background: rgba(122, 90, 248, 0.15);
  border: 1px solid rgba(122, 90, 248, 0.3);
  color: #C0B6FF;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-analyze:hover {
  background: var(--gemini-purple);
  color: #fff;
  border-color: var(--gemini-purple);
  box-shadow: 0 4px 12px rgba(122, 90, 248, 0.3);
}

/* --- TAB 2: ANALYZER Layout --- */
.analyzer-layout {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .analyzer-layout {
    grid-template-columns: 1fr;
  }
}

.analyzer-sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.video-card h3 {
  font-family: var(--font-display);
  font-size: 16px;
  margin-bottom: 4px;
}

.creator-name {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.video-player-wrapper {
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  aspect-ratio: 9 / 16;
  max-height: 480px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.video-player-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-metrics {
  display: flex;
  margin-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 16px;
  justify-content: space-around;
  text-align: center;
}

.video-metrics .metric {
  display: flex;
  flex-direction: column;
}

.video-metrics .metric.highlight .metric-value {
  color: #FFA500;
}

.metric-label {
  font-size: 11px;
  color: var(--text-muted);
}

.metric-value {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-display);
}

.help-card h4 {
  font-family: var(--font-display);
  font-size: 14px;
  margin-bottom: 10px;
}

.help-card ul {
  padding-left: 18px;
  font-size: 13px;
  color: var(--text-muted);
}

.help-card li {
  margin-bottom: 8px;
}

/* Analysis Main Panel */
.analyzer-main-panel {
  position: relative;
  min-height: 400px;
}

.analysis-result-card {
  min-height: 400px;
  display: flex;
  flex-direction: column;
}

.analysis-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 16px;
  margin-bottom: 20px;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-title h3 {
  font-family: var(--font-display);
  font-size: 18px;
}

.purple-icon {
  color: #C0B6FF;
}

/* Loading Overlay inside panel */
.analysis-loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(8, 11, 17, 0.85);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-lg);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
  border: 1px solid var(--panel-border);
}

.loader-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(122, 90, 248, 0.15);
  border-top: 4px solid var(--gemini-purple);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loader-text h4 {
  font-family: var(--font-display);
  font-size: 18px;
  margin-bottom: 4px;
}

.loader-text p {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 20px;
}

.loading-progress-bar {
  width: 100%;
  max-width: 300px;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--btn-gradient);
  border-radius: 10px;
  transition: width 0.4s ease;
}

/* Markdown Styling inside analysis card */
.markdown-body {
  font-size: 14px;
  line-height: 1.6;
  color: #D1D5DB;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3 {
  font-family: var(--font-display);
  color: #FFF;
  margin-top: 24px;
  margin-bottom: 12px;
}

.markdown-body h3 {
  font-size: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 6px;
}

.markdown-body p {
  margin-bottom: 12px;
}

.markdown-body ul {
  padding-left: 20px;
  margin-bottom: 16px;
}

.markdown-body li {
  margin-bottom: 6px;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 13px;
}

.markdown-body th, .markdown-body td {
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 12px;
  text-align: left;
}

.markdown-body th {
  background: rgba(255, 255, 255, 0.03);
  font-weight: 600;
  color: #FFF;
}

/* --- TAB 3: SETTINGS --- */
.settings-card h2 {
  font-family: var(--font-display);
  font-size: 22px;
  margin-bottom: 8px;
}

.settings-card p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.form-group label {
  font-size: 13px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
}

.help-link {
  color: var(--tiktok-cyan);
  text-decoration: none;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.help-link i {
  width: 12px;
  height: 12px;
}

.password-input-wrapper {
  position: relative;
}

.password-input-wrapper input {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  padding: 12px 48px 12px 16px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  color: var(--text-main);
  font-size: 14px;
}

.password-input-wrapper input:focus {
  outline: none;
  border-color: var(--gemini-purple);
}

.toggle-password-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}

.field-help {
  font-size: 11px;
  color: var(--text-muted);
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 10px;
}

/* Button UI Components */
.btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--btn-gradient);
  color: #fff;
  border: none;
}

.btn-primary:hover {
  opacity: 0.95;
  box-shadow: 0 4px 15px rgba(255, 0, 80, 0.2);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-main);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
}

/* --- FOOTER --- */
.app-footer-bar {
  text-align: center;
  padding: 20px 0;
  margin-top: 40px;
  border-top: 1px solid var(--panel-border);
  color: var(--text-muted);
  font-size: 12px;
}

/* --- LANGUAGE SELECTOR & MODAL --- */
.lang-select {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 12px;
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.lang-select:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.lang-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(8, 11, 17, 0.85);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.lang-modal-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.lang-modal-content {
  width: 90%;
  max-width: 480px;
  padding: 40px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(17, 24, 39, 0.85);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  animation: modalSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.lang-modal-logo {
  position: relative;
  width: 60px;
  height: 60px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin: 0 auto 24px auto;
}

.lang-modal-logo i {
  position: absolute;
  width: 32px;
  height: 32px;
}

.lang-modal-content h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.lang-modal-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 32px;
}

.lang-options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.lang-option-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  padding: 16px;
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.lang-option-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

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

.lang-flag {
  font-size: 24px;
  line-height: 1;
}

.lang-name {
  flex-grow: 1;
  text-align: left;
}

/* --- VIDEO PREVIEW MODAL --- */
.preview-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(8, 11, 17, 0.85);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.preview-modal-overlay.hidden {
  display: none !important;
}

.preview-modal-content {
  width: 90%;
  max-width: 380px;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(17, 24, 39, 0.9);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  animation: modalSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
