/* ==========================================================================
   MY PROFILE
   --------------------------------------------------------------------------
   Loaded only by templates/accounts/profile.html.

   Uses the prf- prefix rather than profile-, because .profile-trigger and
   .profile-copy already belong to the shared topbar in base.html and must not
   be caught by rules written for this page.

   Same system as the dashboard and activity log: one card primitive, hairline
   borders, status colour only where it means something, 44px hit areas,
   visible focus, reduced-motion respected.
   ========================================================================== */

.prf {
  --prf-accent: var(--purple, #5b5bd6);
  --prf-ink: var(--ink, #0f172a);
  --prf-dim: var(--muted, #64748b);
  --prf-line: var(--line, #e6eaf2);
  --prf-card: var(--surface, #fff);
  --prf-sunk: color-mix(in srgb, var(--line, #e6eaf2) 32%, transparent);
  --prf-radius: 12px;
  --prf-pad: 20px;

  --prf-red: #b42318;
  --prf-amber: #b54708;
  --prf-green: #027a48;
}

.prf :focus-visible { outline: 2px solid var(--prf-accent); outline-offset: 2px; border-radius: 8px; }

@media (prefers-reduced-motion: reduce) {
  .prf *, .prf *::before, .prf *::after { transition-duration: .01ms !important; animation: none !important; }
}


/* ==========================================================================
   1. Page head + identity
   ========================================================================== */
.prf-head { margin-bottom: 16px; }
.prf-head h1 { margin: 0; color: var(--prf-ink); font: 700 22px/1.25 Manrope, sans-serif; letter-spacing: -.02em; }
.prf-crumbs { display: flex; align-items: center; gap: 7px; margin-top: 5px; color: var(--prf-dim); font-size: 12.5px; }
.prf-crumbs svg { width: 13px; height: 13px; }
.prf-crumbs a { display: inline-flex; color: inherit; }
.prf-crumbs strong { color: var(--prf-ink); font-weight: 600; }

.prf-identity {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: var(--prf-pad);
  margin-bottom: 16px;
  background: var(--prf-card);
  border: 1px solid var(--prf-line);
  border-radius: var(--prf-radius);
}
.prf-avatar-wrap { position: relative; flex: none; }
.prf-identity .avatar,
.prf-identity .prf-avatar { width: 76px; height: 76px; font-size: 26px; border-radius: 50%; object-fit: cover; }
.prf-dot {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 15px;
  height: 15px;
  border: 3px solid var(--prf-card);
  border-radius: 50%;
  background: #94a3b8;
}
.prf-dot.is-online { background: #16a34a; }

.prf-identity-copy { flex: 1; min-width: 0; }
.prf-identity-copy h2 { margin: 0; color: var(--prf-ink); font: 700 19px/1.25 Manrope, sans-serif; letter-spacing: -.02em; overflow-wrap: anywhere; }
.prf-identity-copy > p { margin: 3px 0 0; color: var(--prf-dim); font-size: 13px; }
.prf-chips { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 11px; }
.prf-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 1px solid var(--prf-line);
  border-radius: 999px;
  color: var(--prf-dim);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.prf-chip svg { width: 13px; height: 13px; }
/* Status carries a word as well as a colour. */
.prf-chip.is-online { color: var(--prf-green); border-color: color-mix(in srgb, var(--prf-green) 36%, transparent); }
.prf-chip.is-offline { color: var(--prf-dim); }
.prf-chip.is-online::before,
.prf-chip.is-offline::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.prf-chip.is-role { color: var(--prf-accent); border-color: color-mix(in srgb, var(--prf-accent) 34%, transparent); }


/* ==========================================================================
   2. Flash messages
   ========================================================================== */
.prf-flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  margin-bottom: 12px;
  border: 1px solid var(--prf-line);
  border-left: 3px solid var(--tone, var(--prf-accent));
  border-radius: var(--prf-radius);
  background: var(--prf-card);
  color: var(--prf-ink);
  font-size: 13px;
}
.prf-flash svg { width: 17px; height: 17px; color: var(--tone, var(--prf-accent)); flex: none; }
.prf-flash.is-success { --tone: var(--prf-green); }
.prf-flash.is-error { --tone: var(--prf-red); }
.prf-flash.is-warning { --tone: var(--prf-amber); }


/* ==========================================================================
   3. Layout + card primitive
   ========================================================================== */
.prf-body { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.prf-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.prf-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 88px; min-width: 0; }

.prf-card {
  background: var(--prf-card);
  border: 1px solid var(--prf-line);
  border-radius: var(--prf-radius);
  overflow: hidden;
}
.prf-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px var(--prf-pad);
  border-bottom: 1px solid var(--prf-line);
}
.prf-card-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 10px;
  background: color-mix(in srgb, var(--tone, var(--prf-accent)) 11%, transparent);
  color: var(--tone, var(--prf-accent));
}
.prf-card-icon svg { width: 17px; height: 17px; }
.prf-card-icon.is-warn { --tone: var(--prf-amber); }
.prf-card-head h2 { margin: 0; color: var(--prf-ink); font: 600 15px/1.3 Manrope, sans-serif; }
.prf-card-head p { margin: 2px 0 0; color: var(--prf-dim); font-size: 12.5px; }
.prf-card-body { padding: var(--prf-pad); }


/* ==========================================================================
   4. Forms
   ========================================================================== */
.prf-section + .prf-section { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--prf-line); }
.prf-section-label {
  display: block;
  margin-bottom: 12px;
  color: var(--prf-dim);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.prf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.prf-row + .prf-field, .prf-field + .prf-field, .prf-row + .prf-row { margin-top: 14px; }

.prf-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.prf-field label { color: var(--prf-ink); font-size: 12.5px; font-weight: 600; }
.prf-field label sup { color: var(--prf-red); font-size: 11px; }
.prf-field input[type="text"],
.prf-field input[type="email"],
.prf-field input[type="tel"],
.prf-field input[type="password"],
.prf-field select,
.prf-field textarea {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--prf-line);
  border-radius: 9px;
  background: var(--prf-card);
  color: var(--prf-ink);
  font-size: 13.5px;
  outline: 0;
  transition: border-color .15s, box-shadow .15s;
}
.prf-field textarea { padding: 10px 12px; min-height: 84px; resize: vertical; }
.prf-field input:focus,
.prf-field select:focus,
.prf-field textarea:focus {
  border-color: var(--prf-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--prf-accent) 15%, transparent);
}
.prf-hint { color: var(--prf-dim); font-size: 11.5px; }
.prf-error { display: flex; align-items: center; gap: 5px; color: var(--prf-red); font-size: 12px; font-weight: 600; }
.prf-error svg { width: 13px; height: 13px; }
.prf-field.has-error input,
.prf-field.has-error select { border-color: var(--prf-red); }

/* Error summary — a failed save must be obvious, not a small note far down. */
.prf-errors {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 15px;
  margin-bottom: 18px;
  border: 1px solid color-mix(in srgb, var(--prf-red) 40%, transparent);
  border-left: 3px solid var(--prf-red);
  border-radius: 10px;
  background: color-mix(in srgb, var(--prf-red) 6%, transparent);
}
.prf-errors svg { width: 17px; height: 17px; color: var(--prf-red); flex: none; margin-top: 1px; }
.prf-errors strong { display: block; color: var(--prf-red); font-size: 13px; }
.prf-errors ul { margin: 5px 0 0; padding-left: 16px; }
.prf-errors li { color: var(--prf-red); font-size: 12.5px; line-height: 1.55; }

.prf-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 15px var(--prf-pad);
  border-top: 1px solid var(--prf-line);
  background: var(--prf-sunk);
}
.prf-actions .prf-hint { margin-right: auto; }

.prf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 16px;
  border: 1px solid var(--prf-line);
  border-radius: 10px;
  background: var(--prf-card);
  color: var(--prf-ink);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.prf-btn:hover { background: var(--prf-sunk); border-color: #cbd5e1; }
.prf-btn svg { width: 16px; height: 16px; }
.prf-btn.is-primary { background: var(--prf-accent); border-color: var(--prf-accent); color: #fff; }
.prf-btn.is-primary:hover { filter: brightness(.93); }


/* ==========================================================================
   5. Avatar upload
   ========================================================================== */
.prf-upload { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.prf-upload .avatar,
.prf-upload .prf-preview {
  width: 68px;
  height: 68px;
  font-size: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  border: 1px solid var(--prf-line);
}
.prf-upload-copy { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
/* The real file input stays reachable by keyboard but visually replaced by the
   label button, so the control still works without a mouse. */
.prf-file {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.prf-file:focus-visible + .prf-file-label { outline: 2px solid var(--prf-accent); outline-offset: 2px; }
.prf-file-label { cursor: pointer; }
.prf-file-name { color: var(--prf-dim); font-size: 12px; overflow-wrap: anywhere; }


/* ==========================================================================
   6. Sidebar info cards
   ========================================================================== */
.prf-info-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px var(--prf-pad);
  border-bottom: 1px solid var(--prf-line);
  color: var(--prf-ink);
  font: 600 13px/1.3 Manrope, sans-serif;
}
.prf-info-title svg { width: 15px; height: 15px; color: var(--prf-dim); }

.prf-dl { margin: 0; padding: 6px var(--prf-pad) 14px; }
.prf-dl > div {
  display: grid;
  grid-template-columns: minmax(0, 108px) minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--prf-line) 60%, transparent);
}
.prf-dl > div:last-child { border-bottom: 0; }
.prf-dl dt {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--prf-dim);
  font-size: 12px;
}
.prf-dl dt svg { width: 13px; height: 13px; flex: none; }
.prf-dl dd { margin: 0; color: var(--prf-ink); font-size: 12.5px; font-weight: 500; overflow-wrap: anywhere; }

.prf-skills { display: flex; flex-wrap: wrap; gap: 6px; padding: 14px var(--prf-pad); }
.prf-skill {
  padding: 4px 10px;
  border: 1px solid var(--prf-line);
  border-radius: 999px;
  background: var(--prf-sunk);
  color: var(--prf-ink);
  font-size: 12px;
  font-weight: 500;
}

.prf-links { display: flex; flex-direction: column; padding: 6px; }
.prf-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 9px;
  color: var(--prf-ink);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}
.prf-link:hover { background: var(--prf-sunk); }
.prf-link svg { width: 16px; height: 16px; color: var(--prf-dim); flex: none; }
.prf-link .prf-link-go { margin-left: auto; opacity: .5; }


/* ==========================================================================
   7. Responsive
   ========================================================================== */
@media (max-width: 1040px) {
  .prf-body { grid-template-columns: minmax(0, 1fr); }
  .prf-side { position: static; }
}

@media (max-width: 768px) {
  .prf { --prf-pad: 16px; }
  .prf-head h1 { font-size: 19px; }
  .prf-identity { gap: 14px; }
  .prf-identity .avatar, .prf-identity .prf-avatar { width: 60px; height: 60px; font-size: 21px; }
  .prf-row { grid-template-columns: 1fr; }
  .prf-actions { flex-direction: column; align-items: stretch; }
  .prf-actions .prf-hint { margin: 0 0 4px; }
  .prf-actions .prf-btn { width: 100%; }
  .prf-dl > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}
