/* ==========================================================================
   DESIGN SYSTEM & VARIABLES
   ========================================================================== */
:root {
  --bg-app: #ffffff;
  --bg-gradient: #ffffff;
  --bg-glass: #ffffff;
  --bg-glass-hover: #f8fafc;
  --border-glass: #e2e8f0;
  --border-active: rgba(255, 152, 0, 0.5);

  --primary: #ff9800;
  --primary-glow: rgba(255, 152, 0, 0.3);
  --secondary: #ff5722;
  --secondary-glow: rgba(255, 87, 34, 0.3);
  --success: #2ecc71;
  --success-glow: rgba(46, 204, 113, 0.2);
  --warning: #f1c40f;
  --error: #e74c3c;

  --text-main: #2c3e50;
  --text-muted: #7f8c8d;
  --text-highlight: #ff9800;
}

/* ==========================================================================
   RESET & SCROLLBAR
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg-app);
  color: var(--text-main);
  width: 780px;
  height: 600px; /* Chrome extension popup hard limit is 600px */
  overflow: hidden;
  user-select: none;
}

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #f1f5f9;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-glow);
}

/* ==========================================================================
   APP CONTAINER LAYOUT
   ========================================================================== */
.app-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: var(--bg-gradient);
  /* border: 1px solid var(--border-glass); */
  position: relative;
  overflow: hidden;
}

.app-header {
  padding: 16px 20px 12px 20px;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.logo-area {
  display: flex;
  align-items: center;
  position: relative;
  z-index: 1;
}

.logo-glow {
  position: absolute;
  width: 80px;
  height: 25px;
  background: radial-gradient(
    circle,
    rgba(255, 152, 0, 0.4) 0%,
    transparent 70%
  );
  filter: blur(8px);
  z-index: -1;
  top: 5px;
}

.logo-text {
  font-family: "Outfit", sans-serif;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text-main);
}

.logo-text .highlight {
  color: var(--primary);
  text-shadow: 0 0 10px var(--primary-glow);
}

.subtitle {
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-top: 2px;
  font-weight: 600;
}

.app-content-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  width: 100%;
}

.app-main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
  display: flex; /* Make app-main a flex container so view-section can fill it */
  flex-direction: column;
}

/* ==========================================================================
   VIEW ANIMATIONS
   ========================================================================== */
.view-section {
  display: none;
  width: 100%;
  flex-direction: column;
}

/* Active view fills the full app-main height as a flex column */
.view-section.active {
  display: flex;
  flex: 1; /* Fill available height from .app-main flex container */
  min-height: 0; /* Allow shrinking below content size so overflow-y works */
  overflow: hidden; /* Clip — actual scrolling happens in .input-scroll-body */
}

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

/* ==========================================================================
   1. INPUT VIEW STYLING
   ========================================================================== */
.toggle-container {
  display: flex;
  background: #f1f5f9;
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 20px;
}

.toggle-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px;
  font-family: "Outfit", sans-serif;
  font-size: 15px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.25s ease;
}

.toggle-btn .icon {
  width: 16px;
  height: 16px;
}

.toggle-btn:hover {
  color: var(--text-main);
  background: #ffffff;
}

.toggle-btn.active {
  background: var(--bg-glass-hover);
  color: var(--primary);
}

.input-group {
  display: none;
  margin-bottom: 20px;
  flex-direction: column;
}

.input-group.active {
  display: flex;
}

.input-label {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}

.url-input-wrapper {
  display: flex;
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 2px 8px;
  transition: all 0.3s ease;
}

.url-input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 12px rgba(255, 152, 0, 0.15);
}

#input-video-url {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 12px 6px;
  color: var(--text-main);
  font-size: 15px;
  font-family: inherit;
}

#input-video-url::placeholder {
  color: rgba(0, 0, 0, 0.35);
}

.icon-btn-clear {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.icon-btn-clear svg {
  width: 14px;
  height: 14px;
}

.icon-btn-clear:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.input-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}

