/* =========================================================
   AdPilot — UI theme (Bootstrap 5.3 extension)
   ========================================================= */
:root {
    --ap-primary: #4f46e5;
    --ap-primary-rgb: 79, 70, 229;
    --ap-sidebar: #111827;
    --ap-sidebar-w: 256px;
    --bs-primary: var(--ap-primary);
    --bs-primary-rgb: var(--ap-primary-rgb);
    --bs-link-color: var(--ap-primary);
    --bs-link-color-rgb: var(--ap-primary-rgb);
    --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --bs-border-radius: .6rem;
}
.btn-primary { --bs-btn-bg: var(--ap-primary); --bs-btn-border-color: var(--ap-primary); --bs-btn-hover-bg: #4338ca; --bs-btn-hover-border-color: #4338ca; --bs-btn-active-bg: #3730a3; }
.btn-outline-primary { --bs-btn-color: var(--ap-primary); --bs-btn-border-color: var(--ap-primary); --bs-btn-hover-bg: var(--ap-primary); --bs-btn-hover-border-color: var(--ap-primary); --bs-btn-active-bg: var(--ap-primary); --bs-btn-active-border-color: var(--ap-primary); }
.nav-pills { --bs-nav-pills-link-active-bg: var(--ap-primary); }
.pagination { --bs-pagination-active-bg: var(--ap-primary); --bs-pagination-active-border-color: var(--ap-primary); --bs-pagination-color: var(--ap-primary); }
.text-bg-primary { background-color: var(--ap-primary) !important; }
.progress-bar { background-color: var(--ap-primary); }
.form-check-input:checked { background-color: var(--ap-primary); border-color: var(--ap-primary); }
.min-w-0 { min-width: 0; }

body.app-body { background: #f4f6fb; }
[data-bs-theme="dark"] body.app-body { background: #0b1120; }
[data-bs-theme="dark"] .card { background: #111827; }

/* ---------- Layout ---------- */
.app-wrapper { display: flex; min-height: 100vh; }
.app-sidebar {
    width: var(--ap-sidebar-w); background: var(--ap-sidebar); color: #cbd5e1;
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 1040; display: flex; flex-direction: column;
    transition: transform .25s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.25rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .25rem .75rem 1rem; }
.sidebar-nav .nav-heading { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 1rem .75rem .35rem; }
.sidebar-nav .nav-link { display: flex; align-items: center; gap: .7rem; color: #cbd5e1; padding: .55rem .75rem; border-radius: .5rem; font-size: .9rem; }
.sidebar-nav .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav .nav-link.active { background: rgba(99,102,241,.22); color: #fff; box-shadow: inset 3px 0 0 #818cf8; }
.sidebar-plan { margin: .75rem; padding: 1rem; border-radius: .75rem; background: linear-gradient(135deg, #4f46e5, #7c3aed); }
.sidebar-backdrop { display: none; }

.app-main { flex: 1; margin-left: var(--ap-sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.app-topbar {
    position: sticky; top: 0; z-index: 1030; height: 64px; display: flex; align-items: center; gap: .75rem;
    padding: 0 1.5rem; background: rgba(255,255,255,.9); backdrop-filter: blur(8px); border-bottom: 1px solid #e5e7eb;
}
[data-bs-theme="dark"] .app-topbar { background: rgba(17,24,39,.9); border-color: #1f2937; }
.topbar-title { font-size: 1.1rem; font-weight: 600; margin: 0; }
.btn-icon { border: 0; background: transparent; padding: .35rem .5rem; border-radius: .5rem; }
.btn-icon:hover { background: rgba(0,0,0,.05); }
.app-content { padding: 1.5rem; flex: 1; }
.app-footer { display: flex; justify-content: space-between; padding: 1rem 1.5rem; font-size: .8rem; color: #6b7280; border-top: 1px solid #e5e7eb; }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.show { transform: none; }
    .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1035; }
    .app-main { margin-left: 0; }
    .app-content { padding: 1rem; }
}

/* ---------- Components ---------- */
.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: #e0e7ff; color: var(--ap-primary); font-weight: 700; font-size: .9rem; flex-shrink: 0; }
.avatar-sm { width: 30px; height: 30px; font-size: .8rem; }
.card { border-radius: .85rem; }
.card-header { padding: .9rem 1.25rem; border-bottom-color: rgba(0,0,0,.06); }
.kpi-icon { width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.25rem; flex-shrink: 0; }
.empty-icon { width: 76px; height: 76px; border-radius: 50%; margin: 0 auto; display: flex; align-items: center; justify-content: center; font-size: 2rem; background: #eef2ff; color: var(--ap-primary); }
.table > :not(caption) > * > * { padding: .7rem .9rem; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: #6b7280; font-weight: 600; white-space: nowrap; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; }

.onboarding { background: linear-gradient(135deg, #eef2ff, #faf5ff); }
.onboard-step { display: flex; align-items: center; gap: .6rem; padding: .85rem 1rem; border-radius: .7rem; background: #fff; text-decoration: none; color: inherit; border: 1px dashed #c7d2fe; font-weight: 500; }
.onboard-step i { font-size: 1.25rem; color: var(--ap-primary); }
.onboard-step.done { border-style: solid; border-color: #bbf7d0; color: #15803d; }
.onboard-step.done i { color: #16a34a; }

/* Wizard */
.wizard-steps { display: flex; gap: .5rem; overflow-x: auto; }
.wizard-step { flex: 1; min-width: 110px; display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: .6rem; border-radius: .7rem; background: #fff; color: #6b7280; cursor: pointer; border: 1px solid #e5e7eb; }
.wizard-step span { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: #f3f4f6; font-weight: 600; font-size: .85rem; }
.wizard-step.active { border-color: var(--ap-primary); color: var(--ap-primary); }
.wizard-step.active span, .wizard-step.done span { background: var(--ap-primary); color: #fff; }
.wizard-step.done { color: #111827; }
[data-bs-theme="dark"] .wizard-step { background: #111827; border-color: #374151; }

.objective-card { display: flex; flex-direction: column; gap: .2rem; padding: 1rem; border: 1.5px solid #e5e7eb; border-radius: .75rem; cursor: pointer; height: 100%; transition: all .15s; }
.objective-card i { font-size: 1.4rem; color: var(--ap-primary); }
.objective-card small { color: #6b7280; }
.btn-check:checked + .objective-card { border-color: var(--ap-primary); background: #eef2ff; box-shadow: 0 0 0 3px rgba(var(--ap-primary-rgb), .15); }
[data-bs-theme="dark"] .btn-check:checked + .objective-card { background: rgba(79,70,229,.15); }

.dropzone { border: 2px dashed #c7d2fe; border-radius: .8rem; padding: 1.5rem; text-align: center; color: #6b7280; background: #f8faff; cursor: pointer; transition: all .15s; }
.dropzone.drag { border-color: var(--ap-primary); background: #eef2ff; }
[data-bs-theme="dark"] .dropzone { background: transparent; }

/* Ad preview */
.fb-preview { border-radius: .8rem; overflow: hidden; }
.fb-preview .pv-img, .ad-img-ph { aspect-ratio: 1/1; background: #f3f4f6; display: flex; align-items: center; justify-content: center; font-size: 3rem; color: #cbd5e1; overflow: hidden; }
.fb-preview .pv-img img { width: 100%; height: 100%; object-fit: cover; }
.fb-preview.story { max-width: 300px; margin: auto; }
.fb-preview.story .pv-img { aspect-ratio: 9/16; }
.pv-text, .sp-text { white-space: pre-wrap; word-break: break-word; }
.ad-preview img { aspect-ratio: 1/1; object-fit: cover; }

/* Composer */
.acc-chip { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .7rem .3rem .3rem; border: 1.5px solid #e5e7eb; border-radius: 99px; cursor: pointer; position: relative; background: #fff; opacity: .65; }
.acc-chip img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.acc-chip .acc-net { position: absolute; left: 20px; bottom: -2px; font-size: .7rem; background: #fff; border-radius: 50%; line-height: 1; padding: 1px; }
.btn-check:checked + .acc-chip { border-color: var(--ap-primary); opacity: 1; box-shadow: 0 0 0 3px rgba(var(--ap-primary-rgb), .15); }
[data-bs-theme="dark"] .acc-chip { background: #111827; border-color: #374151; }
.composer-text { resize: vertical; font-size: .95rem; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .6rem; }
.media-item { position: relative; aspect-ratio: 1/1; border-radius: .6rem; overflow: hidden; background: #f3f4f6; cursor: pointer; }
.media-item img, .media-item video { width: 100%; height: 100%; object-fit: cover; }
.media-item .rm { position: absolute; top: 4px; right: 4px; border: 0; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,.65); color: #fff; font-size: .75rem; line-height: 1; }
.media-item .badge-vid { position: absolute; bottom: 4px; left: 4px; }
.media-item.uploading::after { content: ''; position: absolute; inset: 0; background: rgba(255,255,255,.7) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 50 50'%3E%3Ccircle cx='25' cy='25' r='20' fill='none' stroke='%234f46e5' stroke-width='5' stroke-dasharray='90 60'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 25 25' to='360 25 25' dur='0.8s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E") center no-repeat; }
.lib-item.selected { outline: 3px solid var(--ap-primary); }
.emoji-bar .emoji { font-size: 1.1rem; padding: .15rem .35rem; }
.char-pill { display: inline-flex; align-items: center; gap: .25rem; padding: .1rem .5rem; border-radius: 99px; background: #f3f4f6; margin-left: .3rem; }
.char-pill.over { background: #fee2e2; color: #b91c1c; }
.social-preview { border-radius: .8rem; overflow: hidden; }
.sp-media-grid { display: grid; gap: 2px; }
.sp-media-grid.n2 { grid-template-columns: 1fr 1fr; }
.sp-media-grid.n3, .sp-media-grid.n4 { grid-template-columns: 1fr 1fr; }
.sp-media-grid img, .sp-media-grid video { width: 100%; aspect-ratio: 1/1; object-fit: cover; display: block; }

/* Posts list */
.post-thumb { width: 72px; height: 72px; flex-shrink: 0; border-radius: .6rem; overflow: hidden; background: #f3f4f6; display: flex; align-items: center; justify-content: center; position: relative; color: #9ca3af; font-size: 1.5rem; }
.post-thumb img, .post-thumb video { width: 100%; height: 100%; object-fit: cover; }
.thumb-count { position: absolute; bottom: 3px; right: 3px; background: rgba(0,0,0,.65); color: #fff; font-size: .65rem; padding: 0 5px; border-radius: 99px; }
.thumb-badge { position: absolute; color: #fff; font-size: 1.4rem; }
.post-text { font-size: .92rem; white-space: pre-wrap; word-break: break-word; }
.target-pill { display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem; padding: .2rem .6rem; border-radius: 99px; border: 1px solid #e5e7eb; background: #fff; }
.target-pill.status-failed { border-color: #fecaca; background: #fef2f2; }
.target-pill.status-published { border-color: #bbf7d0; background: #f0fdf4; }
[data-bs-theme="dark"] .target-pill { background: transparent; border-color: #374151; }

/* Calendar */
.fc .fc-toolbar-title { font-size: 1.15rem; font-weight: 600; }
.fc .fc-button-primary { background: var(--ap-primary); border-color: var(--ap-primary); }
.fc .fc-button-primary:not(:disabled).fc-button-active { background: #3730a3; border-color: #3730a3; }
.fc-post { font-size: .75rem; line-height: 1.25; padding: 1px 3px; overflow: hidden; }
.fc-post-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-post-time { font-weight: 600; }
.fc-daygrid-event { cursor: pointer; }

/* Billing */
.plan-current { background: linear-gradient(135deg, #4f46e5, #7c3aed) !important; }
.pricing-card { position: relative; border-radius: 1rem; }
.pricing-card.featured { border-width: 2px !important; }
.pricing-card .price { font-size: 2rem; font-weight: 800; }
.pricing-card .price small { font-size: .9rem; font-weight: 500; color: #6b7280; }
.ribbon { position: absolute; top: -12px; right: 16px; background: var(--ap-primary); color: #fff; font-size: .72rem; font-weight: 600; padding: .25rem .7rem; border-radius: 99px; }
.connect-icon { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.35rem; }
.connect-icon i { color: #fff !important; }

/* Select2 tweaks */
.select2-container--bootstrap-5 .select2-selection { min-height: 38px; }

/* ---------- Auth ---------- */
.auth-body { background: radial-gradient(circle at 20% 20%, #e0e7ff, transparent 40%), radial-gradient(circle at 80% 80%, #f3e8ff, transparent 40%), #f8fafc; }
.auth-card { border-radius: 1.25rem; }
.auth-side { background: linear-gradient(160deg, #312e81, #4f46e5 55%, #7c3aed); padding: 3rem; align-items: center; }
.auth-points li { margin-bottom: .8rem; }
.auth-points i { color: #a5b4fc; margin-right: .5rem; }

/* ---------- Landing ---------- */
.landing { font-family: 'Inter', sans-serif; }
.hero { background: radial-gradient(circle at 85% 10%, #ede9fe, transparent 45%), radial-gradient(circle at 10% 90%, #e0f2fe, transparent 40%); }
.text-gradient { background: linear-gradient(90deg, #4f46e5, #a855f7); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-mock { border-radius: 1.25rem; transform: rotate(-1.5deg); }
.mock-kpi { background: #f8fafc; border-radius: .6rem; padding: .5rem; display: flex; flex-direction: column; }
.mock-kpi small { color: #6b7280; font-size: .7rem; }
.mock-bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; }
.mock-bars span { flex: 1; background: linear-gradient(180deg, #818cf8, #4f46e5); border-radius: 4px 4px 0 0; }
.feature-icon { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; background: #eef2ff; color: var(--ap-primary); font-size: 1.5rem; }
.feature-card { transition: transform .2s; }
.feature-card:hover { transform: translateY(-4px); }
.step-num { width: 54px; height: 54px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--ap-primary); color: #fff; font-size: 1.3rem; font-weight: 700; }
