/**
 * Ads Page Styles
 * Uses CSS custom properties from app.css for theming consistency
 */

/* ============ Control Bar Overrides ============ */

#ads-section .control-bar {
    padding: 8px 35px;
    border-bottom: 1px solid rgba(55, 53, 47, 0.09);
    background: white;
}

#ads-section .search-box {
    position: relative;
    align-items: center;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px 36px 8px 12px;
    min-width: 200px;
    max-width: 360px;
    width: 260px;
    flex: 0 0 auto;
}

#ads-section .search-box input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
    padding: 0;
    width: 100%;
}

#ads-section .search-box input::placeholder {
    color: rgba(55, 53, 47, 0.4);
}

#ads-section .search-box:focus-within {
    border-color: #B9F040 !important;
    box-shadow: 0 0 0 3px rgba(185, 240, 64, 0.1) !important;
}

#ads-section .filter-button {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

#ads-section .filter-button:hover,
#ads-section .filter-button:focus,
#ads-section .filter-button:focus-visible {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Sort Button */
#ads-section .sort-button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid rgba(55, 53, 47, 0.16);
    border-radius: 6px;
    font-size: 14px;
    color: #37352f;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

#ads-section .sort-button:hover {
    background: rgba(55, 53, 47, 0.03);
    border-color: rgba(55, 53, 47, 0.3);
}

/* Sort Dropdown */
#ads-section .sort-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border: 1px solid rgba(55, 53, 47, 0.16);
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    z-index: 1000;
    min-width: 160px;
    display: none;
    overflow: hidden;
    margin-top: 4px;
}

#ads-section .sort-dropdown.active {
    display: block;
}

#ads-section .sort-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: none;
    font-size: 14px;
    color: #37352f;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease;
}

#ads-section .sort-option:hover {
    background: rgba(55, 53, 47, 0.06);
}

#ads-section .sort-check {
    color: #B9F040;
    font-weight: 600;
}

/* Filter Dropdown Group */
#ads-section .filter-dropdown-group {
    padding: 4px 0;
    border-bottom: 1px solid rgba(55, 53, 47, 0.09);
}

#ads-section .filter-dropdown-group:last-child {
    border-bottom: none;
}

#ads-section .filter-dropdown-group-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(55, 53, 47, 0.5);
    padding: 8px 14px 4px;
}

#ads-section .filter-dropdown-option {
    display: block;
    width: 100%;
    padding: 8px 14px;
    background: transparent;
    border: none;
    font-size: 14px;
    color: #37352f;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease;
}

#ads-section .filter-dropdown-option:hover {
    background: rgba(55, 53, 47, 0.06);
}

#ads-section .filter-dropdown-empty {
    padding: 16px;
    text-align: center;
    color: rgba(55, 53, 47, 0.5);
    font-size: 14px;
}

/* Active Filter Items */
#ads-section .filter-active-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(185, 240, 64, 0.15);
    border-radius: 4px;
    margin-bottom: 6px;
    font-size: 13px;
}

#ads-section .filter-active-item:last-child {
    margin-bottom: 0;
}

#ads-section .filter-active-field {
    color: rgba(55, 53, 47, 0.6);
    font-size: 12px;
}

#ads-section .filter-active-value {
    color: #37352f;
    flex: 1;
}

#ads-section .filter-active-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(55, 53, 47, 0.5);
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
    transition: color 0.15s ease;
}

#ads-section .filter-active-remove:hover {
    color: #dc2626;
}

/* Container */
.ads-container {
    padding: 24px;
    max-width: 2400px;
    margin: 0 auto;
    background: #f5f7fb;
    min-height: calc(100vh - 120px);
}

/* Header */
.ads-header {
    margin-bottom: 24px;
}

.ads-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 8px 0;
}

.ads-subtitle {
    font-size: 0.875rem;
    color: var(--muted);
    margin: 0;
}

/* Masonry Layout - uses Masonry.js for tight packing with horizontal reading order */
.ads-grid {
    position: relative;
}

/* Grid sizer element for Masonry to calculate column widths */
.ads-grid-sizer,
.ads-card {
    width: calc(50% - 12px); /* 2 columns with 24px gap */
}

/* Gutter sizer for Masonry */
.ads-gutter-sizer {
    width: 24px;
}

/* Responsive column widths */
@media (min-width: 1270px) {
    .ads-grid-sizer,
    .ads-card {
        width: calc(33.333% - 16px); /* 3 columns */
    }
}

@media (min-width: 1680px) {
    .ads-grid-sizer,
    .ads-card {
        width: calc(25% - 18px); /* 4 columns */
    }
}

@media (min-width: 2100px) {
    .ads-grid-sizer,
    .ads-card {
        width: calc(20% - 19.2px); /* 5 columns */
    }
}

@media (min-width: 2510px) {
    .ads-grid-sizer,
    .ads-card {
        width: calc(16.666% - 20px); /* 6 columns */
    }
}

/* Empty State */
.ads-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--muted);
}

.ads-empty__icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.ads-empty__title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 8px 0;
}

.ads-empty__text {
    font-size: 0.875rem;
    margin: 0;
}

/* Loading State */
.ads-loading {
    text-align: center;
    padding: 48px 24px;
    color: var(--muted);
}

/* Error State */
.ads-error {
    text-align: center;
    padding: 48px 24px;
    color: var(--muted);
}

.ads-error__text {
    margin-bottom: 16px;
}

