/* =========================================================================
   FACTORY DASHBOARD NOTIFICATIONS
   -------------------------------------------------------------------------
   Notification center, incident-description modal, and analysis callback UI.
   Keep this file separate from the permanent dashboard page styles.
   ========================================================================= */

/* ---------------------------------------------------- bell and unread badge */
.dashboard-notification-button {
  position: relative;
}

.dashboard-notification-bell {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: var(--dashboard-muted, #94a3b8);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  transition: fill 0.16s ease, stroke 0.16s ease, transform 0.16s ease;
}

.dashboard-notification-button:hover .dashboard-notification-bell,
.dashboard-notification-button--unread .dashboard-notification-bell {
  stroke: #fbbf24;
}

.dashboard-notification-button--unread .dashboard-notification-bell {
  fill: color-mix(in srgb, #fbbf24 22%, transparent);
  transform: rotate(-8deg);
}

.dashboard-notification-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  display: grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border: 2px solid var(--dashboard-surface, #111827);
  border-radius: 999px;
  background: #ef4444;
}

/* ------------------------------------------------------ notification tray */
.dashboard-notification-overlay {
  position: fixed;
  top: 100px;
  z-index: 1300;
  width: min(390px, calc(100vw - 30px));
  overflow: hidden;
  color: var(--dashboard-text, #e5edf8);
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 16px;
  background: rgba(17, 24, 39, 0.94);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(18px);
}

html[dir="ltr"] .dashboard-notification-overlay{
      right: 28px;
}

html[dir="rtl"] .dashboard-notification-overlay{
      left: 28px;
}

.dashboard-notification-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 17px 13px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.dashboard-notification-overlay-header strong { font-size: 1.04rem; }
.dashboard-notification-overlay-header p {
  margin: 3px 0 0;
  color: #94a3b8;
  font-size: 0.76rem;
}

.dashboard-notification-overlay-close,
.dashboard-notification-delete,
.dashboard-modal-close {
  display: inline-grid;
  place-items: center;
  padding: 0;
  color: #94a3b8;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.dashboard-notification-overlay-close {
  width: 32px;
  height: 32px;
  font-size: 1.55rem;
}

.dashboard-notification-list {
  max-height: min(520px, 60vh);

  overflow: auto;
  padding: 8px;
  overscroll-behavior: none;
}

.dashboard-notification-list::-webkit-scrollbar {
    width: 6px;
}

.dashboard-notification-list::-webkit-scrollbar-track {
    background: transparent;
}

.dashboard-notification-list::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.5);
    border-radius: 999px;
}


.dashboard-notification-empty {
  margin: 0;
  padding: 28px 18px;
  color: #94a3b8;
  text-align: center;
  font-size: 0.86rem;
}

.dashboard-notification-card {
  position: relative;
  margin-bottom: 7px;
  padding: 12px 13px 10px 38px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-right-width: 4px;
  border-radius: 11px;
  background: rgba(30, 41, 59, 0.72);
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, background-color 0.14s ease;
}

.dashboard-notification-card:hover,
.dashboard-notification-card:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(56, 189, 248, 0.68);
  background: rgba(30, 41, 59, 0.96);
  outline: 0;
}

