/* ═══════════════════════════════════════════════════════════
   VIRALIX AD AUTOMATION HUB — SaaS Dashboard v3
   ═══════════════════════════════════════════════════════════ */

.hub-wrap {
    max-width: 1120px;
    margin: 0 auto;
    padding: 8px 0 64px;
    font-family: var(--font-family, 'Inter', sans-serif);
    color: var(--text-primary, #fafafa);
}

/* ── Page header ── */
.hub-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-primary, rgba(255, 255, 255, 0.08));
}

.hub-page-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--accent-secondary, #818cf8);
    margin-bottom: 8px;
}

.hub-page-eyebrow i {
    font-size: 0.6875rem;
}

.hub-page-header h1,
.hub-hero h1 {
    font-size: clamp(1.375rem, 2.5vw, 1.75rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    color: var(--text-primary, #fafafa);
    margin: 0 0 6px;
    line-height: 1.2;
}

.hub-page-desc,
.hub-hero-sub {
    font-size: 0.9375rem;
    color: var(--text-secondary, #a1a1aa);
    line-height: 1.5;
    max-width: 520px;
    margin: 0;
}

.hub-metrics,
.hub-stats {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.hub-metric-card,
.hub-stats > div {
    min-width: 120px;
    padding: 14px 18px;
    background: var(--bg-surface, #18181b);
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.08));
    border-radius: 10px;
    text-align: left;
}

.hub-stat-val,
.hub-metric-card .hub-stat-val {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text-primary, #fafafa);
    line-height: 1;
}

.hub-stat-lbl,
.hub-metric-card .hub-stat-lbl {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-tertiary, #71717a);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 4px;
}

.hub-hero {
    display: none;
}

.hub-hero-icon {
    display: none;
}

/* ── Segmented tabs ── */
.hub-tabs {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    margin-bottom: 24px;
    background: var(--bg-surface, #18181b);
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.08));
    border-radius: 10px;
}

.hub-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary, #a1a1aa);
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: 7px;
    cursor: pointer;
    transition: background 150ms, color 150ms;
    white-space: nowrap;
}

.hub-tab i {
    margin-right: 6px;
    font-size: 0.75rem;
}

.hub-tab.active {
    background: var(--bg-hover, #27272a);
    color: var(--text-primary, #fafafa);
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.4));
}

.hub-tab:hover:not(.active) {
    color: var(--text-primary, #fafafa);
}

/* ── Cards ── */
.hub-card {
    background: var(--bg-surface, #18181b);
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.08));
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 12px;
}

.hub-card.disabled-section {
    opacity: 0.45;
    pointer-events: none;
    filter: none;
}

.hub-card-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.hub-card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary, #fafafa);
}

.hub-card-title i {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-secondary, #818cf8);
    border-radius: 7px;
    font-size: 0.75rem;
}

.hub-step-tag {
    font-size: 0.625rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--bg-primary, #09090b);
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.08));
    color: var(--text-tertiary, #71717a);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

/* ── Meta connection ── */
.meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.meta-status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.meta-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.meta-dot.connected {
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.meta-dot.disconnected {
    background: var(--text-tertiary, #71717a);
}

.meta-status span {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary, #a1a1aa);
}

.hub-wrap .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 150ms, opacity 150ms;
}

.btn-meta {
    background: var(--accent-meta, #0866ff);
    color: #fff;
}

.btn-meta:hover {
    background: #0756d4;
    transform: none;
    box-shadow: none;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.08);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.15);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.12);
}

.btn-ghost {
    background: transparent;
    color: var(--accent-secondary, #818cf8);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.btn-ghost:hover {
    background: rgba(99, 102, 241, 0.08);
}

/* ── Selects ── */
.hub-select {
    width: 100%;
    padding: 9px 36px 9px 12px;
    background: var(--bg-primary, #09090b);
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.08));
    border-radius: 8px;
    color: var(--text-primary, #fafafa);
    font-size: 0.8125rem;
    font-family: inherit;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%2371717a' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
    transition: border-color 150ms, box-shadow 150ms;
}

.hub-select:focus {
    border-color: var(--accent-primary, #6366f1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.hub-select option {
    background: var(--bg-surface, #18181b);
}

/* ── Post grid ── */
.post-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.post-card {
    background: var(--bg-primary, #09090b);
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.08));
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 150ms, box-shadow 150ms;
    position: relative;
}

.post-card:hover {
    border-color: var(--border-secondary, rgba(255, 255, 255, 0.12));
    transform: none;
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.4));
}

.post-card.selected {
    border-color: var(--accent-primary, #6366f1);
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.25);
}

.post-card.recommended {
    border-color: var(--accent-primary, #6366f1);
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.2);
    transform: none;
}

