/* --- 基础样式 --- */
:root {
    --bg-color: #f0f2f5;
    --card-bg: #ffffff;
    --text-primary: #333;
    --text-secondary: #65676b;
    --btn-bg: #e4e6eb;
    --btn-hover: #d8dadf;
    --green-status: #31a24c;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    margin: 0;
    padding: 0;
}

/* --- 查询面板 --- */
.query-panel {
    background: var(--card-bg);
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.query-panel h2 {
    margin: 0 0 16px 0;
    font-size: 18px;
    color: var(--text-primary);
}

/* 标签页选项卡样式 */
.tag-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 2px solid #e4e6eb;
    padding-bottom: 8px;
}

.tag-tab {
    padding: 10px 20px;
    border: none;
    border-radius: 6px 6px 0 0;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.tag-tab:hover {
    background: var(--btn-bg);
    color: var(--text-primary);
}

.tag-tab.active {
    background: #1877f2;
    color: white;
    box-shadow: 0 2px 4px rgba(24, 119, 242, 0.3);
}

.tag-tab.active::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    right: 0;
    height: 2px;
    background: #1877f2;
}

.query-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    height: 23px;
}

.form-group input,
.form-group select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #1877f2;
}

/* label和日期预设按钮的容器 */
.label-with-presets {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.label-with-presets label {
    margin: 0;
    white-space: nowrap;
}

/* 日期预设按钮 */
.date-presets {
    display: flex;
    gap: 4px;
}

.date-preset-btn {
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.date-preset-btn:hover {
    background: #f0f2f5;
    border-color: #bbb;
}

.date-preset-btn.active {
    background: #1877f2;
    color: white;
    border-color: #1877f2;
    font-weight: 600;
}

.date-preset-btn.active:hover {
    background: #166fe5;
    border-color: #166fe5;
}

/* 加载状态 */
.loading-indicator {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    display: none;
}

.loading-indicator.active {
    display: block;
}

/* 主容器 */
.main-container {
    padding: 20px;
    max-width: 1600px;
    margin: 0 auto;
}

/* --- 网格布局 --- */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

/* --- 卡片样式 --- */
.card {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 650px;  /* 固定高度 */
    overflow: hidden;  /* 防止内容溢出 */
}

.card-content-wrapper {
    flex: 1;
    overflow-y: auto;  /* 内容区域可滚动 */
    overflow-x: hidden;
}

.card-header {
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;  /* 头部不缩小 */
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: bold;
    margin-bottom: 8px;
}

/* 投放中：绿色 */
.status-active {
    color: #16a34a; /* 推荐绿色 */
}

/* 已停止：红色 */
.status-inactive {
    color: #dc2626; /* 推荐红色 */
}

.status-dot {
    width: 14px;
    height: 14px;
    background: #fff;
    border: 2px solid var(--green-status);
    border-radius: 50%;
    position: relative;
}

.status-dot::after {
    content: "✓";
    position: absolute;
    font-size: 10px;
    color: var(--green-status);
    top: -2px;
    left: 2px;
    font-weight: bold;
}

/* ✅ 标记按钮组样式 */
.tag-buttons {
    display: flex;
    gap: 8px;
    margin: 8px 0;
}

.tag-btn {
    flex: 1;
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: var(--btn-bg);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.tag-btn:hover {
    background: var(--btn-hover);
    border-color: #bbb;
}

.tag-btn.active {
    background: #1877f2;
    color: white;
    border-color: #1877f2;
    font-weight: 600;
}

.tag-btn.active:hover {
    background: #166fe5;
    border-color: #166fe5;
}

/* 查看详情按钮 */
.btn-details {
    width: 100%;
    padding: 10px;
    background-color: var(--btn-bg);
    border: none;
    border-radius: 6px;
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s;
}

.btn-details:hover {
    background-color: var(--btn-hover);
}

/* 内容区域 */
.ad-content {
    margin-top: 8px;
}

.user-info {
    display: flex;
    align-items: center;

    justify-content: space-between; /* 左右贴紧 */

    width: 100%;
    max-width: 500px;   /* 可选：限制宽度 */
    margin: 0 auto 10px; /* 整体水平居中 */

    gap: 10px;
}


.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.username {
    font-weight: bold;
    font-size: 18px;
    color: #000000;
}

.ad-text {
    font-size: 14px;
    margin-bottom: 10px;
    line-height: 1.4;
}

/* 文案折叠样式 */
.ad-text-wrapper {
    position: relative;
}

.ad-text.collapsed {
    max-height: 100px;  /* 折叠时最大高度约4-5行 */
    overflow: hidden;
    position: relative;
}

.ad-text.collapsed::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(transparent, var(--card-bg));
}

.show-more-btn {
    background: none;
    border: none;
    color: #1877f2;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    padding: 4px 0;
    margin-top: 4px;
    display: block;
}

.show-more-btn:hover {
    text-decoration: underline;
}

/* --- 轮播图组件 - 参考Meta广告库结构 --- */
.carousel {
  position: relative;
  width: 100%;
  height: 300px;
  overflow: hidden;
  border-radius: 8px;
  background: #000;
}

/* 轮播容器：横向滚动容器 */
.carousel-track {
  display: flex;
  height: 100%;
  transition: transform 0.3s ease-in-out;
  /* 不设置width，让子元素自然排列 */
}

/* 每个轮播项：类似Meta的独立卡片 */
.carousel-item {
  /* 每个item固定占据容器的100%宽度 */
  flex: 0 0 100%;
  min-width: 100%;

  /* 容器内部布局：让图片居中 */
  display: flex;
  align-items: center;
  justify-content: center;

  height: 100%;
  padding: 0 16px;  /* 左右留白 */
  box-sizing: border-box;
  position: relative;
}

/* 图片本身的样式 */
.carousel-item img,
.carousel-item video {
  max-height: 100%;
  max-width: 100%;
  height: auto;
  width: auto;

  object-fit: contain;
  object-position: center;

  cursor: zoom-in;
  display: block;
}

/* 视频占位样式 */
.video-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 40px;
    pointer-events: none;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.8);
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.nav-btn.prev {
    left: 10px;
}

.nav-btn.next {
    right: 10px;
}

.nav-btn:hover {
    background: white;
}

/* --- 弹窗 (Modal) --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    border-radius: 8px;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.modal-header {
    padding: 16px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.modal-body {
    padding: 20px;
}

/* --- 灯箱 (Lightbox) --- */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
}