/* DROPZONE */
.dropzone-area {
  border: 2px dashed var(--border-glass);
  border-radius: 12px;
  padding: 24px 20px;
  text-align: center;
  cursor: pointer;
  background: #f8fafc;
  transition: all 0.3s ease;
  min-height: 130px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.dropzone-area.dragover {
  border-color: var(--primary);
  background: rgba(255, 152, 0, 0.03);
  box-shadow: 0 0 15px rgba(255, 152, 0, 0.1);
}

.dropzone-icon-wrapper {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.03);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px auto;
  color: var(--text-muted);
  border: 1px solid var(--border-glass);
  transition: all 0.3s ease;
}

.dropzone-area:hover .dropzone-icon-wrapper {
  color: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
  transform: translateY(-2px);
}

.dropzone-icon {
  width: 22px;
  height: 22px;
}

.dropzone-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 4px;
}

.dropzone-title .highlight {
  color: var(--primary);
  font-weight: 600;
}

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

/* File Selected State */
.file-info-box {
  display: flex;
  align-items: center;
  width: 100%;
  background: var(--bg-glass-hover);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 10px 14px;
  gap: 12px;
  text-align: left;
}

.file-icon {
  width: 24px;
  height: 24px;
  color: var(--primary);
}

.file-details {
  flex: 1;
  min-width: 0; /* Cho phép text truncation */
}

.file-name-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size-text {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 1px;
}

.btn-remove {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-remove svg {
  width: 16px;
  height: 16px;
}

.btn-remove:hover {
  background: rgba(231, 76, 60, 0.1);
  color: var(--error);
}

/* CONFIGURATION STYLES */
.config-section {
  background: #f8fafc;
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.config-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.radio-option {
  display: flex;
  align-items: center;
  cursor: pointer;
  position: relative;
}

.radio-option input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.radio-custom {
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-glass);
  border-radius: 50%;
  margin-right: 8px;
  display: inline-block;
  position: relative;
  background: #f1f5f9;
  transition: all 0.2s;
}

.radio-option input:checked ~ .radio-custom {
  border-color: var(--primary);
  box-shadow: 0 0 8px var(--primary-glow);
}

.radio-custom::after {
  content: "";
  position: absolute;
  display: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  top: 3px;
  left: 3px;
}

.radio-option input:checked ~ .radio-custom::after {
  display: block;
}

.radio-label-text {
  font-size: 15px;
  color: var(--text-main);
  font-weight: 500;
}

/* CHECKBOX GROUP */
.checkbox-group {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 8px;
}

.checkbox-option {
  display: flex;
  align-items: center;
  cursor: pointer;
  position: relative;
}

.checkbox-option input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.checkbox-custom {
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-glass);
  border-radius: 4px;
  margin-right: 8px;
  display: inline-block;
  position: relative;
  background: #f1f5f9;
  transition: all 0.2s;
}

.checkbox-option input:checked ~ .checkbox-custom {
  border-color: var(--primary);
  box-shadow: 0 0 8px var(--primary-glow);
}

.checkbox-custom::after {
  content: "";
  position: absolute;
  display: none;
  left: 5px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid var(--primary);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox-option input:checked ~ .checkbox-custom::after {
  display: block;
}

.checkbox-label-text {
  font-size: 15px;
  color: var(--text-main);
  font-weight: 500;
}

/* MARKETING DIRECTION GRID */
.mkt-direction-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}

.mkt-direction-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-glass);
  background: #f8fafc;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.mkt-direction-option input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.mkt-direction-option:hover {
  border-color: rgba(255, 152, 0, 0.3);
  background: rgba(255, 152, 0, 0.04);
}

.mkt-direction-option.selected {
  border-color: var(--primary);
  background: rgba(255, 152, 0, 0.07);
}

.mkt-direction-icon {
  font-size: 18px;
  line-height: 1;
  margin-bottom: 2px;
}

.mkt-direction-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.mkt-direction-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.3;
}

.mkt-direction-option.selected .mkt-direction-label {
  color: var(--primary);
}

/* ACTION BUTTON */
.btn-primary-glow {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  border: none;
  color: #fff;
  padding: 14px 20px;
  border-radius: 8px;
  font-family: "Outfit", sans-serif;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 4px 15px rgba(255, 152, 0, 0.2);
  position: relative;
}

