/* ==========================================================================
   AGENCYOS v2 — Maverix Visuals rebrand + interactivity layer
   Dark mode, motion, brand gold accent, command palette, calendar,
   charts, avatars, permission-gated UI, mini read-only pipeline board.
   ========================================================================== */

:root {
  --gold: oklch(0.78 0.11 85);
  --gold-foreground: oklch(0.22 0.03 85);
  --anim-fast: .15s; --anim-med: .25s; --anim-slow: .45s;
}

/* ---------------- Dark mode ---------------- */
html[data-theme="dark"] {
  --canvas: oklch(0.19 0.015 150);
  --background: oklch(0.22 0.015 150);
  --surface: oklch(0.235 0.016 150);
  --surface-muted: oklch(0.28 0.018 150);
  --foreground: oklch(0.94 0.006 130);
  --card: oklch(0.235 0.016 150);
  --secondary: oklch(0.28 0.018 150);
  --secondary-foreground: oklch(0.9 0.01 130);
  --muted: oklch(0.3 0.018 150);
  --muted-foreground: oklch(0.68 0.015 140);
  --border: oklch(0.33 0.02 150);
  --input: oklch(0.33 0.02 150);
  --sidebar: oklch(0.15 0.02 155);
  --sidebar-accent: oklch(0.24 0.03 155);
  --shadow-card: 0 2px 10px -4px oklch(0.05 0.02 150 / 0.5);
  --shadow-float: 0 30px 60px -22px oklch(0.05 0.02 150 / 0.65);
  --shadow-portal: 0 40px 90px -30px oklch(0.05 0.02 150 / 0.7);
}
html[data-theme="dark"] .dotted-canvas { background-image: radial-gradient(var(--border) 1px, transparent 1px); }
html[data-theme="dark"] .auth-side { background: oklch(0.14 0.02 155); }
html[data-theme="dark"] .p-card, html[data-theme="dark"] .asset-tile, html[data-theme="dark"] .social-card { border-color: var(--border); }
body { transition: background var(--anim-med) ease, color var(--anim-med) ease; }
.theme-toggle-track { position: relative; height: 18px; width: 13.5px; }
.theme-toggle-track svg { position: absolute; inset: 0; transition: opacity var(--anim-med) ease, transform var(--anim-med) ease; }
.icon-sun { opacity: 1; transform: rotate(0deg) scale(1); }
.icon-moon { opacity: 0; transform: rotate(-60deg) scale(.4); position:absolute; top:0; left:0; }
html[data-theme="dark"] .icon-sun { opacity: 0; transform: rotate(60deg) scale(.4); }
html[data-theme="dark"] .icon-moon { opacity: 1; transform: rotate(0deg) scale(1); }

/* ---------------- Brand mark ---------------- */
.sidebar-brand .mark { background: #fff; padding: 3px; }
.sidebar-brand .mark img { object-fit: contain; height: 100%; width: 100%; }
.sidebar-brand .name .dot { color: var(--gold); }
.brand-gold { color: var(--gold); }
.badge.gold { background: color-mix(in oklab, var(--gold) 22%, var(--surface-muted)); color: color-mix(in oklab, var(--gold) 55%, black 35%); }

/* ---------------- Motion ---------------- */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: scale(1); } }
@keyframes spinSlow { to { transform: rotate(360deg); } }
@keyframes pulseDot { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes shimmer { 0% { background-position: -200px 0; } 100% { background-position: 200px 0; } }

.reveal { animation: fadeInUp var(--anim-med) cubic-bezier(.2,.8,.3,1) both; animation-delay: var(--d, 0ms); }
.reveal-pop { animation: popIn var(--anim-med) cubic-bezier(.2,.8,.3,1) both; animation-delay: var(--d, 0ms); }
.page-body > *:not(.overlay):not(.drawer):not(.drawer-scrim):not(.cmdk-overlay) { animation: fadeIn var(--anim-slow) ease both; }
.icon-btn, .btn, .chip, .folder-chip, .side-link, .swatch, .demo-pick { transition: transform var(--anim-fast) ease, background var(--anim-fast) ease, color var(--anim-fast) ease, box-shadow var(--anim-fast) ease, border-color var(--anim-fast) ease; }
.side-link:active, .btn:active, .chip:active { transform: scale(.96); }
.stat-card .val { transition: color var(--anim-med) ease; }
.pulse { animation: pulseDot 1.6s ease-in-out infinite; }
.skeleton { background: linear-gradient(90deg, var(--surface-muted) 25%, var(--border) 37%, var(--surface-muted) 63%); background-size: 400px 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--radius-md); }
@media (prefers-reduced-motion: reduce) {
  .reveal, .reveal-pop, .page-body > *:not(.overlay):not(.drawer):not(.drawer-scrim):not(.cmdk-overlay), .pulse, .skeleton { animation: none !important; }
  * { transition-duration: 0.01ms !important; }
}