.lightbox.active {
    display: flex;
}

.lightbox img {
    height: 80vh;      /* 固定高度 = 屏幕高度的80% */
    width: auto;       /* 宽度自适应 */
    max-width: 95vw;   /* 防止横向溢出屏幕 */
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}


.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    cursor: pointer;
}

/* 底部链接样式 */
.footer-cta {
    background: #f0f2f5;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #666;
    border-radius: 0 0 8px 8px;
    margin-top: 10px;
}

.btn-learn-more {
    padding: 6px 12px;
    background: #e4e6eb;
    border-radius: 4px;
    text-decoration: none;
    color: #000;
    font-weight: bold;
}

.lightbox video{
  max-width: 90%;
  max-height: 90%;
  border-radius: 6px;
  box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

.ms { position: relative; width: 260px; }
.ms-btn{
  width: 100%;
  display:flex; justify-content:space-between; align-items:center;
  padding:10px 12px;
  border:1px solid #ddd; border-radius:10px;
  background:#fff; cursor:pointer;
}
.ms-panel{
  position:absolute; left:0; right:0; top: calc(100% + 8px);
  background:#fff; border:1px solid #ddd; border-radius:12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.08);
  padding:10px;
  display:none;
  z-index: 999;
}
.ms.open .ms-panel{ display:block; }

.ms-actions{ display:flex; gap:8px; margin-bottom:10px; }
.ms-action{
  padding:6px 10px; border:1px solid #eee; border-radius:10px;
  background:#fafafa; cursor:pointer;
}

.ms-list{ max-height: 260px; overflow:auto; display:flex; flex-direction:column; gap:6px; }
.ms-item{ display:flex; align-items:center; gap:8px; padding:6px 8px; border-radius:10px; }
.ms-item:hover{ background:#f6f7f9; }
.ms-item input{ transform: translateY(1px); }

/* --- 全屏Loading遮罩 --- */
.fullscreen-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.fullscreen-loading-overlay.active {
    opacity: 1;
}

.fullscreen-loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #1877f2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    color: white;
    font-size: 18px;
    font-weight: 500;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- 轮播图Loading --- */
.carousel-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 8px;
}

.carousel-loader .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* 媒体复制按钮 */
.copy-media-btn {
    position: absolute;
    top: 12px;
    right: 28px;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 5;
    opacity: 0;
}

.carousel-item:hover .copy-media-btn {
    opacity: 1;
}

.copy-media-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.05);
}

.copy-media-btn:active {
    transform: scale(0.95);
}

.copy-media-btn.copied {
    background: #10b981;
}

.copy-media-btn.copied:hover {
    background: #059669;
}

.copy-media-btn.copied {
    background: #10b981;
}