.btn-primary-glow::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  filter: blur(12px);
  opacity: 0.4;
  border-radius: 8px;
  z-index: -1;
  transition: opacity 0.3s;
}

.btn-primary-glow:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 152, 0, 0.35);
}

.btn-primary-glow:hover::after {
  opacity: 0.4;
}

.btn-primary-glow:active {
  transform: translateY(1px);
  box-shadow: 0 2px 10px rgba(255, 152, 0, 0.15);
}

.btn-icon {
  width: 18px;
  height: 18px;
  transition: transform 0.3s;
}

.btn-primary-glow:hover .btn-icon {
  transform: translateX(4px);
}

/* INPUT VIEW LAYOUT */
#view-input {
  padding: 0; /* padding được xử lý bởi các child */
}

.input-scroll-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain; /* Không scroll chain lên parent */
  scrollbar-gutter: stable; /* Giữ layout ổn định khi scrollbar xuất hiện */
  padding: 20px 20px 12px 20px;
  display: block;
}

.input-sticky-footer {
  flex-shrink: 0;
  padding: 12px 20px 16px 20px;
  border-top: 1px solid var(--border-glass);
  background: var(--bg-gradient);
}

#btn-submit {
  width: 100%;
}

/* ==========================================================================
   2. PROCESSING VIEW STYLING
   ========================================================================== */
#view-processing {
  justify-content: flex-start;
  align-items: center;
  padding: 40px 30px;
  overflow-y: auto;
}

#processing-loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
}

/* Spinner */
.spinner-container {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 0 auto 24px auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pulse-orb {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse 2s infinite ease-in-out;
  position: absolute;
  top: calc(50% - 16px);
  left: calc(50% - 16px);
}

.rotating-ring {
  border-radius: 50%;
  border: 2px solid transparent;
  position: absolute;
}

.rotating-ring.ring-1 {
  width: 64px;
  height: 64px;
  border-top-color: var(--primary);
  border-bottom-color: var(--primary-glow);
  animation: spin 1.5s linear infinite;
  top: calc(50% - 32px);
  left: calc(50% - 32px);
}

.rotating-ring.ring-2 {
  width: 80px;
  height: 80px;
  border-left-color: var(--secondary);
  border-right-color: var(--secondary-glow);
  animation: spin 2.5s linear infinite reverse;
  top: calc(50% - 40px);
  left: calc(50% - 40px);
}

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

@keyframes pulse {
  0%,
  100% {
    transform: scale(0.9);
    box-shadow: 0 0 15px rgba(255, 152, 0, 0.5);
    background: var(--primary);
  }
  50% {
    transform: scale(1.15);
    box-shadow: 0 0 30px rgba(155, 89, 182, 0.7);
    background: var(--secondary);
  }
}

.processing-title {
  font-family: "Outfit", sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.processing-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* Steps Progress Panel */
.progress-steps {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 20px;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0.4;
  transition: all 0.3s ease;
}

.step-item.active {
  opacity: 1;
}

.step-item.completed {
  opacity: 1;
}

.step-bullet {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}

.bullet-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  display: block;
}

.step-item.active .step-bullet {
  border-color: var(--primary);
  box-shadow: 0 0 8px var(--primary-glow);
}

.step-item.active .bullet-dot {
  background: var(--primary);
  animation: bulletPulse 1s infinite alternate;
}

.step-item.completed .step-bullet {
  border-color: var(--success);
  background: var(--success);
}

.step-item.completed .bullet-dot {
  background: #fff;
  width: 4px;
  height: 4px;
}

@keyframes bulletPulse {
  0% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  100% {
    transform: scale(1.3);
    opacity: 1;
  }
}

.step-label {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
}

.step-item.active .step-label {
  color: var(--text-main);
  font-weight: 600;
}

.step-item.completed .step-label {
  color: var(--text-muted);
  text-decoration: none;
}

/* Console Logs Box */
.console-box {
  width: 100%;
  flex: 1;
  min-height: 250px; /* Thêm min-height để hộp log đủ cao, dễ nhìn */
  max-height: 400px;
  display: flex;
  flex-direction: column;
  background: #05060b;
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  overflow: hidden;
  font-family: monospace;
}

.console-header {
  background: #ffffff;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

.console-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: block;
}

.console-dot.red {
  background: var(--error);
}
.console-dot.yellow {
  background: var(--warning);
}
.console-dot.green {
  background: var(--success);
}

.console-title {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 4px;
}

.console-content {
  flex: 1;
  padding: 10px;
  overflow-y: auto;
  font-size: 13px;
  color: #39ff14; /* Matrix Green */
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.log-line {
  line-height: 1.4;
  word-break: break-all;
}

.log-line.system {
  color: var(--text-muted);
}
.log-line.error {
  color: var(--error);
}

/* ==========================================================================
   3. RESULTS VIEW STYLING
   ========================================================================== */
#view-results {
  padding: 12px 14px;
  overflow: hidden;
  height: 510px;
}

/* Tabs Navigation */
.results-nav {
  display: flex;
  background: #f1f5f9;
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 12px;
  gap: 2px;
}

.nav-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 4px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  font-family: "Outfit", sans-serif;
  white-space: nowrap;
}