.ads-error__retry {
    padding: 8px 16px;
    background: var(--brand-color);
    color: var(--text);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

.ads-error__retry:hover {
    opacity: 0.9;
}

/* Ad Card */
.ads-card {
    position: relative;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    margin-bottom: 24px; /* Vertical gap for Masonry */
}

.ads-card:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

/* During accordion animation, let Masonry reposition cards instantly (no transform transition fighting) */
.masonry-animating .ads-card {
    transition: box-shadow 0.2s ease !important;
}

/* Card Header */
/* Bulk select checkbox - top-left, beside status dropdown */
.ads-card__select {
    display: flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}
.ads-card__select-input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #1877f2;
}

.ads-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.ads-card__status {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 8px;
    border-radius: 4px;
}

/* Status Wrapper with Dropdown */
.ads-card__status-wrapper {
    position: relative;
}

.ads-card__status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    border: none;
    background: transparent;
    transition: opacity 0.15s ease;
}

.ads-card__status:hover {
    opacity: 0.85;
}

.ads-card__status-chevron {
    font-size: 8px;
    opacity: 0.7;
    transition: transform 0.15s ease;
}

.ads-card__status-wrapper.open .ads-card__status-chevron {
    transform: rotate(180deg);
}

/* Status Dropdown */
.ads-card__status-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    min-width: 120px;
    display: none;
    overflow: hidden;
}

.ads-card__status-wrapper.open .ads-card__status-dropdown {
    display: block;
}

.ads-card__status-option {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: transparent;
    text-align: left;
    font-size: 13px;
    color: #37352f;
    cursor: pointer;
    transition: background 0.15s ease;
}

.ads-card__status-option:hover {
    background: rgba(55, 53, 47, 0.06);
}

.ads-card__status-option.active {
    background: rgba(185, 240, 64, 0.15);
    font-weight: 500;
}

/* Status Colors */
.ads-card__status--draft {
    background: #fef3c7;
    color: #92400e;
}

.ads-card__status--queued {
    background: #e0e7ff;
    color: #3730a3;
}

.ads-card__status--testing {
    background: #fce7f3;
    color: #9d174d;
}

.ads-card__status--live {
    background: #d1fae5;
    color: #065f46;
}

.ads-card__status--retired {
    background: #f3f4f6;
    color: #6b7280;
}

.ads-card__status--published {
    background: #dbeafe;
    color: #1e40af;
}

/* Legacy status colors for backwards compatibility */
.ads-card__status--ready {
    background: #d1fae5;
    color: #065f46;
}

.ads-card__status--exported {
    background: #dbeafe;
    color: #1e40af;
}

/* Header left group (status + angle) */
.ads-card__header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

/* Angle Pill */
.ads-card__angle-wrapper {
    position: relative;
}

.ads-card__angle-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    border: none;
    background: rgba(99, 71, 169, 0.1);
    color: #6347a9;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.15s ease;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ads-card__angle-pill:hover {
    background: rgba(99, 71, 169, 0.18);
}

.ads-card__angle-pill--empty {
    background: transparent;
    color: var(--muted);
    border: 1px dashed var(--border);
    font-weight: 500;
}

.ads-card__angle-pill--empty:hover {
    background: rgba(99, 71, 169, 0.06);
    border-color: rgba(99, 71, 169, 0.3);
    color: #6347a9;
}

/* Funnel Step Pill */
.ads-card__funnel-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ads-card__funnel-pill--tofu {
    background: rgba(59, 130, 246, 0.1);
    color: #2563eb;
}

.ads-card__funnel-pill--mofu {
    background: rgba(139, 92, 246, 0.1);
    color: #7c3aed;
}

.ads-card__funnel-pill--bofu {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

/* Angle Dropdown (appended to body) */
.ads-card__angle-dropdown {
    background: white;
    border: 1px solid oklch(0.88 0 0);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.05);
    max-height: 300px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ads-card__angle-search-container {
    padding: 8px;
    border-bottom: 1px solid oklch(0.92 0 0);
    background: white;
}

.ads-card__angle-search {
    width: 100%;
    border: 1px solid oklch(0.88 0 0);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 14px;
    font-family: 'Lato', sans-serif;
    outline: none;
    transition: all 0.15s ease;
    box-sizing: border-box;
}

.ads-card__angle-search:focus {
    border-color: #b9f040;
    box-shadow: 0 0 0 3px rgba(185, 240, 64, 0.15);
}

.ads-card__angle-options {
    overflow-y: auto;
    max-height: 250px;
}

.ads-card__angle-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.15s ease;
    font-size: 14px;
}

.ads-card__angle-option:hover {
    background: oklch(0.98 0 0);
}

.ads-card__angle-option.selected {
    background: rgba(185, 240, 64, 0.1);
}

.ads-card__angle-option.selected:hover {
    background: rgba(185, 240, 64, 0.15);
}

.ads-card__angle-option-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ads-card__angle-option-check {
    color: #65a30d;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.ads-card__angle-option--create {
    color: #6347a9;
    font-weight: 500;
    border-top: 1px solid oklch(0.92 0 0);
    background: rgba(99, 71, 169, 0.03);
}

.ads-card__angle-option--create:hover {
    background: rgba(99, 71, 169, 0.08);
}

