/* META AD LIBRARY CARD DESIGN + CAROUSEL SLIDER + KEYWORD MATRIX (< 350 LINES) */

.ads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 24px;
  align-items: start;
}

.fb-ad-card {
  background: var(--bg-surface);
  border: 1px solid #dbe3ec;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.fb-ad-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-blue);
}

/* PHẦN TRÊN CÙNG GIỐNG META AD LIBRARY SCREENSHOT */
.fb-meta-top {
  padding: 13px 16px 11px;
  border-bottom: 1px solid #edf2f7;
  font-size: 12.2px;
  color: #4b5563;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #fcfdff;
}

.fb-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.fb-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 12.5px;
}

.fb-status-badge.active { color: #059669; }
.fb-status-badge.inactive { color: #64748b; }

.fb-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}
.fb-status-dot.active { background: #10b981; box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18); }
.fb-status-dot.inactive { background: #94a3b8; }

.fb-longevity-pill {
  font-size: 11.5px;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 99px;
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.fb-longevity-pill.super {
  background: #fff1f2;
  color: #be123c;
  border-color: #fecdd3;
}

.fb-collation-line {
  font-weight: 700;
  color: #1e293b;
  font-size: 12.3px;
  margin-top: 2px;
}

.fb-detail-btn {
  margin-top: 6px;
  width: 100%;
  padding: 7px 12px;
  background: #f1f5f9;
  hover: #e2e8f0;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #0f172a;
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.15s;
}
.fb-detail-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary-bright);
  color: var(--primary-dark);
}

/* DẢI NGÀNH CHÍNH & NGÀNH PHỤ TỰ ĐỘNG */
.fb-industry-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #f0f9ff;
  border-bottom: 1px solid #e0f2fe;
  font-size: 11.5px;
}

.ind-primary-tag {
  background: #0284c7;
  color: #ffffff;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
}

.ind-secondary-tag {
  background: #ffffff;
  color: #0369a1;
  border: 1px solid #bae6fd;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
}

/* FANPAGE HEADER */
.fb-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px 8px;
}

.fb-page-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.adv-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-bright), var(--primary));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  flex-shrink: 0;
  border: 1px solid #e2e8f0;
}