.nav-tab:hover {
  color: var(--text-main);
}

.nav-tab.active {
  background: var(--bg-glass-hover);
  color: var(--primary);
  border: 1px solid rgba(0, 0, 0, 0.03);
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.05);
}

/* Tabs Content Wrapper */
.results-tab-content {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 12px;
  padding-right: 2px;
}

.tab-panel {
  display: none;
  flex-direction: column;
  animation: fadeIn 0.25s ease-out;
}

.tab-panel.active {
  display: flex;
}

.tab-header-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.panel-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.btn-text-action {
  background: transparent;
  border: none;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 4px;
  transition: all 0.2s;
}

.btn-text-action:hover {
  background: rgba(255, 152, 0, 0.08);
}

.icon-small {
  width: 12px;
  height: 12px;
}

/* FB POST FEED */
.posts-feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.post-card {
  background: #ffffff;
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.2s;
}

.post-card:hover {
  transform: translateY(-1px);
  background: rgba(0, 0, 0, 0.03);
}

.post-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  padding-bottom: 6px;
}

.post-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.post-body {
  font-size: 15px;
  color: var(--text-main);
  line-height: 1.5;
  white-space: pre-wrap;
  user-select: text; /* Cho phép bôi đen copy */
}

/* TIKTOK FEED */
.tiktok-feed {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tiktok-card {
  background: #ffffff;
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  overflow: hidden;
}

.tiktok-card-header {
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.01);
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: background 0.2s;
}

.tiktok-card-header:hover {
  background: rgba(0, 0, 0, 0.03);
}

.tiktok-card-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tiktok-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

.tiktok-card-tag {
  font-size: 12px;
  color: var(--text-muted);
}

.tiktok-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-arrow {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: transform 0.25s;
}

.tiktok-card.expanded .icon-arrow {
  transform: rotate(180deg);
  color: var(--primary);
}

.tiktok-card-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tiktok-card.expanded .tiktok-card-body {
  max-height: 1000px; /* Giá trị cao đủ để chứa nội dung */
  padding: 14px;
  border-top: 1px solid rgba(0, 0, 0, 0.02);
}

.tiktok-meta-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  background: #f8fafc;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
}

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

.tiktok-meta-val {
  color: var(--text-main);
  font-weight: 500;
}

.tiktok-scene-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scene-block {
  border-left: 2px solid var(--secondary);
  padding-left: 10px;
  margin-left: 4px;
}

.scene-title-row {
  font-size: 13px;
  font-weight: 700;
  color: var(--secondary);
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
}

.scene-time {
  color: var(--text-muted);
  font-weight: normal;
}

.scene-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
}

.scene-visual {
  color: var(--text-muted);
  font-style: italic;
}

.scene-audio {
  color: var(--text-main);
  line-height: 1.4;
  user-select: text;
}

.tiktok-cta-box {
  margin-top: 12px;
  padding: 8px 10px;
  background: rgba(46, 204, 113, 0.05);
  border: 1px solid rgba(46, 204, 113, 0.15);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text-main);
}

.tiktok-cta-box strong {
  color: var(--success);
}