.ads-card__angle-option-create-icon {
    font-size: 18px;
    font-weight: bold;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ads-card__angle-empty {
    padding: 20px;
    text-align: center;
    color: oklch(0.6 0 0);
    font-size: 14px;
}

.ads-card__delete {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: background 0.2s ease, color 0.2s ease;
}

.ads-card__delete:hover {
    background: #fee2e2;
    color: #dc2626;
}

/* Ad Mockup Container */
.ads-card__mockup {
    padding: 0 16px 16px 16px;
}

/* Accordions Container */
.ads-card__accordions {
    border-top: 1px solid var(--border);
    padding-bottom: 8px;
}

/* Individual Accordion */
.ads-accordion {
    border-bottom: 1px solid var(--border);
}

.ads-accordion:last-child {
    border-bottom: none;
}

/* Accordion Trigger Button */
.ads-accordion__trigger {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    transition: background 0.15s ease;
}

.ads-accordion__trigger:hover {
    background: #edf0f5;
}

.ads-accordion__trigger:focus {
    outline: none;
    background: #edf0f5;
}

.ads-accordion__trigger:focus-visible {
    box-shadow: inset 0 0 0 2px var(--brand-color);
}

.ads-accordion__title {
    text-align: left;
}

/* Chevron Icon */
.ads-accordion__chevron {
    flex-shrink: 0;
    color: var(--muted);
    transition: transform 0.2s ease;
}

.ads-accordion.expanded .ads-accordion__chevron {
    transform: rotate(180deg);
}

/* Accordion Content */
.ads-accordion__content {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.25s ease;
}

.ads-accordion.expanded .ads-accordion__content {
    grid-template-rows: 1fr;
}

.ads-accordion__body {
    overflow: hidden;
}

.ads-accordion__body > * {
    padding: 0 16px 16px 16px;
}

.ads-accordion.expanded .ads-accordion__body > * {
    padding-top: 12px;
}

/* Accordion Text */
.ads-accordion__text {
    font-size: 0.875rem;
    color: var(--text);
    line-height: 1.6;
    margin: 0;
}

/* Legacy detail value class (for VoC empty state) */
.ads-card__detail-value {
    font-size: 0.875rem;
    color: var(--text);
    line-height: 1.5;
    margin: 0;
}

/* VoC Evidence List */
.ads-card__voc-list {
    list-style: none;
    padding: 0 16px 16px 16px;
    margin: 0;
}

.ads-card__voc-item {
    font-style: italic;
    padding: 10px 12px;
    background: #f8fafc;
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 0.875rem;
    color: var(--text);
    line-height: 1.5;
    border-left: 3px solid var(--brand-color);
}

.ads-card__voc-item:last-child {
    margin-bottom: 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .ads-grid-sizer,
    .ads-card {
        width: 100%; /* Single column on mobile */
    }
    
    .ads-container {
        padding: 16px;
    }
}

/* ============ Video Player Overlay ============ */

.pe-fb-ad__video-wrapper {
    position: relative;
    width: 100%;
    cursor: pointer;
    background: #000;
    pointer-events: auto;
}

.pe-fb-ad__video-wrapper video {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}

/* Large center play button (shown when paused) */
.pe-fb-ad__video-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.2s;
}

.pe-fb-ad__video-wrapper.is-playing .pe-fb-ad__video-play-btn {
    opacity: 0;
}

/* Bottom controls bar */
.pe-fb-ad__video-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    opacity: 0;
    transition: opacity 0.2s;
}

.pe-fb-ad__video-wrapper:hover .pe-fb-ad__video-controls,
.pe-fb-ad__video-wrapper.is-playing .pe-fb-ad__video-controls {
    opacity: 1;
}

.pe-fb-ad__video-ctrl-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.9;
}

.pe-fb-ad__video-ctrl-btn:hover {
    opacity: 1;
}

/* Progress bar */
.pe-fb-ad__video-progress {
    flex: 1;
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}

.pe-fb-ad__video-progress:hover {
    height: 6px;
}

.pe-fb-ad__video-progress-fill {
    height: 100%;
    background: #fff;
    border-radius: 2px;
    width: 0%;
    pointer-events: none;
}

/* Time label */
.pe-fb-ad__video-time {
    font-size: 11px;
    color: rgba(255,255,255,0.9);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 28px;
}

/* Ensure pointer events work on current ad cards */
.ads-card--current .pe-fb-ad__video-wrapper,
.ads-card--current .pe-fb-ad__video-controls,
.ads-card--current .pe-fb-ad__video-ctrl-btn,
.ads-card--current .pe-fb-ad__video-progress {
    pointer-events: auto;
}

/* ============ Source Toggle (Test Ads / Current Ads) ============ */

.ads-source-toggle {
    display: flex;
    gap: 2px;
    background: rgba(55, 53, 47, 0.06);
    border-radius: 6px;
    padding: 2px;
    margin-left: auto;
}

.ads-source-toggle__btn {
    padding: 5px 14px;
    border: none;
    background: transparent;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    color: rgba(55, 53, 47, 0.5);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.ads-source-toggle__btn:hover {
    color: rgba(55, 53, 47, 0.8);
}

.ads-source-toggle__btn.active {
    background: white;
    color: #37352f;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    cursor: default;
}

/* ============ Current Ad Card ============ */

.ads-card--current .pe-fb-ad__text-field {
    pointer-events: none;
}

.ads-card--current .pe-fb-ad__media,
.ads-card--current .ads-card__accordions {
    pointer-events: auto;
}

.ads-card--current .ads-accordion__trigger {
    background: #f8fafb;
    color: #37352f;
}

.ads-card--current .ads-accordion__trigger:hover {
    background: #edf0f5;
}

.ads-card__current-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 10px 4px;
}

/* Labels rendered inline inside the current-ad header — no extra padding,
   header already provides spacing. */
.ads-card__current-labels--inline {
    padding: 0;
    flex: 1;
    min-width: 0;
    align-items: center;
}

/* Lighter header for the read-only "Current Ads" card — no border so the
   card stays visually quiet, mirroring the original padding-only layout. */
