/* =============================================================================
 * ph-core.css — NEUTRAL base styles for the shared window.PH components.
 * -----------------------------------------------------------------------------
 * These styles are intentionally MINIMAL and structural. They read CSS custom
 * properties so each variant themes the shared widgets by defining:
 *   --ph-accent   primary accent / brand color
 *   --ph-bg       app background
 *   --ph-surface  panel / card background
 *   --ph-text     primary text color
 *   --ph-border   border color
 *   --ph-radius   corner radius
 * Optional extras (with safe fallbacks below):
 *   --ph-muted    secondary text
 *   --ph-danger / --ph-warn / --ph-ok  status colors
 *   --ph-shadow   elevation shadow
 *   --ph-overlay  modal backdrop color
 *
 * Variants OWN their look — only override these here if a variant does not.
 * ========================================================================== */

:root {
  /* Fallback theme tokens (variants override on their root/body). */
  --ph-accent: #3b82f6;
  --ph-bg: #0f1115;
  --ph-surface: #181b22;
  --ph-text: #e8eaed;
  --ph-border: #2a2f3a;
  --ph-radius: 10px;
  --ph-muted: #9aa3b2;
  --ph-danger: #e5484d;
  --ph-warn: #f5a524;
  --ph-ok: #2bb673;
  --ph-info: #3b82f6;
  --ph-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --ph-overlay: rgba(0, 0, 0, 0.55);
  /* Semantic z-index token (no magic numbers). Toast sits above the bell
   * dropdown (1000) on its own scale; variants may raise it if needed. */
  --ph-z-toast: 500;
}

/* ---------------------------------------------------------------------------
 * Generic button used by shared widgets (modal close, etc.). Variants may
 * restyle .ph-btn freely; this is just a sane neutral default.
 * ------------------------------------------------------------------------- */
.ph-btn {
  font: inherit;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: var(--ph-radius);
  border: 1px solid var(--ph-border);
  background: var(--ph-accent);
  color: #fff;
  line-height: 1.2;
  transition: filter .15s ease, opacity .15s ease;
}
.ph-btn:hover { filter: brightness(1.08); }
.ph-btn:active { filter: brightness(0.95); }
.ph-btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Gating helper (applyGating toggles this on hidden elements as a fallback). */
.ph-gated-hidden { display: none !important; }

/* ===========================================================================
 * TOAST
 * ========================================================================= */
.ph-toast-host {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: var(--ph-z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.ph-toast {
  position: relative;
  pointer-events: auto;
  min-width: 220px;
  max-width: 360px;
  padding: 11px 14px 11px 32px;
  border-radius: var(--ph-radius);
  background: var(--ph-surface);
  color: var(--ph-text);
  border: 1px solid var(--ph-border);
  box-shadow: var(--ph-shadow);
  font-size: 14px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .28s ease, transform .28s ease;
}
/* Status read as a leading dot, not a banned 3px side-stripe. */
.ph-toast::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--ph-accent);
}
.ph-toast--show { opacity: 1; transform: translateY(0); }
.ph-toast--error::before { background: var(--ph-danger); }
.ph-toast--warn::before { background: var(--ph-warn); }

/* ===========================================================================
 * BELL + NOTIFICATIONS DROPDOWN
 * ========================================================================= */
.ph-bell {
  position: relative;
  display: inline-block;
}
.ph-bell__btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--ph-radius);
  border: 1px solid var(--ph-border);
  background: var(--ph-surface);
  color: var(--ph-text);
  cursor: pointer;
}
.ph-bell__btn:hover { border-color: var(--ph-accent); }
.ph-bell__badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--ph-danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--ph-bg);
}
.ph-bell__dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  max-width: 86vw;
  max-height: 460px;
  overflow: auto;
  background: var(--ph-surface);
  border: 1px solid var(--ph-border);
  border-radius: var(--ph-radius);
  box-shadow: var(--ph-shadow);
  z-index: 1000;
}
.ph-bell__dropdown[hidden] { display: none; }
.ph-bell__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--ph-border);
  position: sticky;
  top: 0;
  background: var(--ph-surface);
}
.ph-bell__head strong { color: var(--ph-text); font-size: 14px; }
.ph-bell__readall {
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--ph-accent);
  padding: 2px 4px;
}
.ph-bell__list { padding: 4px 0; }
.ph-bell__empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--ph-muted);
  font-size: 13px;
}
.ph-bell__item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--ph-border);
  font-size: 13px;
}
.ph-bell__item:last-child { border-bottom: none; }
.ph-bell__item.is-unread { background: color-mix(in srgb, var(--ph-accent) 8%, transparent); }
.ph-bell__item-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}
.ph-bell__item-top strong { color: var(--ph-text); font-weight: 600; flex: 1; }
.ph-bell__time { color: var(--ph-muted); font-size: 11px; white-space: nowrap; }
.ph-bell__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ph-muted);
  flex: none;
}
.ph-bell__item.ph-sev--info .ph-bell__dot { background: var(--ph-info); }
.ph-bell__item.ph-sev--warning .ph-bell__dot { background: var(--ph-warn); }
.ph-bell__item.ph-sev--error .ph-bell__dot { background: var(--ph-danger); }
.ph-bell__item.ph-sev--critical .ph-bell__dot { background: var(--ph-danger); }
.ph-bell__msg { color: var(--ph-muted); line-height: 1.4; }
.ph-bell__mark {
  margin-top: 6px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--ph-accent);
  padding: 0;
}

