/* 13-share-forms.css — The presentation share panel and its progress ring, the leaderboard on phones,
   chart grids, the listing form (price total, divisible switch, activities), activity and AI settings.
   Part of the CRM stylesheet: the files load in number order (components/app_styles.html) and later
   rules win, exactly as when this was one file. */

/* Choices after preparing presentations: share files, Telegram picker, link or download. */
.share-panel { position: fixed; z-index: 41; left: calc(var(--sidebar-w) + (100% - var(--sidebar-w)) / 2); bottom: 22px; transform: translateX(-50%); width: min(560px, calc(100% - 24px)); padding: 12px 14px 14px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-lg); animation: toast-in .2s ease; }
.share-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 14px; }
.share-panel-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.share-panel-actions .btn { flex: 1 1 auto; justify-content: center; height: 40px; }
@media (max-width: 820px) {
  .share-panel { left: 10px; right: 10px; width: auto; transform: none; bottom: calc(70px + env(safe-area-inset-bottom)); }
  .share-panel-actions .btn { flex: 1 1 100%; }
}

/* Broker ranking on a phone: rank, name and score on top, the numbers labelled underneath. */
@media (max-width: 640px) {
  .leader.head { display: none; }
  .leader { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 12px; }
  .leader .rank, .leader .person { order: -2; }
  .leader .person { flex: 1 1 calc(100% - 160px); min-width: 0; }
  .leader .person b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .leader .hide-md { display: none; }
  .leader-score { order: -1; flex: 0 0 96px; }
  .leader-stat { display: flex; flex: 1 1 calc(25% - 20px); flex-direction: column; gap: 2px; min-width: 0; font-size: 14px; }
  .leader-stat::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

.grid-charts { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
@media (max-width: 820px) {
  .grid-charts { grid-template-columns: minmax(0, 1fr); }
  .chart-with-legend { flex-wrap: wrap; }
  .chart-with-legend .chart-box { flex: 1 1 100% !important; min-width: 0; }
}

/* Progress ring in the share panel. */
.share-panel-head { gap: 12px; justify-content: flex-start; }
.share-panel-head [data-close] { margin-left: auto; }
.share-panel-text { display: flex; flex-direction: column; min-width: 0; }
.share-progress { position: relative; flex: none; width: 46px; height: 46px; }
.share-progress svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.share-progress circle { fill: none; stroke-width: 4; }
.share-progress .track { stroke: var(--surface-3); }
.share-progress .bar { stroke: var(--primary); stroke-linecap: round; transition: stroke-dashoffset .25s ease, stroke .2s; }
.share-progress .tick { fill: none; stroke: #fff; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 30; stroke-dashoffset: 30; transform: rotate(90deg); transform-origin: center; }
.share-progress.spinning svg { animation: share-spin .9s linear infinite; }
.share-progress.done .track { stroke: var(--success); fill: var(--success); }
.share-progress.done .bar { stroke: var(--success); }
.share-progress.done .tick { stroke-dashoffset: 0; transition: stroke-dashoffset .35s ease .1s; }
.share-percent { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12.5px; font-weight: 700; }
@keyframes share-spin { to { transform: rotate(270deg); } }
@keyframes upload-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .share-progress.spinning svg { animation-duration: 2.5s; } }

.price-total { display: flex; align-items: center; background: var(--surface-2); font-weight: 700; }

.pcard-price .per-m2 { font-weight: 600; color: var(--muted); }
.split-chip { margin-left: 4px; padding: 1px 6px; border-radius: 5px; background: var(--green-bg); color: var(--green); font-size: 12px; font-weight: 700; }

/* The share page opened from the Mini App in the phone browser: no sidebar, the panel is the page. */
.share-page { --sidebar-w: 0px; }
.share-page .share-panel [data-close] { display: none; }

.kcard-readonly { cursor: pointer; opacity: .85; }

/* Listing form: divisible switch at the top, activities as a checklist. */
.form-lead { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px 18px; margin-bottom: 18px; padding: 14px 16px; border: 1px solid var(--accent-soft-2); border-radius: 12px; background: var(--accent-soft); }
.form-lead .field { flex: 1 1 220px; margin: 0; }
.divisible-toggle { display: flex; flex: 1 1 320px; align-items: flex-start; gap: 10px; cursor: pointer; }
.divisible-toggle input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); }
.divisible-toggle span { display: flex; flex-direction: column; gap: 2px; }
.divisible-toggle small { color: var(--muted); font-size: 13.5px; }
.check-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; padding: 0; list-style: none; }
.check-list > label { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 14px; cursor: pointer; }
.check-list label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* Activity settings */
.activity-add { display: flex; gap: 8px; margin-bottom: 14px; }
.activity-add .input { flex: 1; }
.activity-list { margin: 0; padding: 0; list-style: none; }
.activity-list li.is-dragging { opacity: .45; }
.drag-handle { display: inline-flex; align-items: center; flex: none; padding: 6px 2px; color: var(--faint); cursor: grab; touch-action: none; user-select: none; }
.drag-handle:active { cursor: grabbing; }
.activity-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border-soft); }
.activity-row .input { flex: 1; min-width: 0; }
@media (max-width: 640px) { .activity-row { flex-wrap: wrap; } .activity-row .input { flex: 1 1 100%; } }

.pcard-title { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* AI assistant settings */
.ai-settings { max-width: 760px; }
.ai-rewrite { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.ai-features { display: grid; gap: 12px; font-size: 14px; line-height: 1.5; }
.ai-features > div { display: grid; gap: 2px; }
.ai-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 14px; line-height: 1.5; }
.ai-points li { display: flex; align-items: flex-start; gap: 8px; }
.ai-points .i { flex: none; margin-top: 3px; color: var(--green); }
.char-meter.over { color: var(--red); font-weight: 600; }
.ai-state p { margin-bottom: 0; }
.steps { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 7px; font-size: 14px; line-height: 1.5; }
.steps a { color: var(--accent-strong); font-weight: 600; }
.ai-price { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius); background: var(--slate-bg); font-size: 13.5px; line-height: 1.5; }
.ai-key { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.ai-key code { font-size: 13.5px; }
@media (max-width: 640px) {
  .ai-key { flex-direction: column; align-items: flex-start; }
  .ai-usage { grid-template-columns: 1fr; }
  .ai-settings .activity-add { flex-wrap: wrap; }
  .ai-settings .activity-add .input { flex: 1 1 100%; }
}