.ads-card__header--current {
    padding: 8px 12px;
    border-bottom: none;
    background: transparent;
    min-height: 32px;
}

.ads-card__current-label {
    font-size: 11px;
    font-weight: 500;
    color: rgba(55, 53, 47, 0.5);
    background: rgba(55, 53, 47, 0.06);
    padding: 2px 8px;
    border-radius: 3px;
}

/* ============ Import Summary Bar ============ */

.import-summary {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.import-summary__scores {
    display: flex;
    gap: 24px;
    align-items: center;
}

.import-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.import-score__label {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.import-score__value {
    font-size: 1.25rem;
    font-weight: 800;
}

.import-score--high { color: #166534; }
.import-score--mid  { color: #a16207; }
.import-score--low  { color: #b91c1c; }


/* ============ Ad Critique Accordion ============ */

.critique-grade {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 800;
    margin-left: 8px;
    vertical-align: middle;
}

.critique-grade--a { background: #dcfce7; color: #166534; }
.critique-grade--b { background: #ecfccb; color: #3f6212; }
.critique-grade--c { background: #fef9c3; color: #854d0e; }
.critique-grade--d { background: #fee2e2; color: #991b1b; }
.critique-grade--f { background: #fecaca; color: #7f1d1d; }

.critique-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.critique-verdict {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    line-height: 1.4;
}

.critique-weakness {
    font-size: 0.8125rem;
    color: #b91c1c;
    margin: 0;
    line-height: 1.4;
}

.critique-dimension {
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.critique-dimension:last-of-type {
    border-bottom: none;
}

.critique-dimension__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.critique-dimension__label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text);
}

.critique-dimension__score {
    font-size: 0.75rem;
    font-weight: 800;
}

.critique-score--high { color: #166534; }
.critique-score--mid  { color: #a16207; }
.critique-score--low  { color: #b91c1c; }

.critique-dimension__text {
    font-size: 0.75rem;
    color: var(--muted);
    margin: 2px 0 0;
    line-height: 1.4;
}

.critique-tag {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 1px 7px;
    border-radius: 4px;
    background: rgba(55, 53, 47, 0.06);
    color: var(--text);
}

.critique-longevity {
    font-size: 0.75rem;
    color: var(--muted);
    margin: 0;
    line-height: 1.4;
    font-style: italic;
}


/* ============ Inline Ad Critique (vzd- classes, matches Chrome extension) ============ */

.vzd-analysis {
    margin: 0;
    padding: 14px 16px;
    background: #fff;
    border-left: 3px solid #B9F040;
    border-top: 1px solid #e4e6eb;
    font-family: 'Lato', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 13px;
    color: #1c1e21;
    line-height: 1.4;
    box-sizing: border-box;
    width: 100%;
}

.vzd-analysis * {
    box-sizing: border-box;
}

.vzd-grade-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 6px;
    flex-wrap: nowrap;
}

.vzd-grade {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 900;
    flex-shrink: 0;
}

.vzd-grade-A, .vzd-grade-A\+, .vzd-grade-A- { background: #dcfce7; color: #166534; }
.vzd-grade-B, .vzd-grade-B\+, .vzd-grade-B- { background: #ecfccb; color: #3f6212; }
.vzd-grade-C, .vzd-grade-C\+, .vzd-grade-C- { background: #fef9c3; color: #854d0e; }
.vzd-grade-D, .vzd-grade-D\+, .vzd-grade-D- { background: #fee2e2; color: #991b1b; }
.vzd-grade-F { background: #fecaca; color: #7f1d1d; }

.vzd-verdict {
    font-size: 13px;
    font-weight: 700;
    color: #1c1e21;
    line-height: 1.3;
}

.vzd-weakness {
    font-size: 12px;
    color: #b91c1c;
    margin-bottom: 6px;
    line-height: 1.3;
    padding-left: 38px;
}

.vzd-dimension {
    padding: 5px 0;
    border-bottom: 1px solid #f0f2f5;
    overflow: hidden;
}

.vzd-dimension:last-of-type { border-bottom: none; }

.vzd-score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    gap: 8px;
}

.vzd-score-label {
    color: #1c1e21;
    font-weight: 700;
    font-size: 11px;
}

.vzd-score-val { font-weight: 800; font-size: 12px; }
.vzd-score-high { color: #166534; }
.vzd-score-mid  { color: #a16207; }
.vzd-score-low  { color: #b91c1c; }

.vzd-tag {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.vzd-latency-low    { background: #dcfce7; color: #166534; }
.vzd-latency-medium { background: #fef9c3; color: #854d0e; }
.vzd-latency-high   { background: #fee2e2; color: #991b1b; }
.vzd-funnel-tof, .vzd-funnel-TOF { background: #dbeafe; color: #1e40af; }
.vzd-funnel-mof, .vzd-funnel-MOF { background: #ede9fe; color: #5b21b6; }
.vzd-funnel-bof, .vzd-funnel-BOF { background: #dcfce7; color: #166534; }

.vzd-score-reason {
    font-size: 11px;
    color: #4b4f56;
    line-height: 1.4;
    margin-top: 1px;
}

.vzd-longevity {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #f0f2f5;
    font-size: 11px;
    color: #8a8d91;
    font-style: italic;
    line-height: 1.3;
}


/* ============ View Toggle ============ */

.ads-view-toggle {
    display: flex;
    align-items: center;
    gap: 2px;
    background: rgba(55, 53, 47, 0.06);
    border-radius: 6px;
    padding: 2px;
    margin-left: auto;
}

.ads-view-toggle__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: white;
    border-radius: 4px;
    color: #37352f;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ads-view-toggle__btn:hover {
    color: rgba(55, 53, 47, 0.8);
}

.ads-view-toggle__btn.active {
    background: transparent;
    color: rgba(55, 53, 47, 0.3);
    box-shadow: none;
    cursor: default;
}

/* ============ Kanban Layout ============ */

.ads-kanban {
    display: flex;
    justify-content: center;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 16px;
    min-height: calc(100vh - 180px);
}

.ads-kanban__column {
    flex: 0 0 280px;
    min-width: 280px;
    background: rgba(55, 53, 47, 0.03);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 180px);
}

.ads-kanban__column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(55, 53, 47, 0.09);
    background: white;
    border-radius: 8px 8px 0 0;
}

.ads-kanban__column-title {
    font-size: 14px;
    font-weight: 600;
    color: #37352f;
}

.ads-kanban__column-count {
    font-size: 12px;
    font-weight: 500;
    color: rgba(55, 53, 47, 0.5);
    background: rgba(55, 53, 47, 0.08);
    padding: 2px 8px;
    border-radius: 10px;
}

.ads-kanban__column-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    min-height: 100px;
}

.ads-kanban__column-body.drag-over {
    background: rgba(185, 240, 64, 0.1);
}

.ads-kanban__empty {
    text-align: center;
    padding: 24px 16px;
    color: rgba(55, 53, 47, 0.4);
    font-size: 13px;
    border: 2px dashed rgba(55, 53, 47, 0.15);
    border-radius: 6px;
}

/* Kanban Card */
.ads-kanban__card {
    background: white;
    border: 1px solid rgba(55, 53, 47, 0.12);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: grab;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
    position: relative;
}

.ads-kanban__card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.ads-kanban__card.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.ads-kanban__card:active {
    cursor: grabbing;
}

.ads-kanban__card-headline {
    font-size: 14px;
    font-weight: 600;
    color: #37352f;
    margin-bottom: 4px;
    line-height: 1.3;
}

.ads-kanban__card-type {
    display: inline-block;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: rgba(55, 53, 47, 0.6);
    background: rgba(55, 53, 47, 0.06);
    padding: 2px 6px;
    border-radius: 3px;
    margin-bottom: 6px;
}

.ads-kanban__card-preview {
    font-size: 12px;
    color: rgba(55, 53, 47, 0.7);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ads-kanban__card-select {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    cursor: pointer;
}
.ads-kanban__card-select-input {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #1877f2;
}

.ads-kanban__card-drag-handle {
    position: absolute;
    top: 8px;
    right: 8px;
    color: rgba(55, 53, 47, 0.25);
    font-size: 12px;
    letter-spacing: -2px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.ads-kanban__card:hover .ads-kanban__card-drag-handle {
    opacity: 1;
}

/* Kanban responsive */
@media (max-width: 768px) {
    .ads-kanban__column {
        flex: 0 0 260px;
        min-width: 260px;
    }
}

/* Kanban Hover Preview */
.ads-kanban__preview {
    position: fixed;
    z-index: 9999;
    width: 380px;
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    pointer-events: none;
}

.ads-kanban__preview.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Override image placeholder in preview - hide "Click to add" text */
.ads-kanban__preview .pe-fb-ad__media:not(.has-image) {
    cursor: default;
}

.ads-kanban__preview .pe-fb-ad__media-placeholder {
    display: none;
}

/* Reduce image area height in preview when no image */
.ads-kanban__preview .pe-fb-ad__media:not(.has-image) {
    aspect-ratio: 2.5/1;
}

/* Make the preview FB ad fit nicely */
.ads-kanban__preview .pe-fb-ad {
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}

/* Image Media Styles */
.pe-fb-ad__media {
    transition: opacity 0.2s ease;
}

.pe-fb-ad__media:hover {
    opacity: 0.9;
}

.pe-fb-ad__media.has-image {
    cursor: pointer;
}

.pe-fb-ad__media:not(.has-image) {
    cursor: pointer;
    position: relative;
}

.pe-fb-ad__media:not(.has-image):hover {
    background: linear-gradient(to top right,transparent calc(50% - 1px),#6b7280 calc(50% - 1px),#6b7280 calc(50% + 1px),transparent calc(50% + 1px)),linear-gradient(to top left,transparent calc(50% - 1px),#6b7280 calc(50% - 1px),#6b7280 calc(50% + 1px),transparent calc(50% + 1px)),#d1d5db !important;
}

.pe-fb-ad__media-placeholder {
    transition: color 0.2s ease;
}

.pe-fb-ad__media:not(.has-image):hover .pe-fb-ad__media-placeholder {
    color: #37352f;
}

/* Ads Tab Specific: Make image container height flexible based on image aspect ratio */
.ads-card__mockup .pe-fb-ad__media.has-image {
    aspect-ratio: unset;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f7fb;
}

.ads-card__mockup .pe-fb-ad__media.has-image img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    max-width: 100%;
}

/* Media Delete Button */
.pe-fb-ad__media-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: none;
    background: rgba(0, 0, 0, 0.6);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease;
    z-index: 5;
}

.pe-fb-ad__media:hover .pe-fb-ad__media-delete {
    opacity: 1;
}

.pe-fb-ad__media-delete:hover {
    background: rgba(220, 38, 38, 0.9);
}

.pe-fb-ad__media-delete img {
    filter: brightness(0) invert(1);
}

/* ============ Find & Replace ============ */

/* Find & Replace Button */
/* Bulk publish button - Meta blue */
.ads-bulk-publish-button {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    background: #1877f2;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}
.ads-bulk-publish-button:hover {
    background: #166fe5;
}
.ads-bulk-publish-button img {
    filter: brightness(0) invert(1);
}

.ads-find-replace-button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid rgba(55, 53, 47, 0.16);
    border-radius: 6px;
    font-size: 14px;
    color: #37352f;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
    white-space: nowrap;
}

.ads-find-replace-button:hover {
    background: rgba(55, 53, 47, 0.03);
    border-color: rgba(55, 53, 47, 0.3);
}

.ads-find-replace-button svg {
    flex-shrink: 0;
}

/* Find & Replace Dialog */
.ads-find-replace-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border: 1px solid rgba(55, 53, 47, 0.16);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    min-width: 500px;
    max-width: 700px;
    max-height: 80vh;
    z-index: 2001;
    display: none;
    flex-direction: column;
}

.ads-find-replace-dialog.active {
    display: flex;
}

.ads-find-replace-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(55, 53, 47, 0.09);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.ads-find-replace-title {
    font-size: 16px;
    font-weight: 600;
    color: rgba(55, 53, 47, 0.9);
}

.ads-find-replace-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 24px;
    color: rgba(55, 53, 47, 0.6);
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.15s ease;
}

.ads-find-replace-close:hover {
    background: rgba(55, 53, 47, 0.06);
    color: rgba(55, 53, 47, 0.9);
}

.ads-find-replace-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.ads-find-replace-section {
    margin-bottom: 20px;
}

.ads-find-replace-section:last-child {
    margin-bottom: 0;
}

.ads-find-replace-section-title {
    font-size: 13px;
    font-weight: 600;
    color: rgba(55, 53, 47, 0.7);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ads-find-replace-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.ads-find-replace-field-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 14px;
    color: rgba(55, 53, 47, 0.8);
    user-select: none;
}

.ads-find-replace-field-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #B9F040;
}

.ads-find-replace-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: rgba(55, 53, 47, 0.8);
    margin-bottom: 8px;
}

.ads-find-replace-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(55, 53, 47, 0.16);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    color: #37352f;
    background: white;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ads-find-replace-input:focus {
    outline: none;
    border-color: #B9F040;
    box-shadow: 0 0 0 3px rgba(185, 240, 64, 0.1);
}

.ads-find-replace-preview-header {
    margin-bottom: 12px;
}

.ads-find-replace-match-count {
    font-size: 14px;
    font-weight: 500;
    color: rgba(55, 53, 47, 0.8);
}

.ads-find-replace-preview-content {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid rgba(55, 53, 47, 0.09);
    border-radius: 6px;
    padding: 12px;
    background: #f8f9fa;
}

.ads-find-replace-preview-item {
    padding: 8px;
    margin-bottom: 8px;
    background: white;
    border-radius: 4px;
    border-left: 3px solid #B9F040;
    font-size: 13px;
    line-height: 1.5;
}

.ads-find-replace-preview-item:last-child {
    margin-bottom: 0;
}

.ads-find-replace-preview-field {
    font-weight: 600;
    color: rgba(55, 53, 47, 0.7);
    margin-bottom: 4px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.ads-find-replace-preview-text {
    color: #37352f;
}

.ads-find-replace-preview-text .highlight {
    background: rgba(185, 240, 64, 0.4);
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 500;
}

.ads-find-replace-error {
    padding: 12px;
    background: #fee2e2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    color: #991b1b;
    font-size: 14px;
    margin-top: 12px;
}

.ads-find-replace-actions {
    padding: 16px 20px;
    border-top: 1px solid rgba(55, 53, 47, 0.09);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

.ads-find-replace-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: opacity 0.2s ease, background 0.2s ease;
}

.ads-find-replace-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ads-find-replace-btn-secondary {
    background: rgba(55, 53, 47, 0.08);
    color: #37352f;
}

.ads-find-replace-btn-secondary:hover:not(:disabled) {
    background: rgba(55, 53, 47, 0.12);
}

.ads-find-replace-btn-primary {
    background: #B9F040;
    color: #37352f;
}

.ads-find-replace-btn-primary:hover:not(:disabled) {
    background: #A5D837;
}

/* ============ Ad Edit Mode ============ */

/* Edit Icon */
.pe-fb-ad__edit-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    padding: 4px;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    z-index: 10;
}

.pe-fb-ad__edit-icon:hover {
    background: white;
}

.pe-fb-ad__edit-icon img {
    width: 16px;
    height: 16px;
    display: block;
}

.pe-fb-ad__edit-icon:focus {
    outline: 2px solid #B9F040;
    outline-offset: 2px;
}

/* Hide edit icon when in edit mode */
.pe-fb-ad.is-editing .pe-fb-ad__edit-icon {
    display: none;
}

/* Edit Controls (Save/Cancel buttons) */
.pe-fb-ad__edit-controls {
    display: none;
    padding: 20px 12px;
    border-top: 1px solid #e4e6eb;
    background: #f8fafb;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
}

.pe-fb-ad.is-editing .pe-fb-ad__edit-controls {
    display: flex;
}

.pe-fb-ad__edit-cancel,
.pe-fb-ad__edit-save {
    padding: 6px 12px !important;
    border-radius: 4px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: opacity 0.2s ease, background 0.2s ease;
    font-family: inherit;
    margin: 0 !important;
}

.pe-fb-ad__edit-cancel {
    border: 1px solid rgba(55, 53, 47, 0.16) !important;
    background: white !important;
    color: #37352f !important;
}

.pe-fb-ad__edit-cancel:hover {
    background: rgba(55, 53, 47, 0.06);
}

.pe-fb-ad__edit-save {
    border: none !important;
    background: #B9F040 !important;
    color: #37352f !important;
    margin-right: 8px !important;
}

.pe-fb-ad__edit-save:hover {
    background: #A5D837;
}

.pe-fb-ad__edit-save:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Edit Mode - Editable Elements */
.pe-fb-ad.is-editing .pe-fb-ad__primary-text,
.pe-fb-ad.is-editing .pe-fb-ad__headline,
.pe-fb-ad.is-editing .pe-fb-ad__description {
    outline: 2px solid #B9F040;
    outline-offset: 2px;
    background: rgba(185, 240, 64, 0.05);
    border-radius: 4px;
    padding: 4px !important;
    min-height: 1.2em;
}

.pe-fb-ad.is-editing .pe-fb-ad__primary-text[contenteditable="true"]:focus,
.pe-fb-ad.is-editing .pe-fb-ad__headline[contenteditable="true"]:focus,
.pe-fb-ad.is-editing .pe-fb-ad__description[contenteditable="true"]:focus {
    outline: 2px solid #A5D837;
    background: rgba(185, 240, 64, 0.1);
}

/* Ensure primary text wrapper is editable */
.pe-fb-ad.is-editing .pe-fb-ad__primary-text-wrapper {
    padding: 8px 12px !important;
}

.pe-fb-ad.is-editing .pe-fb-ad__primary-text {
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ============ Card Header Actions ============ */

.ads-card__actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ads-card__iterate,
.ads-card__publish,
.ads-card__delete {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s ease, color 0.2s ease;
}

.ads-card__iterate img,
.ads-card__publish img {
    width: 18px;
    height: 18px;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.ads-card__iterate:hover,
.ads-card__publish:hover,
.ads-card__delete:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--muted);
}

.ads-card__iterate:hover img,
.ads-card__publish:hover img {
    opacity: 0.85;
}

/* ============ Meta Publish Modal ============ */

.meta-publish-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.meta-publish-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.meta-publish-modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    transition: transform 0.2s ease;
}

.meta-publish-modal-overlay.active .meta-publish-modal {
    transform: translateY(0);
}

.meta-publish-modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border, #e2e8f0);
}

.meta-publish-modal__title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text, #1a202c);
    margin: 0;
}

.meta-publish-modal__close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    color: var(--muted, #718096);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s ease, color 0.2s ease;
}

.meta-publish-modal__close:hover {
    background: var(--bg, #f5f7fb);
    color: var(--text, #1a202c);
}

.meta-publish-modal__content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Loading State */
.meta-publish-modal__loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 16px;
}

.meta-publish-modal__spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border, #e2e8f0);
    border-top-color: #1877F2;
    border-radius: 50%;
    animation: meta-spin 0.8s linear infinite;
}

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

/* Error State */
.meta-publish-modal__error {
    text-align: center;
    padding: 20px;
}

.meta-publish-modal__error-text {
    color: #dc2626;
    margin-bottom: 16px;
}

/* Connect State */
.meta-publish-modal__connect {
    text-align: center;
    padding: 20px;
}

.meta-publish-modal__connect-icon {
    margin-bottom: 16px;
}

.meta-publish-modal__connect-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text, #1a202c);
    margin: 0 0 8px 0;
}

.meta-publish-modal__connect-text {
    color: var(--muted, #718096);
    margin: 0 0 24px 0;
    line-height: 1.5;
}

/* Buttons */
.meta-publish-modal__btn {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease, opacity 0.2s ease;
    border: none;
}

.meta-publish-modal__btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.meta-publish-modal__btn--primary {
    background: #1877F2;
    color: white;
}

.meta-publish-modal__btn--primary:hover:not(:disabled) {
    background: #166fe5;
}

.meta-publish-modal__btn--secondary {
    background: var(--bg, #f5f7fb);
    color: var(--text, #1a202c);
    border: 1px solid var(--border, #e2e8f0);
}

.meta-publish-modal__btn--secondary:hover:not(:disabled) {
    background: var(--border, #e2e8f0);
}

.meta-publish-modal__btn--small {
    padding: 6px 12px;
    font-size: 13px;
}

/* Form Styles */
.meta-publish-modal__form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.meta-publish-modal__connected-as {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: rgba(24, 119, 242, 0.05);
    border-radius: 8px;
    margin-bottom: 8px;
}

.meta-publish-modal__connected-label {
    color: var(--muted, #718096);
    font-size: 13px;
}

.meta-publish-modal__connected-name {
    color: #1877F2;
    font-weight: 500;
    font-size: 14px;
}

.meta-publish-modal__disconnect {
    margin-left: auto;
    font-size: 12px;
    color: var(--muted, #718096);
    text-decoration: none;
}

.meta-publish-modal__disconnect:hover {
    color: #dc2626;
    text-decoration: underline;
}

.meta-publish-modal__section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.meta-publish-modal__label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text, #1a202c);
}

.meta-publish-modal__select,
.meta-publish-modal__input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 6px;
    font-size: 14px;
    color: var(--text, #1a202c);
    background: white;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.meta-publish-modal__select:focus,
.meta-publish-modal__input:focus {
    outline: none;
    border-color: #1877F2;
    box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.1);
}

.meta-publish-modal__select:disabled {
    background: var(--bg, #f5f7fb);
    cursor: not-allowed;
    opacity: 0.7;
}

.meta-publish-modal__hint {
    font-size: 12px;
    color: var(--muted, #718096);
    margin: 4px 0 0 0;
}

/* Create Form (for new campaign/adset) */
.meta-publish-modal__create-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
    padding: 14px;
    background: var(--bg, #f5f7fb);
    border-radius: 8px;
    border: 1px solid var(--border, #e2e8f0);
}

.meta-publish-modal__create-actions {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    padding-top: 10px;
    border-top: 1px solid var(--border, #e2e8f0);
}

/* Ad Status Toggle */
.meta-publish-modal__status-toggle {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 12px;
    margin-top: 4px;
    border-top: 1px solid var(--border, #e2e8f0);
}

.meta-publish-modal__toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.meta-publish-modal__toggle-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted, #718096);
}

.meta-publish-modal__toggle-label--paused {
    color: var(--text, #1a202c);
}

.meta-publish-modal__toggle-label--live {
    color: var(--muted, #718096);
}

.meta-publish-modal__switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.meta-publish-modal__switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.meta-publish-modal__switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border, #cbd5e0);
    border-radius: 22px;
    transition: background-color 0.2s;
}

.meta-publish-modal__switch-slider::before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.meta-publish-modal__switch input:checked + .meta-publish-modal__switch-slider {
    background-color: #48bb78;
}

.meta-publish-modal__switch input:checked + .meta-publish-modal__switch-slider::before {
    transform: translateX(18px);
}

/* Actions Footer */
.meta-publish-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 16px;
    margin-top: 8px;
    border-top: 1px solid var(--border, #e2e8f0);
}

/* Field Groups (for advanced options in create forms) */
.meta-publish-modal__field-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 4px;
}

.meta-publish-modal__field-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted, #718096);
    display: flex;
    align-items: center;
    gap: 8px;
}

.meta-publish-modal__locked-badge {
    font-size: 9px;
    font-weight: 500;
    color: #9a7b4f;
    background: transparent;
    padding: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

.meta-publish-modal__select--nested {
    padding: 8px 10px;
    font-size: 13px;
    background: white;
}

.meta-publish-modal__field-hint {
    font-size: 11px;
    color: var(--muted, #718096);
    margin: 0;
    line-height: 1.4;
    font-style: italic;
    opacity: 0.85;
}

/* Create form refinements */
.meta-publish-modal__create-form .meta-publish-modal__input:first-child {
    margin-bottom: 4px;
}

/* Publish success state */
.meta-publish-modal__success {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    animation: publishSuccessFadeIn 0.4s ease-out;
}

.meta-publish-modal__success-circle {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: #e6f4ea;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    animation: publishSuccessScale 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.meta-publish-modal__success-check {
    width: 36px;
    height: 36px;
    stroke: #1e8e3e;
    stroke-width: 3;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.meta-publish-modal__success-check path {
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: publishCheckDraw 0.4s ease-out 0.3s forwards;
}

.meta-publish-modal__success-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text, #1a202c);
    margin: 0 0 8px;
}

.meta-publish-modal__success-text {
    font-size: 14px;
    color: var(--muted, #718096);
    margin: 0 0 4px;
    line-height: 1.5;
}
.meta-publish-modal__success-text--muted {
    font-size: 13px;
    color: var(--muted, #718096);
}

.meta-publish-modal__success-id {
    font-size: 12px;
    color: var(--muted, #718096);
    opacity: 0.7;
    margin: 0 0 28px;
    font-family: monospace;
}

.meta-publish-modal__success-btn {
    margin-top: 4px;
}

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

@keyframes publishSuccessScale {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

@keyframes publishCheckDraw {
    to { stroke-dashoffset: 0; }
}

/* ─── Section titles ──────────────────────────────────────────────── */

.ads-card__section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #a0aec0;
    padding: 6px 16px 0;
}

.ads-card__section-title--ad {
    padding-bottom: 4px;
}

/* ─── Lead ad gating ──────────────────────────────────────────────── */

/* The gated wrapper sits inside the primary text wrapper.
   The card keeps its natural height — the overlay covers everything
   below the first ~3 lines with a gradient fade to white + CTA. */
.pe-fb-ad__primary-text-wrapper--gated {
    position: relative;
}

.pe-fb-ad__gate-overlay {
    position: absolute;
    top: 3.2em;  /* start fading after ~2-3 lines of visible text */
    left: 0;
    right: 0;
    bottom: 0;
    min-height: 80px;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.85) 30%,
        #fff 55%
    );
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    z-index: 2;
}

.pe-fb-ad__gate-cta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
}

.pe-fb-ad__gate-cta-btn {
    background: #B9F040;
    color: #1a1a1a;
    font-weight: 700;
    font-size: 14px;
    padding: 10px 28px;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid #a8d835;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    white-space: nowrap;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.pe-fb-ad__gate-cta-btn:hover {
    background: #c5f55a;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.pe-fb-ad__gate-cta-sub {
    display: block;
    font-size: 12px;
    color: #65676b;
    text-align: center;
}

/* Hide media, link details, footer, edit icon when gated */
.pe-fb-ad--lead-gated .pe-fb-ad__media,
.pe-fb-ad--lead-gated .pe-fb-ad__link-details,
.pe-fb-ad--lead-gated .pe-fb-ad__footer,
.pe-fb-ad--lead-gated .pe-fb-ad__edit-controls,
.pe-fb-ad--lead-gated .pe-fb-ad__edit-icon {
    display: none !important;
}

/* Toggle inline ad-critique scores on/off (Current Ads view) */
#ads-section.ads-section--hide-scores .pe-fb-ad__inline-critique {
    display: none !important;
}