/* ===========================================================================
 * MODAL (used by model-viewer placeholder; reusable by variants)
 * ========================================================================= */
.ph-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--ph-overlay);
  animation: ph-fade .15s ease;
}
@keyframes ph-fade { from { opacity: 0; } to { opacity: 1; } }
.ph-modal {
  width: min(640px, 96vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--ph-surface);
  color: var(--ph-text);
  border: 1px solid var(--ph-border);
  border-radius: var(--ph-radius);
  box-shadow: var(--ph-shadow);
  overflow: hidden;
}
.ph-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--ph-border);
}
.ph-modal__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: var(--ph-radius);
  background: transparent;
  color: var(--ph-text);
  cursor: pointer;
}
.ph-modal__close:hover { background: color-mix(in srgb, var(--ph-text) 10%, transparent); }
.ph-modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--ph-border);
}

/* --- 3D model viewer PLACEHOLDER (reserved spot, NO real scene) --- */
.ph-mv__title { font-size: 15px; font-weight: 600; }
.ph-mv__stage {
  position: relative;
  flex: 1;
  min-height: 320px;
  margin: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  border: 1px dashed var(--ph-border);
  border-radius: var(--ph-radius);
  background:
    repeating-linear-gradient(45deg,
      color-mix(in srgb, var(--ph-text) 3%, transparent) 0 12px,
      transparent 12px 24px);
  color: var(--ph-muted);
}
.ph-mv__wip {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  padding: 3px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ph-warn) 22%, transparent);
  color: var(--ph-warn);
  border: 1px solid color-mix(in srgb, var(--ph-warn) 45%, transparent);
}
.ph-mv__icon {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: .65;
  color: var(--ph-accent);
}
.ph-mv__icon svg { width: 56px; height: 56px; }
.ph-mv__text { font-size: 15px; color: var(--ph-text); max-width: 380px; }
.ph-mv__sub { font-size: 13px; color: var(--ph-muted); max-width: 360px; }

/* ===========================================================================
 * CAMERA (animated placeholder + LIVE badge)
 * ========================================================================= */
.ph-camera {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: var(--ph-radius);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--ph-border);
}
.ph-camera__canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.ph-camera__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff3b3b;
  animation: ph-pulse 1.2s infinite;
}
@keyframes ph-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .25; }
}
/* Camera image disabled by request: render the Камера tab as a light empty state
   (no canvas, no animation). Overrides the black-box default above. */
.ph-camera--off {
  background: var(--ph-surface, #fff);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ph-camera__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  padding: 24px;
  color: var(--ph-text);
}
.ph-camera__empty-icon { opacity: 0.32; }
.ph-camera__empty-icon svg { display: block; }
.ph-camera__empty-title { font-weight: 600; font-size: 14px; }
.ph-camera__empty-sub { font-size: 12.5px; opacity: 0.55; }

/* ===========================================================================
 * DROPZONE
 * ========================================================================= */
.ph-dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  padding: 24px;
  text-align: center;
  border: 2px dashed var(--ph-border);
  border-radius: var(--ph-radius);
  background: color-mix(in srgb, var(--ph-text) 2%, transparent);
  color: var(--ph-muted);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.ph-dropzone:hover { border-color: var(--ph-accent); }
.ph-dropzone.is-dragover {
  border-color: var(--ph-accent);
  background: color-mix(in srgb, var(--ph-accent) 12%, transparent);
}
.ph-dropzone__icon {
  color: var(--ph-accent);
  margin-bottom: 10px;
}
.ph-dropzone__icon svg { width: 34px; height: 34px; }
.ph-dropzone__title { color: var(--ph-text); font-size: 15px; font-weight: 600; }
.ph-dropzone__hint { font-size: 13px; margin-top: 4px; }
.ph-dropzone__progress {
  width: 100%;
  max-width: 320px;
  margin-top: 16px;
  height: 8px;
  border-radius: 999px;
  background: var(--ph-border);
  overflow: hidden;
}
.ph-dropzone__progress[hidden] { display: none; }
.ph-dropzone__bar {
  height: 100%;
  width: 0;
  background: var(--ph-accent);
  border-radius: 999px;
  transition: width .14s linear;
}

/* ===========================================================================
 * ROLE SWITCHER
 * ========================================================================= */
.ph-roleswitch {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--ph-radius);
  border: 1px solid var(--ph-border);
  background: var(--ph-surface);
}
.ph-roleswitch__btn {
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 5px 12px;
  border: none;
  border-radius: calc(var(--ph-radius) - 3px);
  background: transparent;
  color: var(--ph-muted);
  transition: background .15s ease, color .15s ease;
}
.ph-roleswitch__btn:hover { color: var(--ph-text); }
.ph-roleswitch__btn.is-active {
  background: var(--ph-accent);
  color: #fff;
}

/* ===========================================================================
 * Responsive tweaks for shared widgets
 * ========================================================================= */
@media (max-width: 520px) {
  .ph-bell__dropdown { width: 92vw; right: -8px; }
  .ph-roleswitch__btn { padding: 5px 9px; font-size: 12px; }
  .ph-toast { min-width: 0; max-width: 88vw; }
}