.dashboard-notification-card--low { border-right-color: #4ade80; }
.dashboard-notification-card--medium { border-right-color: #fbbf24; }
.dashboard-notification-card--high { border-right-color: #f87171; }

.dashboard-notification-delete {
  position: absolute;
  top: 9px;
  left: 8px;
  width: 25px;
  height: 25px;
  font-size: 1.18rem;
}

.dashboard-notification-delete:hover,
.dashboard-notification-overlay-close:hover,
.dashboard-modal-close:hover {
  color: #f8fafc;
  background: rgba(148, 163, 184, 0.16);
}

.dashboard-notification-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dashboard-notification-card-header strong {
  overflow: hidden;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-notification-severity {
  flex: 0 0 auto;
  padding: 2px 7px;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 999px;
}

.dashboard-notification-severity--low { color: #86efac; background: rgba(34, 197, 94, 0.14); }
.dashboard-notification-severity--medium { color: #fde68a; background: rgba(245, 158, 11, 0.14); }
.dashboard-notification-severity--high { color: #fca5a5; background: rgba(239, 68, 68, 0.14); }

.dashboard-notification-card p {
  margin: 7px 0 6px;
  color: #cbd5e1;
  font-size: 0.81rem;
}

.dashboard-notification-card time {
  display: block;
  color: #94a3b8;
  font-size: 0.7rem;
  direction: rtl;
}

/* --------------------------------------------------------------- modals */
.dashboard-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(9px);
}

.dashboard-modal-backdrop[hidden] { display: none; }

.dashboard-modal-card {
  position: relative;
  width: min(520px, 100%);
  padding: 25px;
  color: #e5edf8;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 17px;
  background: rgba(17, 24, 39, 0.97);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.52);
}

.dashboard-modal-close {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 31px;
  height: 31px;
  font-size: 1.45rem;
}

.dashboard-modal-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 14px;
  font-size: 1.7rem;
  font-weight: 800;
  border-radius: 16px;
}

.dashboard-modal-icon--incident {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(248, 113, 113, 0.34);
}

.dashboard-modal-card h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.dashboard-modal-subtitle {
  margin: 0 0 17px;
  color: #94a3b8;
  font-size: 0.87rem;
  line-height: 1.8;
}

.dashboard-modal-label {
  display: block;
  margin-bottom: 7px;
  color: #cbd5e1;
  font-size: 0.84rem;
}

.dashboard-modal-card textarea {
  width: 100%;
  min-height: 98px;
  padding: 11px 12px;
  color: #e5edf8;
  font: inherit;
  line-height: 1.7;
  resize: vertical;
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 10px;
  outline: 0;
  background: rgba(30, 41, 59, 0.7);
}

.dashboard-modal-card textarea:focus {
  border-color: rgba(56, 189, 248, 0.7);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}

.dashboard-modal-form-error {
  margin: 8px 0 0;
  color: #fca5a5;
  font-size: 0.8rem;
}

.dashboard-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 17px;
}

.dashboard-modal-primary-button,
.dashboard-modal-secondary-button {
  padding: 9px 14px;
  color: #f8fafc;
  font: inherit;
  font-size: 0.86rem;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
}

.dashboard-modal-primary-button { background: #0f766e; border-color: #0f766e; }
.dashboard-modal-primary-button:disabled { cursor: wait; opacity: 0.66; }
.dashboard-modal-secondary-button {
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.24);
  background: rgba(30, 41, 59, 0.82);
}

/* -------------------------------------------- animated callback response */
.dashboard-analysis-card {
  width: min(470px, 100%);
  padding: 33px 30px 28px;
  overflow: hidden;
  text-align: center;
  background:
    radial-gradient(circle at 50% 4%, rgba(56, 189, 248, 0.12), transparent 42%),
    rgba(17, 24, 39, 0.98);
}

.dashboard-analysis-visual {
  position: relative;
  display: grid;
  place-items: center;
  width: 146px;
  height: 146px;
  margin: 0 auto 18px;
}

.dashboard-analysis-waiting-animation,
.dashboard-analysis-result {
  position: absolute;
  inset: 0;
}

.dashboard-analysis-waiting-animation { display: grid; place-items: center; }
.dashboard-analysis-orbit {
  position: absolute;
  border: 1px solid rgba(125, 211, 252, 0.28);
  border-radius: 50%;
}
.dashboard-analysis-orbit--outer { inset: 2px; animation: dashboard-analysis-orbit 3.8s linear infinite; }
.dashboard-analysis-orbit--inner { inset: 22px; border-color: rgba(167, 139, 250, 0.28); animation: dashboard-analysis-orbit-reverse 2.8s linear infinite; }
.dashboard-analysis-orbit-dot {
  position: absolute;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  box-shadow: 0 0 20px currentColor;
}
.dashboard-analysis-orbit-dot--one {
  top: 7px;
  color: #38bdf8;
  background: #38bdf8;
  animation: dashboard-analysis-orbit 3.8s linear infinite;
  transform-origin: 6px 66px;
}
.dashboard-analysis-orbit-dot--two {
  bottom: 25px;
  color: #a78bfa;
  background: #a78bfa;
  animation: dashboard-analysis-orbit-reverse 2.8s linear infinite;
  transform-origin: 6px -42px;
}
.dashboard-analysis-core {
  width: 48px;
  height: 48px;
  border: 1px solid rgba(125, 211, 252, 0.58);
  border-radius: 50%;
  background: rgba(14, 116, 144, 0.32);
  box-shadow: 0 0 0 14px rgba(56, 189, 248, 0.06), 0 0 35px rgba(56, 189, 248, 0.36);
  animation: dashboard-analysis-pulse 1.55s ease-in-out infinite;
}

.dashboard-analysis-result {
  display: none;
  place-items: center;
}
.dashboard-analysis-result svg { width: 112px; height: 112px; overflow: visible; }
.dashboard-analysis-result circle,
.dashboard-analysis-result path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.dashboard-analysis-result circle { stroke-width: 3; stroke-dasharray: 190; stroke-dashoffset: 190; }
.dashboard-analysis-result path { stroke-width: 5; stroke-dasharray: 70; stroke-dashoffset: 70; }
.dashboard-analysis-result--success circle,
.dashboard-analysis-result--success path { stroke: #4ade80; }
.dashboard-analysis-result--error circle,
.dashboard-analysis-result--error path { stroke: #f87171; }

.dashboard-analysis-visual--success .dashboard-analysis-waiting-animation,
.dashboard-analysis-visual--error .dashboard-analysis-waiting-animation { display: none; }
.dashboard-analysis-visual--success .dashboard-analysis-result--success,
.dashboard-analysis-visual--error .dashboard-analysis-result--error { display: grid; }
.dashboard-analysis-visual--success circle,
.dashboard-analysis-visual--error circle { animation: dashboard-analysis-draw 0.52s ease-out forwards; }
.dashboard-analysis-visual--success path,
.dashboard-analysis-visual--error path { animation: dashboard-analysis-draw 0.42s 0.36s ease-out forwards; }

.dashboard-analysis-kicker {
  margin: 0 0 8px;
  color: #7dd3fc;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}
.dashboard-analysis-visual--success ~ .dashboard-analysis-kicker { color: #86efac; }
.dashboard-analysis-visual--error ~ .dashboard-analysis-kicker { color: #fca5a5; }
.dashboard-analysis-stage-name {
  margin: 0 0 12px;
  color: #e0f2fe;
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.7;
}
.dashboard-analysis-message {
  min-height: 50px;
  margin: 18px 0 6px;
}
.dashboard-analysis-actions { justify-content: center; }
.dashboard-analysis-progress { margin-top: 4px; text-align: initial; }
.dashboard-analysis-progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: #cbd5e1;
  font-size: 0.76rem;
  font-weight: 700;
}
.dashboard-analysis-progress-track {
  position: relative;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
}
.dashboard-analysis-progress-bar {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #38bdf8, #a78bfa);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.52);
  transition: width 0.62s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: width, transform;
}
.dashboard-analysis-progress--pending .dashboard-analysis-progress-bar {
  width: 36% !important;
  animation: dashboard-analysis-progress-pending 1.65s linear infinite;
}
.dashboard-analysis-progress--success .dashboard-analysis-progress-bar {
  background: #4ade80;
  box-shadow: 0 0 16px rgba(74, 222, 128, 0.48);
  animation: none;
  transform: none;
}
.dashboard-analysis-progress--error .dashboard-analysis-progress-track {
  background: rgba(248, 113, 113, 0.18);
}
.dashboard-analysis-progress--error .dashboard-analysis-progress-bar {
  background: #f87171;
  box-shadow: 0 0 16px rgba(248, 113, 113, 0.48);
  animation: none;
  transform: none;
}

@keyframes dashboard-analysis-orbit { to { transform: rotate(360deg); } }
@keyframes dashboard-analysis-orbit-reverse { to { transform: rotate(-360deg); } }
@keyframes dashboard-analysis-pulse { 50% { transform: scale(1.16); opacity: 0.72; } }
@keyframes dashboard-analysis-draw { to { stroke-dashoffset: 0; } }
@keyframes dashboard-analysis-progress-pending { 0% { transform: translateX(-115%); } 100% { transform: translateX(300%); } }

@media (max-width: 600px) {
  .dashboard-notification-overlay {
    top: 68px;
    left: 15px;
    width: 90%
  }
  .dashboard-analysis-card { padding-inline: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .dashboard-analysis-orbit--outer,
  .dashboard-analysis-orbit--inner,
  .dashboard-analysis-orbit-dot,
  .dashboard-analysis-core,
  .dashboard-analysis-progress--pending .dashboard-analysis-progress-bar { animation-duration: 3s; }
}
