/* ==========================================================================
   AI TikTok Affiliate Hub & Studio — Cloudflare Pages Theme
   Author: AI Studio Automation
   ========================================================================== */

:root {
  --bg: #090A0F;
  --bg-card: #12141D;
  --bg-elevated: #181B27;
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(254, 44, 85, 0.5);
  
  --txt: #F4F4F5;
  --txt-muted: #9CA3AF;
  
  --tiktok-red: #FE2C55;
  --tiktok-cyan: #25F4EE;
  --yellow-basket: #FACC15;
  --green-money: #10B981;
  
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: 'Outfit', sans-serif;
  --font-mono: ui-monospace, Menlo, Consolas, monospace;
}

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

body {
  background: var(--bg);
  color: var(--txt);
  font-family: var(--font-main);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 10% 10%, rgba(254, 44, 85, 0.06) 0%, transparent 40%),
    radial-gradient(circle at 90% 90%, rgba(37, 244, 238, 0.05) 0%, transparent 40%);
}

/* Container */
.app-container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 20px 16px 80px;
}

/* Top Navbar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: rgba(18, 20, 29, 0.85);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 16px;
  position: sticky;
  top: 14px;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.brand-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo-icon {
  width: 38px;
  height: 38px;
  background: #000;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px rgba(254, 44, 85, 0.4);
}

.brand-titles h1 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #FFF;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--txt-muted);
}

/* Mode Switcher Tabs */
.mode-switcher {
  display: flex;
  background: rgba(0, 0, 0, 0.4);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  gap: 4px;
}

.tab-switch-btn {
  background: none;
  border: none;
  color: var(--txt-muted);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab-switch-btn:hover {
  color: #FFF;
}

.tab-switch-btn.active {
  background: var(--tiktok-red);
  color: #FFF;
  box-shadow: 0 2px 10px rgba(254, 44, 85, 0.4);
}

/* Live Telemetry Bar */
.live-bar {
  margin-top: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
}

.pulse-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--green-money);
}

.pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green-money);
  box-shadow: 0 0 10px var(--green-money);
  animation: pulse 1.8s infinite;
}

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

.live-metrics {
  display: flex;
  gap: 18px;
  color: var(--txt-muted);
}

.live-metrics b {
  color: #FFF;
}

/* Views Section (Showroom Mode) */
.view-section {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.view-section.active {
  display: block;
}

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

/* Bio Hero Banner */
.bio-hero {
  margin-top: 24px;
  background: linear-gradient(135deg, rgba(254, 44, 85, 0.12) 0%, rgba(37, 244, 238, 0.08) 100%), var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 26px 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.channel-avatar {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  border: 3px solid var(--tiktok-red);
  box-shadow: 0 0 25px rgba(254, 44, 85, 0.4);
  margin: 0 auto 14px;
  object-fit: cover;
}

.channel-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.verified-badge {
  color: #38BDF8;
}

.channel-tagline {
  color: var(--txt-muted);
  font-size: 14.5px;
  max-width: 580px;
  margin: 8px auto 16px;
  line-height: 1.6;
}

.channel-stats {
  display: flex;
  justify-content: center;
  gap: 28px;
  font-size: 13.5px;
}

.channel-stats b {
  color: var(--tiktok-cyan);
  font-size: 16px;
}

/* Category Filter Bar */
.filter-tabs-row {
  display: flex;
  gap: 8px;
  margin: 28px 0 18px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.filter-chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--txt-muted);
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.filter-chip:hover {
  color: #FFF;
  border-color: rgba(255, 255, 255, 0.2);
}

.filter-chip.active {
  background: rgba(254, 44, 85, 0.15);
  color: var(--tiktok-red);
  border-color: var(--tiktok-red);
}

/* Products Grid */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
}

.product-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-focus);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(254, 44, 85, 0.15);
}

.product-thumb-box {
  width: 100%;
  height: 220px;
  position: relative;
  background: #1A1D29;
  overflow: hidden;
}

.product-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.product-card:hover .product-img {
  transform: scale(1.05);
}