/* BLOG PREVIEW */
.blog-preview-card {
  background: #ffffff;
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.blog-meta-box {
  background: #f1f5f9;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
  border-left: 3px solid var(--primary);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.blog-meta-box p {
  color: var(--text-main);
}

.blog-meta-box .meta-desc {
  color: var(--text-muted);
  line-height: 1.4;
}

.blog-markdown-body {
  font-size: 15px;
  color: var(--text-main);
  line-height: 1.6;
  white-space: pre-wrap;
  user-select: text;
}

/* Kiểu markdown hiển thị thô đẹp */
.blog-markdown-body h2 {
  font-family: "Outfit", sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 16px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  padding-bottom: 4px;
}

.blog-markdown-body h3 {
  font-family: "Outfit", sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  margin-top: 12px;
  margin-bottom: 6px;
}

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

.blog-markdown-body ul,
.blog-markdown-body ol {
  padding-left: 16px;
  margin-bottom: 8px;
}

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

/* TRANSCRIPT TAB */
.transcript-box-wrapper {
  flex: 1;
  min-height: 450px;
  /* background: #f1f5f9; */
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  overflow: hidden;
}

.transcript-textarea {
  width: 100%;
  height: 100%;
  min-height: 450px;
  border: none;
  outline: none;
  padding: 12px;
  background: #ffffff;
  color: var(--text-main);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  user-select: text;
}

.transcript-textarea:read-only {
  opacity: 1;
}

/* FOOTER BUTTONS */
.btn-secondary {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  padding: 12px 20px;
  border-radius: 8px;
  font-family: "Outfit", sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  width: 100%;
  margin-top: 8px;
}

.btn-secondary:hover {
  background: var(--bg-glass-hover);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-secondary svg {
  width: 14px;
  height: 14px;
}

/* ==========================================================================
   ERROR STATE STYLING
   ========================================================================== */
.error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  animation: fadeIn 0.3s ease-out;
  margin-bottom: 16px;
}

.error-icon-wrapper {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(231, 76, 60, 0.1);
  border: 1px solid rgba(231, 76, 60, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--error);
  margin-bottom: 12px;
  box-shadow: 0 0 15px rgba(231, 76, 60, 0.2);
}

.error-icon {
  width: 24px;
  height: 24px;
}

.error-title {
  font-family: "Outfit", sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
}

.error-message-text {
  font-size: 14px;
  color: #ff9f9f;
  line-height: 1.5;
  background: rgba(231, 76, 60, 0.05);
  border: 1px solid rgba(231, 76, 60, 0.2);
  border-radius: 8px;
  padding: 10px 14px;
  width: 100%;
  margin-bottom: 16px;
  word-break: break-word;
  user-select: text;
  text-align: left;
  max-height: 120px;
  overflow-y: auto;
}

.btn-error-back {
  background: #f8fafc;
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  padding: 10px 16px;
  border-radius: 8px;
  font-family: "Outfit", sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
  width: 100%;
}

.btn-error-back:hover {
  background: #f1f5f9;
  border-color: var(--primary);
  color: var(--primary);
}

/* ==========================================================================
   GLOBAL TOAST ALERT
   ========================================================================== */
.toast-alert {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 20px);
  background: rgba(46, 204, 113, 0.95);
  border: 1px solid var(--success);
  color: #fff;
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(46, 204, 113, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 1000;
}

.toast-alert.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.btn-header-expand {
  position: absolute;
  right: 20px;
  top: 20px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-header-expand:hover {
  background: #f8fafc;
  color: var(--primary);
}

/* ==========================================================================
   3. SIDEBAR & HISTORY STYLING
   ========================================================================== */
.app-sidebar {
  display: none; /* Hidden by default in popup mode */
}

/* History Section for Popup Mode */
.history-section {
  margin-top: 24px;
  border-top: 1px solid var(--border-glass);
  padding-top: 16px;
}

.history-title {
  font-family: "Outfit", sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 185px;
  overflow-y: auto;
  padding-right: 4px;
}

/* Shared History Item Cards (used in both popup and sidebar) */
.history-item {
  position: relative;
  background: #ffffff;
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item:hover {
  background: #f8fafc;
  border-color: rgba(255, 152, 0, 0.25);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transform: translateX(2px);
}

.history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.history-item-type {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  display: inline-block;
}

.history-item-type.youtube {
  background: rgba(231, 76, 60, 0.15);
  color: #e74c3c;
  border: 1px solid rgba(231, 76, 60, 0.25);
}

.history-item-type.facebook {
  background: rgba(52, 152, 219, 0.15);
  color: #3498db;
  border: 1px solid rgba(52, 152, 219, 0.25);
}

.history-item-type.tiktok {
  background: rgba(241, 196, 15, 0.15);
  color: #f1c40f;
  border: 1px solid rgba(241, 196, 15, 0.25);
}

.history-item-type.podcast {
  background: rgba(155, 89, 182, 0.15);
  color: #9b59b6;
  border: 1px solid rgba(155, 89, 182, 0.25);
}

.btn-history-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.4;
  transition: all 0.2s ease;
}

.btn-history-delete:hover {
  color: var(--error);
  background: rgba(231, 76, 60, 0.12);
  opacity: 1;
}

.history-item-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 24px); /* Leave space for delete button */
}

.history-item-time {
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================================================
   FULL TAB DASHBOARD STYLING (mode=tab)
   ========================================================================== */
body.tab-mode {
  width: 100%;
  max-width: none;
  height: 100vh;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body.tab-mode .app-container {
  display: flex;
  flex-direction: row; /* Sidebar left, content right */
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  border: none;
  border-radius: 0;
}

body.tab-mode .app-sidebar {
  display: flex;
  flex-direction: column;
  width: 280px;
  min-width: 280px;
  background: #f8fafc;
  border-right: 1px solid var(--border-glass);
  padding: 24px 16px;
  height: 100%;
  box-sizing: border-box;
}

body.tab-mode .app-content-wrapper {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg-gradient);
}

body.tab-mode .app-header {
  display: none !important; /* Logo is now in sidebar */
}

body.tab-mode .app-main {
  flex: 1;
  padding: 24px 40px;
  height: 100%;
  overflow-y: auto;
}

body.tab-mode #view-input {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 0;
}

body.tab-mode #view-processing {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 0;
  min-height: 480px;
}

