:root {
    --ap-primary: #4f46e5;
    --ap-sidebar: #111827;
    --ap-sidebar-text: #cbd5e1;
    --ap-bg: #f4f6fb;
    --bs-primary: #4f46e5;
    --bs-primary-rgb: 79, 70, 229;
    --bs-link-color: #4f46e5;
    --bs-link-hover-color: #3730a3;
}

body { background: var(--ap-bg); font-size: .925rem; }

.btn-primary { --bs-btn-bg: #4f46e5; --bs-btn-border-color: #4f46e5; --bs-btn-hover-bg: #4338ca; --bs-btn-hover-border-color: #4338ca; --bs-btn-active-bg: #3730a3; }
.btn-outline-primary { --bs-btn-color: #4f46e5; --bs-btn-border-color: #4f46e5; --bs-btn-hover-bg: #4f46e5; --bs-btn-hover-border-color: #4f46e5; }
.text-primary { color: #4f46e5 !important; }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: #a5b4fc; box-shadow: 0 0 0 .2rem rgba(79, 70, 229, .15); }
.form-check-input:checked { background-color: #4f46e5; border-color: #4f46e5; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 1.25rem; flex: 1; }
@media (min-width: 992px) { .content { padding: 1.75rem; } }

.sidebar { --bs-offcanvas-width: 260px; }
.sidebar-inner { background: var(--ap-sidebar); color: var(--ap-sidebar-text); height: 100%; display: flex; flex-direction: column; width: 100%; }
@media (min-width: 992px) {
    .sidebar { width: 250px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; }
}
.sidebar-brand { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.25rem; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-nav { padding: .75rem; gap: 2px; overflow-y: auto; }
.sidebar-nav .nav-link { color: var(--ap-sidebar-text); border-radius: .5rem; padding: .6rem .8rem; display: flex; align-items: center; gap: .7rem; }
.sidebar-nav .nav-link i { font-size: 1.05rem; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--ap-primary); color: #fff; }
.sidebar-footer { margin-top: auto; padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,.08); }

.brand-logo { width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(135deg, #4f46e5, #ec4899); color: #fff; font-size: 1.6rem; }
.brand-logo.sm { width: 34px; height: 34px; border-radius: 9px; font-size: 1rem; }

.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem; padding: .7rem 1.25rem; background: #fff; border-bottom: 1px solid #e5e7eb; }
.app-footer { padding: .75rem 1.25rem; border-top: 1px solid #e5e7eb; background: #fff; }

.fab { position: fixed; right: 18px; bottom: 18px; width: 54px; height: 54px; border-radius: 50%; background: var(--ap-primary); color: #fff; display: grid; place-items: center; font-size: 1.5rem; box-shadow: 0 6px 18px rgba(79,70,229,.45); z-index: 1030; }
.fab:hover { color: #fff; background: #4338ca; }

/* ---------- Cards / stats ---------- */
.card { border: 1px solid #e8eaf1; border-radius: .8rem; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; border-bottom: 1px solid #eef0f5; font-weight: 600; border-radius: .8rem .8rem 0 0 !important; }
.stat-card { display: flex; align-items: center; gap: .9rem; padding: 1rem 1.1rem; }
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; flex-shrink: 0; }
.stat-value { font-size: 1.45rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: #6b7280; font-size: .8rem; }

.table > :not(caption) > * > * { padding: .7rem .75rem; vertical-align: middle; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: #6b7280; font-weight: 600; background: #f9fafb; }

/* Target chips (platform status) */
.target-chips { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.target-chip { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; color: #fff; background: #9ca3af; }
.target-chip.is-success { background: #16a34a; }
.target-chip.is-failed { background: #dc2626; }
.target-chip.is-pending { background: #9ca3af; }

/* Platform account selector */
.account-option { position: relative; }
.account-option input { position: absolute; opacity: 0; }
.account-option label { display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem; border: 1.5px solid #e5e7eb; border-radius: .6rem; cursor: pointer; background: #fff; transition: .15s; }
.account-option label i.bi { font-size: 1.25rem; }
.account-option input:checked + label { border-color: var(--ap-primary); background: #eef2ff; }
.account-option input:focus-visible + label { outline: 2px solid #a5b4fc; }
.account-option input:disabled + label { opacity: .5; cursor: not-allowed; }

/* Publish mode radio cards */
.mode-option input { position: absolute; opacity: 0; }
.mode-option label { display: block; height: 100%; border: 1.5px solid #e5e7eb; border-radius: .6rem; padding: .7rem .8rem; cursor: pointer; background: #fff; }
.mode-option input:checked + label { border-color: var(--ap-primary); background: #eef2ff; }
.mode-option label strong { display: block; }

.img-preview { max-height: 180px; border-radius: .5rem; border: 1px solid #e5e7eb; }
.char-count.over { color: #dc2626; font-weight: 600; }

/* Calendar */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); border-left: 1px solid #e5e7eb; border-top: 1px solid #e5e7eb; }
.cal-head { font-size: .75rem; text-transform: uppercase; font-weight: 600; color: #6b7280; padding: .5rem; background: #f9fafb; border-right: 1px solid #e5e7eb; border-bottom: 1px solid #e5e7eb; text-align: center; }
.cal-day { min-height: 110px; border-right: 1px solid #e5e7eb; border-bottom: 1px solid #e5e7eb; padding: .35rem; background: #fff; }
.cal-day.muted { background: #fafafa; }
.cal-day.today { background: #eef2ff; }
.cal-day .num { font-size: .8rem; font-weight: 600; color: #374151; }
.cal-event { display: block; font-size: .72rem; padding: 2px 5px; margin-top: 3px; border-radius: 4px; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event.scheduled { background: #e0f2fe; color: #075985; }
.cal-event.published { background: #dcfce7; color: #166534; }
.cal-event.failed, .cal-event.partial { background: #fee2e2; color: #991b1b; }
.cal-event.draft, .cal-event.publishing { background: #f3f4f6; color: #374151; }
@media (max-width: 767.98px) {
    .cal-grid { display: block; border: 0; }
    .cal-head, .cal-day.empty, .cal-day.muted { display: none; }
    .cal-day { min-height: 0; border: 1px solid #e5e7eb; border-radius: .5rem; margin-bottom: .5rem; }
    .cal-day:not(.has-events):not(.today) { display: none; }
}

/* Auth */
.auth-page { min-height: 100vh; background: radial-gradient(circle at 20% 10%, #e0e7ff, transparent 40%), radial-gradient(circle at 90% 90%, #fce7f3, transparent 40%), #f4f6fb; }
.auth-card { max-width: 420px; width: 100%; }

.preview-box { white-space: pre-wrap; word-break: break-word; background: #f9fafb; border: 1px solid #eef0f5; border-radius: .5rem; padding: .75rem; font-size: .875rem; }
.min-w-0 { min-width: 0; }

@media (max-width: 575.98px) {
    .content { padding: .9rem; padding-bottom: 5rem; }
    .topbar { padding: .6rem .9rem; }
    .table-responsive-stack thead { display: none; }
    .table-responsive-stack tr { display: block; border-bottom: 1px solid #e5e7eb; padding: .5rem 0; }
    .table-responsive-stack td { display: flex; justify-content: space-between; gap: 1rem; border: 0 !important; padding: .3rem .75rem !important; }
    .table-responsive-stack td::before { content: attr(data-label); font-weight: 600; color: #6b7280; font-size: .8rem; flex-shrink: 0; }
    .table-responsive-stack td.td-main { display: block; }
    .table-responsive-stack td.td-main::before { display: none; }
}

/* Business switcher & sidebar sections */
.business-switch { position: relative; background: rgba(255,255,255,.07); color: #fff; border: 1px solid rgba(255,255,255,.12); border-radius: .6rem; padding: .45rem .7rem; }
.business-switch:hover, .business-switch:focus, .business-switch.show { background: rgba(255,255,255,.12); color: #fff; }
.business-switch.dropdown-toggle::after { position: absolute; right: .8rem; top: 50%; }
.sidebar-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: #94a3b8; padding: .9rem .8rem .3rem; }

/* Long menus scroll instead of wrapping into a second column */
.sidebar-nav { flex-wrap: nowrap; flex: 1 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.sidebar-nav .nav-link { flex-shrink: 0; }

/* Password fields: show / hide eye button (assets/js/password-toggle.js) */
.pw-field { position: relative; }
.pw-field > .form-control { padding-right: 2.6rem; }
.pw-field > .form-control.is-invalid { background-position: right 2.5rem center; }
.pw-eye { position: absolute; top: 50%; right: .35rem; transform: translateY(-50%); border: 0; background: transparent; color: #6b7280;
          width: 2rem; height: 2rem; border-radius: .375rem; display: grid; place-items: center; padding: 0; line-height: 1; }
.pw-eye:hover { color: #111827; background: rgba(0, 0, 0, .05); }
.pw-eye:focus-visible { outline: 2px solid #4f46e5; outline-offset: 1px; }
.pw-field > .form-control-lg ~ .pw-eye { font-size: 1.15rem; right: .5rem; }