/* ---------------- Button loading state ---------------- */
.btn-spin { display: inline-block; height: 14px; width: 14px; border-radius: 999px; border: 2px solid currentColor; border-top-color: transparent; opacity: .85; animation: spinSlow .6s linear infinite; vertical-align: -2px; margin-right: 6px; }
.btn.is-loading, .icon-btn.is-loading { pointer-events: none; opacity: .8; }
.btn.is-loading .btn-label, .icon-btn.is-loading .btn-label { opacity: .55; }

/* Give every clickable control an obvious affordance + gentle lift, so
   nothing in the app reads as "dead" — buttons, chips, cards, rows. */
.btn, .icon-btn, .chip, .side-link, .demo-pick, .swatch, .p-card, .cell-row,
.asset-tile, .social-card, .stat-card, .thread-item, [onclick], [data-clickable] {
  cursor: pointer;
}
.btn:hover, .icon-btn:hover { filter: brightness(1.04); }
.p-card:hover, .asset-tile:hover, .social-card:hover, .stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); }
input, textarea, select { cursor: text; }
.locked, .locked * { cursor: not-allowed !important; }

/* ---------------- Maverix "Powered by" footer + modal ---------------- */
.maverix-foot { cursor: pointer; border-radius: var(--radius-md); transition: background var(--anim-fast) ease; }
.maverix-foot:hover { background: var(--surface-muted); }
.maverix-modal-scrim { position: fixed; inset: 0; background: oklch(0.15 0.02 150 / 0.55); backdrop-filter: blur(3px); z-index: 400; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity .18s ease; padding: 20px; }
.maverix-modal-scrim.open { opacity: 1; pointer-events: auto; }
.maverix-modal { width: 100%; max-width: 380px; background: var(--surface); border-radius: var(--radius-2xl); border: 1px solid var(--border); box-shadow: var(--shadow-portal); padding: 28px 26px; text-align: center; transform: translateY(10px) scale(.97); transition: transform .18s ease; }
.maverix-modal-scrim.open .maverix-modal { transform: translateY(0) scale(1); }
.maverix-modal .mv-logo { height: 64px; width: 64px; border-radius: 18px; background: #fff; padding: 10px; margin: 0 auto 14px; box-shadow: var(--shadow-card); display: flex; align-items: center; justify-content: center; }
.maverix-modal .mv-logo img { height: 100%; width: 100%; object-fit: contain; }
.maverix-modal h3 { font-size: 17px; font-weight: 800; }
.maverix-modal p { font-size: 13px; color: var(--muted-foreground); margin: 8px 0 20px; line-height: 1.55; }
.maverix-modal .mv-actions { display: flex; flex-direction: column; gap: 8px; }
.maverix-modal .mv-close { margin-top: 14px; }

/* ---------------- Auth page: bigger brand + support illustration ---------------- */
.auth-side .brand-row { display: flex; align-items: center; gap: 10px; }
.auth-side .brand-row .mark-xl { height: 46px; width: 46px; border-radius: 13px; background: #fff; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 6px; box-shadow: var(--shadow-card); }
.auth-side .brand-row .mark-xl img { height: 100%; width: 100%; object-fit: contain; }
.auth-side .brand-row b { font-size: 19px; }
.auth-side h1 { font-size: 34px; }
.support-illustration { position: relative; display: flex; align-items: center; gap: 14px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: var(--radius-2xl); padding: 16px 18px; max-width: 360px; }
.support-illustration .ring { position: relative; height: 46px; width: 46px; border-radius: 999px; background: var(--gold); color: var(--gold-foreground); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.support-illustration .ring::after { content: ""; position: absolute; inset: -4px; border-radius: 999px; border: 2px solid rgba(255,255,255,.35); animation: pulseDot 1.8s ease-in-out infinite; }
.support-illustration .txt b { display: block; font-size: 13.5px; color: #fff; }
.support-illustration .txt span { font-size: 11.5px; color: rgba(255,255,255,.6); }
.auth-demo-list .btn-block { margin-top: 4px; }

/* ---------------- Avatars (photo or initials) ---------------- */
.av-photo { object-fit: cover; height: 100%; width: 100%; border-radius: inherit; }
.sidebar-user .initials, .avatar-btn, .demo-pick .sw, .cell-title .tint, .p-card .tint, .thread-item .tint, .team-stack .av, .drawer-scrim ~ .drawer .tint { overflow: hidden; }
.avatar-picker { display: flex; align-items: center; gap: 14px; }
.avatar-picker .preview { height: 64px; width: 64px; border-radius: 999px; background: var(--brand-primary, var(--primary)); color: var(--brand-primary-foreground,#fff); display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 800; overflow: hidden; flex-shrink: 0; border: 2px solid var(--border); }
.avatar-picker .actions { display: flex; gap: 8px; }

/* ---------------- Permission-gated UI ---------------- */
.super-only { display: none !important; }
[data-super="1"] .super-only { display: inherit !important; }
[data-super="1"] .super-only.flex-show { display: flex !important; }
.perm-note { font-size: 11px; color: var(--muted-foreground); background: var(--surface-muted); border-radius: var(--radius-md); padding: 8px 10px; margin-top: 8px; }

/* ---------------- Command palette ---------------- */
.cmdk-overlay { position: fixed; inset: 0; background: oklch(0.15 0.02 150 / 0.5); backdrop-filter: blur(3px); z-index: 300; display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; opacity: 0; pointer-events: none; transition: opacity .15s ease; }
.cmdk-overlay.open { opacity: 1; pointer-events: auto; }
.cmdk-box { width: 100%; max-width: 560px; background: var(--surface); border-radius: var(--radius-2xl); box-shadow: var(--shadow-portal); border: 1px solid var(--border); overflow: hidden; transform: translateY(-8px) scale(.98); transition: transform .18s ease; }
.cmdk-overlay.open .cmdk-box { transform: translateY(0) scale(1); }
.cmdk-input-row { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.cmdk-input-row svg { width: 16px; height: 16px; color: var(--muted-foreground); flex-shrink: 0; }
.cmdk-input-row input { flex: 1; border: none; outline: none; background: transparent; font-size: 14px; }
.cmdk-input-row kbd { font-size: 10px; background: var(--surface-muted); padding: 2px 6px; border-radius: 6px; color: var(--muted-foreground); }
.cmdk-list { max-height: 360px; overflow-y: auto; padding: 8px; }
.cmdk-group { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-foreground); padding: 8px 10px 4px; }
.cmdk-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; cursor: pointer; font-size: 13px; }
.cmdk-item svg { width: 15px; height: 15px; color: var(--muted-foreground); flex-shrink: 0; }
.cmdk-item.active, .cmdk-item:hover { background: var(--surface-muted); }
.cmdk-item .sub { font-size: 11px; color: var(--muted-foreground); margin-left: auto; }
.cmdk-empty { padding: 30px; text-align: center; color: var(--muted-foreground); font-size: 12.5px; }

/* ---------------- Shortcuts modal ---------------- */
.shortcut-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 4px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.shortcut-row:last-child { border-bottom: none; }
.keycap { font-size: 10.5px; font-weight: 700; background: var(--surface-muted); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; padding: 2px 7px; margin-left: 4px; }

/* ---------------- Calendar ---------------- */
.cal-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.cal-toolbar h2 { font-size: 15px; font-weight: 700; min-width: 150px; text-align: center; }
.cal-legend { display: flex; gap: 12px; margin-left: auto; flex-wrap: wrap; }
.cal-legend span { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted-foreground); }
.cal-legend i { height: 8px; width: 8px; border-radius: 999px; display: inline-block; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-foreground); text-align: center; padding-bottom: 4px; }
.cal-cell { min-height: 92px; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 6px; background: var(--surface); display: flex; flex-direction: column; gap: 3px; cursor: pointer; }
.cal-cell:hover { border-color: var(--brand-primary,var(--primary)); }
.cal-cell.other-month { opacity: .35; }
.cal-cell.today { border-color: var(--brand-primary,var(--primary)); box-shadow: 0 0 0 1px var(--brand-primary,var(--primary)); }
.cal-cell .num { font-size: 11px; font-weight: 700; }
.cal-chip { font-size: 9.5px; font-weight: 600; padding: 2px 6px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-more { font-size: 9.5px; color: var(--muted-foreground); padding-left: 2px; }
.cal-agenda { margin-top: 16px; }

/* ---------------- Chart cards ---------------- */
.chart-card { position: relative; }
.chart-card canvas { max-width: 100%; }
.donut-wrap { position: relative; display: flex; align-items: center; justify-content: center; }
.donut-center { position: absolute; text-align: center; pointer-events: none; }
.donut-center b { font-size: 22px; font-weight: 800; display: block; }
.donut-center span { font-size: 10px; color: var(--muted-foreground); }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 11.5px; padding: 5px 0; }
.legend-row i { height: 9px; width: 9px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.legend-row b { margin-left: auto; }
.upsell-card { border-radius: var(--radius-2xl); padding: 18px; color: var(--sidebar-foreground); background: var(--sidebar); position: relative; overflow: hidden; }
.upsell-card::before { content:""; position:absolute; inset:0; background-image: radial-gradient(rgba(255,255,255,.08) 1px, transparent 1px); background-size: 14px 14px; }
.upsell-card > * { position: relative; }
.upsell-card h4 { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.upsell-card p { font-size: 12px; color: rgba(255,255,255,.65); line-height: 1.5; margin-bottom: 14px; }

/* ---------------- Mini read-only pipeline (admin reference board) ---------------- */
.mini-board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.mini-lane { border-radius: var(--radius-lg); padding: 12px; }
.mini-lane .mh { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.mini-lane .mh b { font-size: 11.5px; font-weight: 700; }
.mini-lane .mh span { margin-left: auto; font-size: 10px; font-weight: 800; background: rgba(255,255,255,.5); padding: 1px 6px; border-radius: 6px; }
.mini-card { background: var(--surface); border-radius: 9px; padding: 8px 9px; margin-bottom: 6px; box-shadow: var(--shadow-card); cursor: default; }
.mini-card b { font-size: 11px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-card span { font-size: 9.5px; color: var(--muted-foreground); }
.mini-lane .readonly-tag { font-size: 9px; color: var(--muted-foreground); text-align: center; padding: 4px 0 0; }

@media (max-width: 900px) {
  .mini-board { grid-template-columns: 1fr 1fr; }
  .cal-grid { gap: 4px; }
  .cal-cell { min-height: 64px; padding: 4px; }
  .cal-chip { display: none; }
  .cal-cell .num { font-size: 10px; }
  .cal-cell.has-more::after { content: "•"; color: var(--brand-primary,var(--primary)); font-size: 16px; }
}
@media (max-width: 620px) {
  .mini-board { grid-template-columns: 1fr; }
  .cmdk-box { max-width: 92vw; }
}