body.tab-mode #view-results {
  max-width: 1080px;
  margin: 0 auto;
  height: 100%;
}

body.tab-mode .results-tab-content {
  height: calc(100vh - 200px);
  max-height: none;
}

/* Sidebar Components Inside body.tab-mode */
.sidebar-header {
  margin-bottom: 24px;
  padding: 0 12px;
}

.sidebar-header .logo-text {
  font-size: 28px;
  margin-bottom: 2px;
}

.sidebar-header .subtitle {
  font-size: 12px;
  text-align: left;
}

.sidebar-btn-new {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--primary) 0%, #ff5722 100%);
  border: none;
  border-radius: 8px;
  color: #ffffff;
  font-family: "Outfit", sans-serif;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 15px var(--primary-glow);
  margin-bottom: 28px;
}

.sidebar-btn-new:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 152, 0, 0.45);
}

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

.sidebar-history-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 14px;
  padding: 0 12px;
}

.sidebar-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ==========================================================================
   4. TIKTOK TAB ANALYSIS BLOCK STYLING
   ========================================================================== */
.tiktok-analysis-block {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 8px 4px;
}

.analysis-section-block {
  background: rgba(0, 0, 0, 0.015);
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  padding: 16px;
}

.analysis-block-title {
  font-family: "Outfit", sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-shadow: 0 0 10px var(--primary-glow);
}

.analysis-item-box {
  margin-bottom: 12px;
}

.analysis-item-box:last-child {
  margin-bottom: 0;
}

.analysis-sub-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}

.analysis-text-val {
  font-size: 15px;
  color: var(--text-main);
  line-height: 1.7;
  background: #f8fafc;
  padding: 12px 14px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.03);
}

.analysis-text-val li {
  list-style-type: disc;
  margin-left: 16px;
  margin-top: 4px;
}

.analysis-list-val {
  font-size: 15px;
  color: var(--text-main);
  line-height: 1.7;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.analysis-list-val li {
  list-style-type: disc;
}
