/* ==========================================================
   Social Report – sweet & simple theme on top of Bootstrap 5
   ========================================================== */
:root {
    --brand: #7c5cff;
    --brand-soft: color-mix(in srgb, var(--brand) 12%, white);
    --ink: #1f1d2b;
    --muted: #6b6880;
    --bg: #f7f5fc;
    --card: #ffffff;
    --line: #ece9f5;
    --fb: #1877f2;
    --ig: #d6249f;
    --up: #14a06b;
    --down: #e0475b;
}

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    color: var(--ink);
    background:
        radial-gradient(900px 500px at 0% -10%, color-mix(in srgb, var(--brand) 14%, transparent), transparent 60%),
        radial-gradient(700px 400px at 100% 0%, #ffe3ef, transparent 60%),
        var(--bg);
    background-attachment: fixed;
    min-height: 100vh;
}

.text-muted { color: var(--muted) !important; }
.text-fb { color: var(--fb); }
.text-ig { color: var(--ig); }
.ls-1 { letter-spacing: .06em; }
.min-w-0 { min-width: 0; }
.shadow-soft { box-shadow: 0 10px 30px -12px rgba(60, 40, 120, .18), 0 2px 6px rgba(60, 40, 120, .05) !important; }
.rounded-5 { border-radius: 1.75rem !important; }