.discount-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--tiktok-red);
  color: #FFF;
  font-size: 11.5px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.growth-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: linear-gradient(135deg, #FF5500 0%, #FE2C55 100%);
  color: #FFF;
  font-size: 11.5px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(254, 44, 85, 0.4);
  display: flex;
  align-items: center;
  gap: 3px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  letter-spacing: 0.2px;
}

.product-card-body {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.product-title {
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.4;
  color: #FFF;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-usp {
  font-size: 12px;
  color: var(--txt-muted);
  line-height: 1.5;
  margin-bottom: 12px;
  flex: 1;
}

.price-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 14px;
}

.curr-price {
  font-size: 18px;
  font-weight: 900;
  color: var(--yellow-basket);
}

.orig-price {
  font-size: 12px;
  color: #6B7280;
  text-decoration: line-through;
}

.btn-buy-basket {
  width: 100%;
  background: linear-gradient(135deg, var(--yellow-basket), #EAB308);
  color: #111;
  border: none;
  border-radius: 10px;
  padding: 10px;
  font-size: 13.5px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 3px 12px rgba(250, 204, 21, 0.35);
  transition: all 0.2s;
}

.btn-buy-basket:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

/* Daily Fortune / Voucher Section */
.fortune-card {
  margin-top: 36px;
  background: var(--bg-card);
  border: 1.5px dashed var(--yellow-basket);
  border-radius: 18px;
  padding: 24px;
  text-align: center;
}

.fortune-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--yellow-basket);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.fortune-result {
  margin: 12px auto;
  font-size: 15px;
  color: #E4E4E7;
  max-width: 600px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* AI Studio Layout */
.studio-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  margin-top: 24px;
}

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

.studio-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-header-title {
  font-size: 16px;
  font-weight: 800;
  color: #FFF;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Angles Switcher */
.angles-nav {
  display: flex;
  gap: 6px;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow-x: auto;
}

.angle-btn {
  background: none;
  border: none;
  color: var(--txt-muted);
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.angle-btn.active {
  background: var(--tiktok-red);
  color: #FFF;
  font-weight: 700;
}

.script-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  font-size: 13.5px;
  line-height: 1.6;
}

.script-box textarea {
  width: 100%;
  background: none;
  border: none;
  color: #FFF;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.6;
  resize: vertical;
  min-height: 120px;
  outline: none;
}

/* Phone Mockup 9:16 in Studio */
.phone-preview-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.phone-case {
  width: 250px;
  height: 445px;
  background: #000;
  border-radius: 28px;
  border: 3px solid #2B2F3E;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.8), 0 0 25px rgba(254, 44, 85, 0.2);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.phone-screen-inner {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.phone-bg-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.phone-ui-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0) 40%, rgba(0,0,0,0.85) 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 12px;
  color: #FFF;
}

.phone-yellow-btn {
  background: rgba(250, 204, 21, 0.95);
  color: #111;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 2px 10px rgba(254, 204, 21, 0.5);
  animation: basketPulse 2s infinite;
  cursor: pointer;
  margin-top: 6px;
}

@keyframes basketPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

/* Live Terminal */
.terminal-block {
  background: #06070A;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  color: #34D399;
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Footer */
footer {
  margin-top: 50px;
  border-top: 1px solid var(--border);
  padding-top: 24px;
  text-align: center;
  color: var(--txt-muted);
  font-size: 13px;
}

footer a {
  color: var(--tiktok-cyan);
  text-decoration: none;
  font-weight: 700;
}

.growth-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: linear-gradient(135deg, #FE2C55 0%, #FF0050 100%);
  color: #FFF;
  font-size: 10.5px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(254, 44, 85, 0.5);
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 2;
  animation: pulse 2s infinite;
}

/* ==========================================================================
   GIAI ĐOẠN 3: AI SCANNER, CLOUDFLARE FUNCTIONS & WEBHOOK BRIDGE STYLES
   ========================================================================== */

/* Scanner Card */
.scanner-card {
  background: linear-gradient(135deg, rgba(24, 27, 39, 0.95) 0%, rgba(18, 20, 29, 0.95) 100%);
  border: 1px solid rgba(37, 244, 238, 0.25);
  border-radius: 16px;
  padding: 18px 20px;
  margin-bottom: 22px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  position: relative;
  overflow: hidden;
}

.scanner-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--tiktok-red), var(--tiktok-cyan), var(--yellow-basket));
}