.post-img-wrap {
    position: relative;
    height: 148px;
    background: var(--bg-hover, #27272a);
    overflow: hidden;
}

.post-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.post-type-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: var(--text-secondary, #a1a1aa);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.625rem;
    font-weight: 500;
}

.ai-score-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 0.625rem;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.55);
    color: var(--text-tertiary, #71717a);
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-score-badge.score-high {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.ai-score-badge.score-mid {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.ai-score-badge.score-low {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.ai-badge-top {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-primary, #6366f1);
    color: #fff;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.625rem;
    font-weight: 600;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 3;
}

.post-body {
    padding: 10px 12px 12px;
}

.post-caption {
    font-size: 0.75rem;
    color: var(--text-secondary, #a1a1aa);
    line-height: 1.4;
    margin: 0 0 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-meta {
    font-size: 0.625rem;
    color: var(--text-tertiary, #71717a);
}

.sel-dot {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent-primary, #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.55rem;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 150ms, transform 150ms;
}

.post-card.selected .sel-dot {
    opacity: 1;
    transform: scale(1);
}

.post-empty,
.post-loader {
    grid-column: 1 / -1;
    text-align: center;
    padding: 32px 16px;
    color: var(--text-tertiary, #71717a);
    font-size: 0.875rem;
}

.post-empty i,
.post-loader i {
    display: block;
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: rgba(99, 102, 241, 0.3);
}

.post-loader i {
    display: inline;
    margin-right: 6px;
    color: var(--accent-primary, #6366f1);
}

/* ── Launch section ── */
.sel-info {
    padding: 12px 14px;
    background: var(--bg-primary, #09090b);
    border: 1px dashed var(--border-primary, rgba(255, 255, 255, 0.08));
    border-radius: 8px;
    color: var(--text-tertiary, #71717a);
    font-size: 0.8125rem;
    margin-bottom: 16px;
}

.sel-info.has-selection {
    border-style: solid;
    border-color: rgba(34, 197, 94, 0.25);
    color: #4ade80;
    background: rgba(34, 197, 94, 0.04);
}

.target-explanation-box {
    background: rgba(99, 102, 241, 0.04);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-left: 3px solid var(--accent-primary, #6366f1);
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 0.8125rem;
    color: var(--text-secondary, #a1a1aa);
    display: none;
}

.target-explanation-box.visible {
    display: block;
}

.target-explanation-hdr {
    font-weight: 600;
    color: var(--text-primary, #fafafa);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
}

.launch-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.duration-selector-wrap {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.launch-field label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.6875rem;
    color: var(--text-tertiary, #71717a);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    margin-bottom: 6px;
}

.launch-field label span {
    font-size: 0.6875rem;
    color: var(--text-tertiary, #71717a);
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
}

.launch-input {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-primary, #09090b);
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.08));
    border-radius: 8px;
    color: var(--text-primary, #fafafa);
    font-size: 0.8125rem;
    font-family: inherit;
    outline: none;
    transition: border-color 150ms, box-shadow 150ms;
    resize: vertical;
}

.launch-input:focus {
    border-color: var(--accent-primary, #6366f1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.launch-input::placeholder {
    color: var(--text-tertiary, #71717a);
}

.launch-input:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-launch {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    background: var(--accent-primary, #6366f1);
    color: #fff;
    transition: background 150ms;
    box-shadow: none;
}

.btn-launch:hover:not(:disabled) {
    background: #5558e3;
    transform: none;
    box-shadow: none;
}

.btn-launch:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.launch-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.12);
    border-radius: 8px;
    font-size: 0.8125rem;
    color: var(--accent-secondary, #818cf8);
}

.launch-success {
    text-align: center;
    padding: 20px;
    background: rgba(34, 197, 94, 0.04);
    border: 1px solid rgba(34, 197, 94, 0.15);
    border-radius: 10px;
}

.launch-success i {
    font-size: 1.75rem;
    color: #22c55e;
}

.launch-success h3 {
    color: #4ade80;
    margin: 8px 0 4px;
    font-size: 0.9375rem;
    font-weight: 600;
}

.launch-success p {
    color: var(--text-secondary, #a1a1aa);
    font-size: 0.8125rem;
    margin: 0;
}

.launch-error {
    text-align: center;
    padding: 16px;
    background: rgba(239, 68, 68, 0.04);
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-radius: 10px;
    color: #f87171;
    font-size: 0.8125rem;
}

.launch-ids {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 8px;
    flex-wrap: wrap;
}

.launch-ids span {
    font-size: 0.625rem;
    color: var(--text-tertiary, #71717a);
    background: var(--bg-primary, #09090b);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.08));
}

/* ── History ── */
.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-primary, #09090b);
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.08));
    border-radius: 8px;
    margin-bottom: 6px;
    transition: border-color 150ms;
}

.history-item:hover {
    border-color: var(--border-secondary, rgba(255, 255, 255, 0.12));
    background: var(--bg-primary, #09090b);
}

.history-item-info h4 {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary, #fafafa);
    margin: 0 0 2px;
}

.history-date {
    font-size: 0.6875rem;
    color: var(--text-tertiary, #71717a);
}

.history-view-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: transparent;
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.08));
    color: var(--text-secondary, #a1a1aa);
    text-decoration: none;
    font-size: 0.6875rem;
    transition: background 150ms, color 150ms;
}

.history-view-btn:hover {
    background: var(--bg-hover, #27272a);
    color: var(--text-primary, #fafafa);
}

.history-empty,
.history-loader {
    text-align: center;
    padding: 24px;
    color: var(--text-tertiary, #71717a);
    font-size: 0.8125rem;
}

/* ── Health dashboard ── */
.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.health-card {
    background: var(--bg-primary, #09090b);
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.08));
    border-radius: 10px;
    padding: 16px;
}

.health-card-hdr {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.hc-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary, #fafafa);
    margin-bottom: 2px;
}

.hc-status {
    font-size: 0.6875rem;
    padding: 2px 7px;
    border-radius: 5px;
    background: var(--bg-hover, #27272a);
    color: var(--text-secondary, #a1a1aa);
    font-weight: 500;
}

.hc-status.active {
    background: rgba(34, 197, 94, 0.1);
    color: #4ade80;
}

.hc-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.hc-metric {
    background: var(--bg-surface, #18181b);
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.08));
    padding: 10px;
    border-radius: 8px;
    text-align: center;
}

.hc-metric span {
    display: block;
    font-size: 0.625rem;
    color: var(--text-tertiary, #71717a);
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.hc-metric strong {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary, #fafafa);
}

.advisory-box {
    background: rgba(99, 102, 241, 0.04);
    border: 1px solid rgba(99, 102, 241, 0.12);
    padding: 12px;
    border-radius: 8px;
    margin-top: 8px;
}

.advisory-box.stop-loss {
    background: rgba(239, 68, 68, 0.04);
    border-color: rgba(239, 68, 68, 0.12);
}

.advisory-box.scale {
    background: rgba(34, 197, 94, 0.04);
    border-color: rgba(34, 197, 94, 0.12);
}

.adv-title {
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.adv-text {
    font-size: 0.75rem;
    color: var(--text-secondary, #a1a1aa);
    line-height: 1.45;
    margin-bottom: 10px;
}

.adv-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.post-metrics-overlay {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(9, 9, 11, 0.75);
    padding: 3px 7px;
    border-radius: 5px;
    display: flex;
    gap: 8px;
    font-size: 0.625rem;
    color: #fff;
    z-index: 5;
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.08));
}

.post-metrics-overlay i {
    font-size: 0.6rem;
    color: var(--text-tertiary, #71717a);
}

.ai-tip {
    font-size: 0.6875rem;
    color: var(--accent-secondary, #818cf8);
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-primary, rgba(255, 255, 255, 0.08));
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 200ms, max-height 200ms;
    white-space: pre-wrap;
    line-height: 1.4;
}

.ai-tip.visible {
    opacity: 1;
    max-height: 200px;
}

.ai-analyzing {
    animation: hubPulse 1.5s infinite;
    color: var(--accent-secondary, #818cf8);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
}

@keyframes hubPulse {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
}

/* ── Toast ── */
.vx-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 500;
    z-index: 10000;
    opacity: 0;
    transition: opacity 200ms, transform 200ms;
    pointer-events: none;
    font-family: inherit;
    border: 1px solid transparent;
}

.vx-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.vx-toast-success {
    background: rgba(34, 197, 94, 0.1);
    color: #4ade80;
    border-color: rgba(34, 197, 94, 0.2);
}

.vx-toast-error {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.2);
}

.vx-toast-info {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-secondary, #818cf8);
    border-color: rgba(99, 102, 241, 0.2);
}

.hub-label {
    display: block;
    font-size: 0.6875rem;
    color: var(--text-tertiary, #71717a);
    margin-bottom: 6px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.hub-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .hub-page-header {
        flex-direction: column;
        gap: 16px;
    }

    .hub-metrics,
    .hub-stats {
        width: 100%;
    }

    .hub-metric-card,
    .hub-stats > div {
        flex: 1;
        min-width: 0;
    }

    .hub-tabs {
        display: flex;
        width: 100%;
        overflow-x: auto;
    }

    .hub-tab {
        flex: 1;
        text-align: center;
        padding: 8px 10px;
        font-size: 0.75rem;
    }

    .meta-row {
        flex-direction: column;
        align-items: stretch;
    }

    .meta-row .btn {
        width: 100%;
        justify-content: center;
    }

    .hub-form-grid {
        grid-template-columns: 1fr;
    }

    .post-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .post-img-wrap {
        height: 120px;
    }

    .launch-grid,
    .duration-selector-wrap {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .post-grid {
        grid-template-columns: 1fr;
    }

    .post-img-wrap {
        height: 160px;
    }

    .hub-tabs {
        flex-direction: column;
    }
}
