/* ============================================
   CAMPAIGN BRIEF MODAL — Overrides & Custom
   ============================================ */

/* Modal container — flex column để body chiếm đúng phần còn lại */
.modal.cb-modal {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: min(94vh, 980px);
}

/* Header — h2 đậm hơn chuẩn */
.modal-header .modal-header-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
    min-width: 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    color: var(--text, #0f172a);
    flex-shrink: 0;
}

/* Theme selector */
.cb-theme-selector {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.cb-theme-swatch {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease;
    flex-shrink: 0;
}

.cb-theme-swatch:hover { transform: scale(1.1); }

.cb-theme-swatch.active {
    border-color: var(--text, #0f172a);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

/* Body — flex-grow để chiếm phần còn lại sau header/footer, grid 2 cột */
.modal-body.cb-modal-body {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 460px 1fr;
    padding: 0;
    overflow: hidden;
}

/* Form column */
.cb-form-col {
    border-right: 1px solid var(--line, #e4e7ef);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Step tabs */
.cb-step-tabs-nav {
    display: flex;
    gap: 0;
    padding: 0;
    border-bottom: 1px solid var(--line, #e4e7ef);
    overflow-x: auto;
    background: var(--panel, #fff);
    flex-shrink: 0;
    scrollbar-width: none;
}

.cb-step-tabs-nav::-webkit-scrollbar { display: none; }

.cb-step-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    background: none;
    color: #6b7280;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
    text-align: center;
}

.cb-step-btn:hover:not(.active) {
    color: var(--text, #0f172a);
    background: rgba(0, 0, 0, 0.02);
}

.cb-step-btn.active {
    color: var(--primary, #0e6fba);
    border-bottom-color: var(--primary, #0e6fba);
}

/* Form scroll area */
.cb-form-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

/* Step panes — tab visibility */
.cb-step-pane {
    display: none;
    padding: 0;
}

.cb-step-pane.active {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr;
    padding: 16px 12px;
}

/* File input trong form */
.modal-form input[type="file"] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

/* Preview column */
.cb-preview-col {
    background: #f8fafc;
    overflow-y: auto;
    padding: 14px;
}

/* ============================================
   PREVIEW COMPONENTS (theme-able, reusable)
   ============================================ */

/* ── Theme: Sunrise ── */
.cb-doc[data-theme="sunrise"] {
    --cb-page: #fdf6f8;
    --cb-hdr-bg: #f9edf0;
    --cb-hdr-text: #6b1a2e;
    --cb-hdr-sub: #9b4a5e;
    --cb-hdr-border: #f0c8d2;
    --cb-accent: #c0404f;
    --cb-accent-dim: #f5dde2;
    --cb-accent-bdr: #e8b3bc;
    --cb-pill-bg: #fff8f9;
    --cb-pill-bdr: #f0ccd2;
    --cb-pill-key: #a03040;
    --cb-pill-val: #4a1020;
    --cb-card-bg: #ffffff;
    --cb-card-bdr: #f0dde0;
    --cb-body-bg: #fdf6f8;
    --cb-text: #3f1a24;
    --cb-bullet: #c0404f;
    --cb-meta-bg: #fff0f3;
    --cb-meta-key: #a03040;
    --cb-meta-val: #3f1a24;
    --cb-sec-icon: #f5dde2;
    --cb-img-bg: #f9eef1;
    --cb-img-bdr: #f0c8d2;
    --cb-hash-bg: #fff4f6;
    --cb-hash-bdr: #f0ccd2;
}

/* ── Theme: Mint ── */
.cb-doc[data-theme="mint"] {
    --cb-page: #f3faf7;
    --cb-hdr-bg: #e6f7f2;
    --cb-hdr-text: #0d4d38;
    --cb-hdr-sub: #1a6b50;
    --cb-hdr-border: #b4e6d4;
    --cb-accent: #0f7a5a;
    --cb-accent-dim: #d4f0e8;
    --cb-accent-bdr: #a8e6d0;
    --cb-pill-bg: #f0faf6;
    --cb-pill-bdr: #b4e6d4;
    --cb-pill-key: #0f7a5a;
    --cb-pill-val: #0d3d2c;
    --cb-card-bg: #ffffff;
    --cb-card-bdr: #cceedd;
    --cb-body-bg: #f3faf7;
    --cb-text: #0d3d2c;
    --cb-bullet: #0f7a5a;
    --cb-meta-bg: #e8f7f2;
    --cb-meta-key: #0f7a5a;
    --cb-meta-val: #0d3d2c;
    --cb-sec-icon: #d4f0e8;
    --cb-img-bg: #eaf7f3;
    --cb-img-bdr: #b4e6d4;
    --cb-hash-bg: #edf8f4;
    --cb-hash-bdr: #b4e6d4;
}

/* ── Theme: Lavender ── */
.cb-doc[data-theme="lavender"] {
    --cb-page: #f7f5ff;
    --cb-hdr-bg: #ede9ff;
    --cb-hdr-text: #2c1d6b;
    --cb-hdr-sub: #4a3890;
    --cb-hdr-border: #c8bcf5;
    --cb-accent: #5b42d6;
    --cb-accent-dim: #e6e1ff;
    --cb-accent-bdr: #c4b8f5;
    --cb-pill-bg: #f5f2ff;
    --cb-pill-bdr: #d0c8f5;
    --cb-pill-key: #5038c0;
    --cb-pill-val: #1e1450;
    --cb-card-bg: #ffffff;
    --cb-card-bdr: #ddd8f7;
    --cb-body-bg: #f7f5ff;
    --cb-text: #1e1450;
    --cb-bullet: #5b42d6;
    --cb-meta-bg: #edeaff;
    --cb-meta-key: #5038c0;
    --cb-meta-val: #1e1450;
    --cb-sec-icon: #e6e1ff;
    --cb-img-bg: #efecff;
    --cb-img-bdr: #d0c8f5;
    --cb-hash-bg: #f0eeff;
    --cb-hash-bdr: #d0c8f5;
}

/* ── Theme: Midnight ── */
.cb-doc[data-theme="midnight"] {
    --cb-page: #111827;
    --cb-hdr-bg: #0f1f3d;
    --cb-hdr-text: #e2eaf7;
    --cb-hdr-sub: #90aace;
    --cb-hdr-border: #1e3560;
    --cb-accent: #5b9bd5;
    --cb-accent-dim: #172a4a;
    --cb-accent-bdr: #1e3a62;
    --cb-pill-bg: #141e32;
    --cb-pill-bdr: #1e3060;
    --cb-pill-key: #6ba8e0;
    --cb-pill-val: #d0dcf0;
    --cb-card-bg: #141e32;
    --cb-card-bdr: #1e3060;
    --cb-body-bg: #111827;
    --cb-text: #d0dcf0;
    --cb-bullet: #5b9bd5;
    --cb-meta-bg: #0f1f3d;
    --cb-meta-key: #6ba8e0;
    --cb-meta-val: #d0dcf0;
    --cb-sec-icon: #172a4a;
    --cb-img-bg: #141e32;
    --cb-img-bdr: #1e3060;
    --cb-hash-bg: #141e32;
    --cb-hash-bdr: #1e3060;
}

/* ── Base preview doc ── */
.cb-doc {
    background: var(--cb-page);
    border: 1px solid var(--cb-card-bdr);
    border-radius: 10px;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.cb-header {
    padding: 14px 20px;
    background: var(--cb-hdr-bg);
    border-bottom: 1px solid var(--cb-hdr-border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cb-header-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.cb-logo {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--cb-accent-dim);
    border: 1px solid var(--cb-accent-bdr);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.cb-brand {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--cb-hdr-sub);
    font-weight: 700;
}

.cb-header-middle {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

.cb-header-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: center;
    padding: 10px 8px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--cb-hdr-border);
    border-radius: 8px;
    min-height: 52px;
    justify-content: center;
}

.cb-doc[data-theme="midnight"] .cb-header-item {
    background: rgba(255, 255, 255, 0.04);
}

.cb-header-item-title {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--cb-hdr-sub);
    font-weight: 700;
}

.cb-header-item-val {
    font-size: 13px;
    font-weight: 700;
    color: var(--cb-hdr-text);
    word-break: break-word;
    line-height: 1.3;
}

.cb-meta {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: var(--cb-meta-bg);
    border-bottom: 1px solid var(--cb-card-bdr);
}

.cb-meta-item {
    padding: 10px 12px;
    border-right: 1px solid var(--cb-card-bdr);
}

.cb-meta-item:last-child { border-right: none; }

.cb-meta-key {
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--cb-meta-key);
    font-weight: 700;
    margin-bottom: 3px;
}

.cb-meta-val {
    font-size: 12px;
    font-weight: 600;
    color: var(--cb-meta-val);
    word-break: break-word;
}

.cb-body {
    padding: 0;
    display: grid;
    gap: 0;
    background: var(--cb-body-bg);
}

.cb-section {
    background: var(--cb-card-bg);
    border: none;
    border-bottom: 1px solid var(--cb-card-bdr);
    border-radius: 0;
    overflow: hidden;
    margin: 0;
}

.cb-section-header {
    padding: 9px 12px;
    background: var(--cb-accent-dim);
    border-bottom: 1px solid var(--cb-accent-bdr);
    display: flex;
    align-items: center;
    gap: 7px;
}

.cb-section-icon {
    width: 20px;
    height: 20px;
    border-radius: 5px;
    background: var(--cb-sec-icon);
    border: 1px solid var(--cb-accent-bdr);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    flex-shrink: 0;
}

.cb-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 800;
    color: var(--cb-accent);
    margin: 0;
}

.cb-section-content {
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.cb-product-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 12px;
    padding: 12px;
    width: 100%;
    align-items: stretch;
    min-height: 280px;
}

.cb-product-left {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 100%;
    min-width: 0;
}

.cb-product-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: auto;
    gap: 20px;
    flex: 1;
    align-content: flex-start;
    align-items: stretch;
    width: 100%;
}

.cb-pill {
    background: var(--cb-pill-bg);
    border: 1px solid var(--cb-pill-bdr);
    border-radius: 8px;
    padding: 7px 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 38px;
    justify-content: flex-start;
    min-width: 0;
    overflow: hidden;
}

.cb-pill-key {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--cb-pill-key);
    font-weight: 700;
    overflow-wrap: break-word;
}

.cb-pill-val {
    font-size: 11.5px;
    color: var(--cb-pill-val);
    font-weight: 600;
    word-break: break-word;
    line-height: 1.35;
    overflow-wrap: break-word;
    min-width: 0;
}

.cb-pill-val a {
    color: #0066cc;
    text-decoration: underline;
    cursor: pointer;
    font-weight: 600;
    transition: color 0.15s ease;
    display: block;
    max-width: 100%;
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

.cb-pill-val a:hover { color: #0052a3; }

.cb-product-images {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
    justify-content: space-between;
    flex: 1;
}

.cb-product-left[data-sync-height] .cb-product-grid {
    height: 100%;
    grid-auto-rows: 1fr;
}

.cb-images-wrapper {
    width: 100%;
    aspect-ratio: 1 / 1;
    flex: 0 0 auto;
    border-radius: 8px;
    border: 1px solid var(--cb-img-bdr);
    background: var(--cb-img-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.cb-images-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cb-main-thumb {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    overflow: hidden;
}

.cb-main-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cb-main-thumb .cb-thumb-del {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
    width: 28px;
    height: 28px;
    font-size: 14px;
    line-height: 26px;
}

.cb-thumb {
    display: inline-flex;
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 6px;
    overflow: hidden;
    margin: 4px;
    border: 1px solid var(--cb-img-bdr);
}

.cb-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cb-thumb-del {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,0.5);
    color: #fff;
    border: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 12px;
    line-height: 18px;
    cursor: pointer;
}

.cb-images-label {
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--cb-accent);
    text-align: center;
    width: 100%;
}

.cb-hashtag-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px;
    background: var(--cb-card-bg);
    width: 100%;
}

.cb-hashtag-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--cb-hash-bg);
    border: 1px solid var(--cb-hash-bdr);
    border-radius: 8px;
    padding: 10px;
}

.cb-hashtag-label {
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--cb-accent);
}

.cb-hashtag-item .cb-section-body {
    padding: 0;
    background: none;
    border: none;
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--cb-text);
    white-space: pre-wrap;
    word-break: break-word;
}

.cb-section-body {
    padding: 12px;
    font-size: 12px;
    color: var(--cb-text);
    background: var(--cb-card-bg);
    white-space: pre-wrap;
    word-break: break-word;
}

.cb-section-product .cb-section-content { padding: 0; }

.cb-section > .cb-section-content { padding: 0; background: var(--cb-card-bg); }

.cb-list {
    margin: 0;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--cb-card-bg);
}

.cb-list li {
    padding: 7px 0 7px 24px;
    font-size: 12px;
    color: var(--cb-text);
    line-height: 1.5;
    list-style: none;
    position: relative;
    border-bottom: 1px solid var(--cb-card-bdr);
}

.cb-list li:last-child { border-bottom: none; }

.cb-list li::before {
    content: '•';
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 900;
    color: var(--cb-bullet);
    font-size: 15px;
    line-height: 1;
}

.cb-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border-bottom: 1px solid var(--cb-card-bdr);
}

.cb-two-col .cb-section { border-bottom: none; }

.cb-two-col .cb-section:first-child { border-right: 1px solid var(--cb-card-bdr); }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1100px) {
    .modal-body.cb-modal-body { grid-template-columns: 1fr; }
    .cb-preview-col { display: none; }
}

@media (max-width: 768px) {
    .modal.cb-modal {
        width: calc(100vw - 16px);
        height: calc(100vh - 16px);
    }
    .modal-body.cb-modal-body { grid-template-columns: 1fr; }
    .cb-form-col { border-right: none; }
}