.scanner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 10px;
}

.scanner-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 800;
  color: #FFF;
}

.badge-stage3 {
  background: linear-gradient(135deg, #FE2C55, #FF0050);
  color: #FFF;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 2px 8px rgba(254, 44, 85, 0.4);
}

.ai-engine-badge {
  background: rgba(37, 244, 238, 0.12);
  color: var(--tiktok-cyan);
  border: 1px solid rgba(37, 244, 238, 0.3);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-config-key {
  background: rgba(255, 255, 255, 0.06);
  color: var(--txt);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-config-key:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  color: #FFF;
}

.input-with-button {
  display: flex;
  gap: 10px;
  position: relative;
}

.input-with-button input {
  flex: 1;
  background: #090A0F;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 12px 16px;
  color: #FFF;
  font-size: 13.5px;
  font-family: var(--font-main);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-with-button input:focus {
  border-color: var(--tiktok-cyan);
  box-shadow: 0 0 12px rgba(37, 244, 238, 0.25);
}

.input-with-button input::placeholder {
  color: #6B7280;
}

.btn-scan {
  background: linear-gradient(135deg, #FE2C55 0%, #E01E49 100%);
  color: #FFF;
  border: none;
  border-radius: 10px;
  padding: 0 20px;
  font-size: 13.5px;
  font-weight: 700;
  font-family: var(--font-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(254, 44, 85, 0.4);
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.2s;
}

.btn-scan:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(254, 44, 85, 0.55);
}

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

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

/* Quick links */
.quick-links-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--txt-muted);
}

.quick-link-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #D1D5DB;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.2s;
}

.quick-link-chip:hover {
  background: rgba(37, 244, 238, 0.1);
  border-color: rgba(37, 244, 238, 0.3);
  color: var(--tiktok-cyan);
}

/* Scanner Status banner */
.scanner-status {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: fadeIn 0.3s ease;
}

.scanner-status.loading {
  background: rgba(37, 244, 238, 0.08);
  border: 1px solid rgba(37, 244, 238, 0.25);
  color: var(--tiktok-cyan);
}

.scanner-status.success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34D399;
}

.scanner-status.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #F87171;
}

/* Spinner */
.spin-loader {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(37, 244, 238, 0.3);
  border-top-color: var(--tiktok-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

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

/* Product Selector Bar in Studio */
.product-picker-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 0 12px;
  margin-bottom: 14px;
}

.product-picker-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  font-size: 12px;
  color: var(--txt-muted);
  transition: all 0.2s;
  flex-shrink: 0;
}

.product-picker-chip:hover {
  background: var(--bg-elevated);
  color: #FFF;
}

.product-picker-chip.active {
  background: rgba(254, 44, 85, 0.12);
  border-color: var(--tiktok-red);
  color: #FFF;
  font-weight: 700;
  box-shadow: 0 0 10px rgba(254, 44, 85, 0.2);
}

.product-picker-chip img {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  object-fit: cover;
}

/* Badge for newly scanned items */
.badge-new-scan {
  position: absolute;
  top: 8px;
  left: 8px;
  background: linear-gradient(135deg, #10B981, #059669);
  color: #FFF;
  font-size: 9.5px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.4);
}

/* Webhook bridge button */
.btn-webhook {
  background: linear-gradient(135deg, #0284C7 0%, #0369A1 100%) !important;
  color: #FFF !important;
  border: 1px solid rgba(56, 189, 248, 0.3) !important;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.3) !important;
}

.btn-webhook:hover {
  box-shadow: 0 6px 18px rgba(2, 132, 199, 0.45) !important;
}

/* Modal Popup */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  background: #141722;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  max-width: 480px;
  width: 100%;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
}

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

.modal-header h3 {
  font-size: 16px;
  font-family: var(--font-display);
  color: #FFF;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--txt-muted);
  font-size: 18px;
  cursor: pointer;
}

.btn-close-modal:hover {
  color: #FFF;
}

.modal-body input {
  width: 100%;
  background: #090A0F;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: #FFF;
  font-size: 13.5px;
  margin-top: 10px;
}

.modal-body input:focus {
  border-color: var(--tiktok-cyan);
  outline: none;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}