.fb-page-name {
  font-weight: 800;
  font-size: 14.5px;
  color: #0f172a;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fb-page-name:hover { color: var(--primary); text-decoration: underline; }

.fb-sponsored-sub {
  font-size: 11.8px;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.page-count-badge {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 99px;
  cursor: pointer;
  flex-shrink: 0;
}
.page-count-badge:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-color: var(--primary-bright);
}

/* CAPTION DỄ ĐỌC */
.fb-copy-wrap {
  padding: 4px 16px 10px;
  font-size: 13.5px;
  color: #1e293b;
  line-height: 1.55;
}

.fb-copy-text {
  white-space: pre-line;
  word-break: break-word;
}
.fb-copy-text.clamped {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.btn-read-more {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  margin-top: 4px;
  padding: 0;
}

/* MEDIA STAGE: HỖ TRỢ ĐẦY ĐỦ VIDEO TRỰC TIẾP & SLIDER NHIỀU ẢNH / CAROUSEL */
.fb-media-stage {
  position: relative;
  width: 100%;
  background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
  min-height: 250px;
  max-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-top: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
}

.fb-media-stage img {
  width: 100%;
  height: 290px;
  object-fit: contain;
  background: transparent;
  cursor: pointer;
}

.fb-media-stage video {
  width: 100%;
  max-height: 330px;
  background: #000;
}

.slider-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #cbd5e1;
  color: #0f172a;
  font-weight: 900;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.slider-nav-btn:hover { background: #fff; color: var(--primary); }
.slider-nav-btn.prev { left: 10px; }
.slider-nav-btn.next { right: 10px; }

.media-counter-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(15, 23, 42, 0.82);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 99px;
  z-index: 4;
}

/* CTA BAR GIỐNG BÀI QUẢNG CÁO FACEBOOK */
.fb-cta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.fb-cta-info { min-width: 0; flex: 1; }
.fb-cta-domain { font-size: 11px; color: #64748b; text-transform: uppercase; }
.fb-cta-headline { font-size: 13px; font-weight: 800; color: #0f172a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.fb-cta-btn {
  background: #e2e8f0;
  color: #0f172a;
  font-weight: 700;
  font-size: 12.2px;
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
  flex-shrink: 0;
}

.ad-body { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.pill-row { display: flex; flex-wrap: wrap; gap: 5px; }
.pill { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--bg-subtle); border: 1px solid var(--border); }
.pill-hook { background: var(--primary-light); color: var(--primary-dark); border-color: var(--border-blue); }
.pill-style { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.score-badge { background: var(--emerald-bg); color: var(--emerald); border: 1px solid #a7f3d0; padding: 4px 10px; border-radius: 99px; font-weight: 800; font-size: 12px; }
.ocr-box { background: var(--bg-soft); border-left: 3px solid var(--primary-bright); padding: 8px 12px; border-radius: 6px; font-size: 12.2px; color: var(--text-secondary); }
.ai-insight-box { background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; font-size: 12px; color: var(--text-secondary); white-space: pre-line; }
.ad-footer { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-top: 1px solid var(--border); background: var(--bg-subtle); }
.footer-actions { display: flex; gap: 6px; }
.icon-btn { background: #fff; border: 1px solid var(--border); color: var(--text-secondary); padding: 5px 10px; border-radius: 7px; font-size: 11.5px; font-weight: 600; cursor: pointer; }
.icon-btn:hover { border-color: var(--primary-bright); color: var(--primary-dark); background: var(--bg-soft); }
.icon-btn.fav-active { background: var(--amber-bg); border-color: #fcd34d; color: var(--amber); }

/* KEYWORD LADDER MATRIX (THẤP -> CAO) */
.kw-tiers-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.kw-tier-card {
  background: #f8fafc;
  border: 1px solid #dbeafe;
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kw-tier-head { font-size: 11px; font-weight: 800; color: var(--primary-dark); background: var(--primary-light); padding: 3px 8px; border-radius: 6px; align-self: flex-start; }
.kw-pill-btn { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; padding: 7px 10px; background: #ffffff; border: 1px solid var(--border-blue); border-radius: 8px; font-size: 12.2px; font-weight: 700; color: #0f172a; cursor: pointer; text-align: left; }
.kw-pill-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; font-size: 13px; }
.pagination-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.page-num-btn { min-width: 34px; height: 34px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); background: #ffffff; color: var(--text-main); font-size: 12.5px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: all 0.15s; }
.page-num-btn:hover:not(:disabled) { border-color: var(--primary-bright); color: var(--primary-dark); background: var(--bg-soft); }
.page-num-btn.active { background: var(--primary); color: #ffffff; border-color: var(--primary); box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25); }
.page-num-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.kw-mobile-tabs { display: none; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 10px; scrollbar-width: none; }
.kw-mobile-tabs::-webkit-scrollbar { display: none; }
.kw-mob-tab { flex-shrink: 0; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--border-blue); background: #fff; color: var(--primary-dark); font-size: 12px; font-weight: 700; cursor: pointer; }
.kw-mob-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.url-preview-box { margin-top: 6px; padding: 8px 10px; background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 8px; font-family: Consolas, monospace; font-size: 11.5px; color: #0369a1; word-break: break-all; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.58); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 150; padding: 20px; }
.modal-content { background: #fff; border-radius: 18px; max-width: 960px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 24px; position: relative; }
.modal-close { position: sticky; top: 0; float: right; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: #ffffff; cursor: pointer; font-weight: 800; z-index: 10; box-shadow: var(--shadow-sm); }
.modal-grid { display: grid; grid-template-columns: 1fr 1.1fr; gap: 22px; clear: both; }
.modal-spec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.modal-thumb-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 8px; max-height: 220px; overflow-y: auto; }

/* CENTRAL CONTROL DASHBOARD (BẢNG ĐIỀU KHIỂN TRUNG TÂM) */
.cc-panel { background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%); border: 2px solid #0284c7; border-radius: 18px; padding: 18px 20px; margin-bottom: 20px; box-shadow: 0 10px 28px -8px rgba(2, 132, 199, 0.16); }
.cc-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding-bottom: 12px; border-bottom: 1px solid #e2e8f0; margin-bottom: 14px; }
.cc-kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.cc-kpi-card { background: #ffffff; border: 1px solid #cbd5e1; border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow-sm); }
.cc-kpi-card.fb { border-top: 4px solid #2563eb; }
.cc-kpi-card.tt { border-top: 4px solid #0d9488; }
.cc-kpi-card.total { border-top: 4px solid #0284c7; }
.cc-kpi-card.ai { border-top: 4px solid #7c3aed; }
.cc-main-split { display: grid; grid-template-columns: 1.12fr 0.88fr; gap: 14px; align-items: stretch; }
.cc-box { background: #ffffff; border: 1px solid #cbd5e1; border-radius: 14px; padding: 14px; display: flex; flex-direction: column; }
.cc-filter-strip { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.cc-filter-btn { border: 1px solid #cbd5e1; background: #f8fafc; color: #334155; border-radius: 99px; padding: 4px 11px; font-size: 11.8px; font-weight: 700; cursor: pointer; transition: all 0.15s; }
.cc-filter-btn:hover { border-color: #0284c7; color: #0284c7; }
.cc-filter-btn.active { background: #0284c7; color: #ffffff; border-color: #0284c7; }
.cc-winfail-scroll { max-height: 410px; overflow-y: auto; border: 1px solid #e2e8f0; border-radius: 10px; background: #f8fafc; }
.cc-run-row { display: grid; grid-template-columns: 68px 138px 1fr 128px; gap: 10px; align-items: center; padding: 9px 12px; border-bottom: 1px solid #e2e8f0; font-size: 12.2px; background: #ffffff; }
.cc-run-row.win { border-left: 4px solid #10b981; }
.cc-run-row.zero { border-left: 4px solid #f59e0b; background: #fffdf5; }
.cc-run-row.fail { border-left: 4px solid #ef4444; background: #fff5f5; }
.cc-run-row.running { border-left: 4px solid #0284c7; background: #f0f9ff; }
.cc-col-time { font-family: monospace; font-weight: 700; color: #475569; font-size: 11.5px; }
.cc-plat-badge { display: inline-block; padding: 2px 7px; border-radius: 6px; font-size: 10.8px; font-weight: 800; }
.cc-plat-badge.fb { background: #dbeafe; color: #1e40af; }
.cc-plat-badge.tt { background: #ccfbf1; color: #0f766e; }
.cc-thread-sub, .cc-detail-sub, .cc-found-sub { font-size: 11px; color: #64748b; margin-top: 2px; line-height: 1.3; }
.cc-col-res { text-align: right; }
.cc-outcome-badge { display: inline-block; padding: 3px 8px; border-radius: 99px; font-size: 11px; font-weight: 800; }
.cc-outcome-badge.win { background: #10b981; color: #ffffff; }
.cc-outcome-badge.zero { background: #fef08a; color: #854d0e; }
.cc-outcome-badge.fail { background: #ef4444; color: #ffffff; }
.cc-outcome-badge.running { background: #0284c7; color: #ffffff; }
.cc-terminal { background: #0f172a; color: #e2e8f0; font-family: Consolas, monospace; font-size: 11.8px; line-height: 1.55; padding: 12px; border-radius: 10px; height: 410px; overflow-y: auto; }
.cc-term-line { padding: 3px 0; border-bottom: 1px dashed rgba(148, 163, 184, 0.14); word-break: break-word; }
.cc-log-tag { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 10px; font-weight: 800; margin-right: 5px; }
.cc-log-tag.win { background: #065f46; color: #6ee7b7; }
.cc-log-tag.fail { background: #7f1d1d; color: #fca5a5; }
.cc-log-tag.zero { background: #713f12; color: #fde047; }
.cc-log-tag.info { background: #1e293b; color: #94a3b8; }
.cc-log-plat { display: inline-block; padding: 1px 5px; border-radius: 4px; font-size: 10px; font-weight: 800; margin-right: 5px; }
.cc-log-plat.fb { background: #1e3a8a; color: #93c5fd; }
.cc-log-plat.tt { background: #134e4a; color: #5eead4; }

@media (max-width: 1150px) {
  .subagents-grid, .stats-grid, .kw-tiers-grid, .cc-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .commander-bottom-grid, .panel-grid-2, .vlm-catalog-grid, .modal-grid, .cc-main-split { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
  html, body { overflow-x: hidden; max-width: 100vw; }
  .app-layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .mobile-bottom-nav, .mobile-brand-row, .mobile-industry-strip, .kw-mobile-tabs { display: flex; }
  .topbar-actions { display: none; }
  .topbar { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 14px; }
  .search-wrapper { max-width: 100%; width: 100%; }
  .search-wrapper input { font-size: 15px; padding: 9px 34px 9px 36px; }
  .tab-panel { padding: 12px 12px 96px; }
  .card, .cc-panel { padding: 14px; border-radius: 14px; }
  .cc-kpi-grid { grid-template-columns: minmax(0, 1fr); }
  .cc-run-row { grid-template-columns: 1fr; gap: 4px; }
  .cc-col-res { text-align: left; }
  .commander-hero { padding: 16px; margin-bottom: 16px; border-radius: 14px; }
  .commander-title-group h1 { font-size: 17px; line-height: 1.35; }
  .commander-title-group p { font-size: 12.5px; }
  .commander-input-bar { flex-direction: column; gap: 8px; }
  .commander-input-bar input { width: 100%; font-size: 15px; padding: 11px 14px; }
  .commander-input-bar .btn-lg { width: 100%; padding: 11px 14px; font-size: 13.5px; }
  .preset-commands { flex-direction: column; gap: 6px; }
  .preset-btn { width: 100%; text-align: left; border-radius: 10px; padding: 8px 12px; white-space: normal; line-height: 1.35; }
  .kw-tiers-grid, .subagents-grid, .ads-grid, .form-row-2, .modal-spec-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .kw-tier-card.mob-hidden-tier { display: none; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
  .stat-card { padding: 12px 14px; border-radius: 12px; }
  .stat-label { font-size: 11.5px; }
  .stat-value { font-size: 19px !important; margin: 2px 0; }
  .stat-meta { font-size: 11px; line-height: 1.35; }
  .filter-bar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; padding: 12px; border-radius: 12px; }
  .filter-select { width: 100%; min-width: 0; max-width: 100%; font-size: 12.5px; padding: 8px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #filter-platform, #filter-industry, #filter-page, #filter-sort { grid-column: 1 / -1; }
  .filter-checkbox { justify-content: center; padding: 8px 10px; font-size: 12.5px; }
  .pagination-bar { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px; text-align: center; }
  .pagination-controls { justify-content: center; }
  .fb-ad-card { min-width: 0; max-width: 100%; }
  .fb-media-stage { min-height: 210px; max-height: 310px; }
  .fb-media-stage img { height: 240px; }
  .ad-footer { flex-wrap: wrap; gap: 8px; }
  .modal-backdrop { padding: 10px; align-items: flex-end; }
  .modal-content { padding: 16px; border-radius: 16px; max-height: 92vh; }
  .modal-thumb-grid { grid-template-columns: repeat(3, 1fr); }
}