/* ---------- Buttons ---------- */
.btn { font-weight: 600; border-radius: .9rem; }
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover, .btn-brand:focus { background: color-mix(in srgb, var(--brand) 85%, black); border-color: transparent; color: #fff; }
.btn-brand:disabled { background: var(--brand); opacity: .45; color: #fff; }
.btn-fb { background: var(--fb); color: #fff; }
.btn-fb:hover { background: #0f63d1; color: #fff; }
.btn-light { background: #fff; border-color: var(--line); }

.form-control, .form-select { border-radius: .9rem; border-color: var(--line); }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .25rem color-mix(in srgb, var(--brand) 18%, transparent); }

/* ---------- Nav ---------- */
.app-nav { background: rgba(255, 255, 255, .7); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.app-nav .nav-link { font-weight: 500; color: var(--muted); border-radius: .7rem; padding: .45rem .8rem !important; }
.app-nav .nav-link.active, .app-nav .nav-link:hover { color: var(--brand); background: var(--brand-soft); }
.brand-dot { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: linear-gradient(135deg, var(--brand), #ff7eb6); color: #fff; }
.brand-dot-lg { width: 60px; height: 60px; font-size: 1.6rem; border-radius: 18px; }
.brand-logo { height: 34px; width: auto; }
.brand-logo-lg { height: 60px; width: auto; }

/* ---------- Auth ---------- */
.auth-page main { display: grid; place-items: center; min-height: 100vh; }
.auth-card { width: 100%; max-width: 440px; border-radius: 1.75rem; }

/* ---------- Home / picker ---------- */
.hero { max-width: 640px; }
.client-picker { position: relative; }
.client-picker .form-control { padding-left: 1rem; }
.client-picker.has-selection .form-control { padding-left: 3.4rem; font-weight: 600; }
.client-picker .picked-avatar { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); }
.client-list {
    display: none; position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px);
    background: #fff; border: 1px solid var(--line); border-radius: 1rem; max-height: 320px; overflow-y: auto; padding: .35rem;
}
.client-list.open { display: block; }
.client-option { display: flex; align-items: center; gap: .75rem; padding: .55rem .65rem; border-radius: .75rem; cursor: pointer; }
.client-option:hover, .client-option.active { background: var(--brand-soft); }
.client-option .handles { font-size: .8rem; color: var(--muted); }
.client-option .handles i { margin-right: .2rem; }
.client-empty { padding: 1rem; text-align: center; color: var(--muted); font-size: .9rem; }

.recent-card { transition: transform .15s ease; }
.recent-card:hover { transform: translateY(-2px); }

/* ---------- Avatars ---------- */
.avatar { border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--line); }
.avatar-sm { width: 30px; height: 30px; font-size: .75rem; }
.avatar-md { width: 44px; height: 44px; font-size: .95rem; }
.avatar-xl { width: 88px; height: 88px; font-size: 1.9rem; border: 4px solid rgba(255, 255, 255, .7); }
.avatar-initials { display: inline-grid; place-items: center; font-weight: 700; color: hsl(var(--hue), 55%, 35%); background: hsl(var(--hue), 80%, 90%); }

/* ---------- Loading ---------- */
.loading-overlay { position: fixed; inset: 0; z-index: 2000; display: none; place-items: center; background: rgba(247, 245, 252, .92); backdrop-filter: blur(4px); }
.loading-overlay.show { display: grid; }
.loader { width: 64px; height: 64px; margin: 0 auto; border-radius: 50%; border: 6px solid var(--brand-soft); border-top-color: var(--brand); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Settings ---------- */
.status-pill { display: inline-flex; align-items: center; padding: .4rem .8rem; border-radius: 999px; font-size: .875rem; font-weight: 600; }
.status-ok { background: #e3f7ee; color: #0f7a51; }
.status-bad { background: #fde8eb; color: #b3283b; }
.status-off { background: #f0eef6; color: var(--muted); }
.token-box summary { cursor: pointer; }
.client-table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: #fbfaff; }

/* ==========================================================
   Report
   ========================================================== */
.report-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; max-width: 1100px; margin: 0 auto 1.25rem; }
.report { max-width: 1100px; margin: 0 auto; }

.report-cover {
    position: relative; overflow: hidden; color: #fff; border-radius: 1.75rem; padding: 2rem;
    background: linear-gradient(135deg, var(--brand) 0%, color-mix(in srgb, var(--brand) 55%, #ff7eb6) 100%);
    margin-bottom: 1.5rem;
}
.report-cover::after { content: ''; position: absolute; right: -80px; bottom: -120px; width: 320px; height: 320px; border-radius: 50%; background: rgba(255, 255, 255, .12); }
.report-cover .brand-dot { background: rgba(255, 255, 255, .22); }
.cover-tag { font-size: .8rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; background: rgba(255, 255, 255, .2); padding: .35rem .8rem; border-radius: 999px; }
.report-title { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 800; letter-spacing: -.02em; }
.cover-month { font-size: 1.15rem; font-weight: 600; opacity: .95; }
.cover-handles { display: flex; flex-wrap: wrap; gap: .5rem; }
.cover-handles span { background: rgba(255, 255, 255, .18); padding: .25rem .7rem; border-radius: 999px; font-size: .875rem; }
.cover-handles i { margin-right: .35rem; }

.report-section { background: var(--card); border-radius: 1.5rem; padding: 1.5rem; margin-bottom: 1.5rem; box-shadow: 0 10px 30px -12px rgba(60, 40, 120, .14); }
@media (min-width: 768px) { .report-section, .report-cover { padding: 2.25rem; } }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.section-head h2 { font-size: 1.3rem; font-weight: 800; margin: 0; display: flex; align-items: center; gap: .6rem; }
.section-head h2 i { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; font-size: 1.1rem; background: var(--brand-soft); color: var(--brand); }
.platform-ig .section-head h2 i { background: linear-gradient(135deg, #feda75, #d62976 50%, #4f5bd5); color: #fff; }
.platform-fb .section-head h2 i { background: var(--fb); color: #fff; }

.kpi { background: #fbfaff; border: 1px solid var(--line); border-radius: 1.1rem; padding: 1rem 1.1rem; position: relative; }
.kpi-icon { position: absolute; top: .9rem; right: 1rem; color: color-mix(in srgb, var(--brand) 55%, white); font-size: 1.1rem; }
.platform-ig .kpi-icon { color: #e58bc4; }
.platform-fb .kpi-icon { color: #7fb0f5; }
.kpi-label { font-size: .8rem; font-weight: 600; color: var(--muted); }
.kpi-value { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; margin: .15rem 0 .3rem; }
.delta { display: inline-flex; align-items: center; gap: .15rem; font-size: .75rem; font-weight: 700; padding: .12rem .45rem; border-radius: 999px; }
.delta-up { background: #e3f7ee; color: var(--up); }
.delta-down { background: #fde8eb; color: var(--down); }

.highlights { background: linear-gradient(135deg, #fff7e6, #fff0f6); border-radius: 1.1rem; padding: 1rem 1.25rem; }
.highlights ul { padding-left: 1.2rem; }
.highlights li { margin-bottom: .2rem; }

.panel { border: 1px solid var(--line); border-radius: 1.1rem; padding: 1.1rem; }
.panel-title { font-weight: 700; margin-bottom: .9rem; }
.chart-wrap { position: relative; height: 260px; }

.post-card { display: block; height: 100%; border: 1px solid var(--line); border-radius: 1rem; overflow: hidden; text-decoration: none; color: inherit; background: #fff; transition: transform .15s ease; }
a.post-card:hover { transform: translateY(-2px); color: inherit; }
.post-thumb { position: relative; aspect-ratio: 1 / 1; background: linear-gradient(135deg, #f3f0ff, #ffeef6); display: grid; place-items: center; color: #b9b2d8; font-size: 2rem; }
.post-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.post-rank { position: absolute; top: .5rem; left: .5rem; background: rgba(0, 0, 0, .6); color: #fff; font-size: .7rem; font-weight: 700; padding: .1rem .45rem; border-radius: 999px; }
.post-type { position: absolute; top: .5rem; right: .5rem; background: rgba(255, 255, 255, .9); color: var(--ink); font-size: .65rem; font-weight: 700; padding: .1rem .45rem; border-radius: 999px; }
.post-body { padding: .6rem .7rem .7rem; }
.post-date { font-size: .7rem; color: var(--muted); font-weight: 600; }
.post-text { font-size: .78rem; line-height: 1.3; margin: .15rem 0 .45rem; min-height: 2em; }
.post-stats { display: flex; flex-wrap: wrap; gap: .2rem .6rem; font-size: .72rem; font-weight: 600; }
.post-stats i { margin-right: .2rem; color: var(--muted); }

.breakdown-row { margin-bottom: .8rem; }
.bar { height: 10px; border-radius: 999px; background: #f0eef6; overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), #ff7eb6); }
.platform-fb .bar span { background: linear-gradient(90deg, var(--fb), #6aa8ff); }
.best-day { background: var(--brand-soft); border-radius: .8rem; padding: .6rem .9rem; font-size: .9rem; display: inline-block; }

.notes-input { border-radius: 1rem; background: #fffdf5; }
.notes-print { white-space: normal; line-height: 1.6; }
.print-only { display: none; }

.report-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; color: var(--muted); font-size: .8rem; padding: .5rem 1rem 2rem; }

/* ---------- Print / PDF ---------- */
@page { size: A4; margin: 10mm; }
@media print {
    body { background: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .no-print, .app-nav, .report-toolbar, .loading-overlay, .modal, .modal-backdrop { display: none !important; }
    .print-only { display: block !important; }
    main.container { max-width: none !important; padding: 0 !important; }
    .report-section { box-shadow: none; border: 1px solid var(--line); padding: 1.2rem; margin-bottom: 1rem; }
    .report-cover { padding: 1.6rem; }
    .page-break { break-before: page; }
    .avoid-break, .kpi, .post-card, .panel { break-inside: avoid; }
    .col-md-4 { flex: 0 0 auto; width: 33.333%; }
    .col-xl-3 { flex: 0 0 auto; width: 25%; }
    .col-xl-2 { flex: 0 0 auto; width: 16.666%; }
    .chart-wrap { height: 220px; }
    a { text-decoration: none !important; }
}
