/* Assessment modal specific styling */

#assessmentModal .modal__dialog {
  width: min(940px, 94vw);
  max-width: 940px;
  margin: 4vh auto;
  border-radius: var(--radius-lg);
  /* Use surface, not bg, for the modal dialog itself */
  background: var(--surface); 
}

#assessmentModal .modal__body--scroll {
  max-height: 70vh;
  overflow-y: auto;
  /* Tighter top/bottom padding */
  padding: 20px 24px;
  /* Use the main page background for the scrollable area */
  background: var(--bg);
}

.assessment-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  /* Add padding to match the new body padding */
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.assessment-modal__title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.assessment-modal__close {
  margin-left: auto;
  line-height: 1;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.assessment-modal__close--mobile {
  display: none;
}
.assessment-modal__close--desktop {
  margin-left: 0;
}

.assessment-modal__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.assessment-status {
  padding: 3px 10px;
  border-radius: 999px;
  border: none;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
  line-height: 1.4;
}

.assessment-status[data-tone="positive"] {
  background: rgba(16, 185, 129, .1);
  color: #057a55;
}
html[data-theme="dark"] .assessment-status[data-tone="positive"] {
  background: rgba(16, 185, 129, .2);
  color: #34d399;
}

.assessment-status[data-tone="caution"] {
  background: rgba(245, 158, 11, .1);
  color: #b45309;
}
html[data-theme="dark"] .assessment-status[data-tone="caution"] {
  background: rgba(245, 158, 11, .2);
  color: #f59e0b;
}

.assessment-status[data-tone="negative"] {
  background: rgba(239, 68, 68, .1);
  color: #c81e1e;
}
html[data-theme="dark"] .assessment-status[data-tone="negative"] {
  background: rgba(239, 68, 68, .2);
  color: #f87171;
}

.assessment-modal__body {
  display: flex;
  flex-direction: column;
  /* Tighter gap between sections */
  gap: 18px;
}

.assessment-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  color: var(--muted);
  border: none;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  font-size: 14px;
  min-height: 200px;
}

.assessment-loading__spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 999px;
  animation: spin .9s linear infinite;
}

.assessment-empty {
  padding: 32px 16px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  text-align: center;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.assessment-empty__icon {
  font-size: 28px;
  margin-bottom: 8px;
  display: block;
  opacity: 0.6;
}
.assessment-empty h4 {
  margin-bottom: 4px;
}

.assessment-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  display: flex;
  align-items: flex-start;
  gap: 20px;
}

.assessment-summary__score {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--primary);
  min-width: 52px;
}

.assessment-summary__details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.assessment-summary__verdict {
  font-size: 16px;
  font-weight: 600;
}

.assessment-summary__headline {
  font-size: 13px;
  color: var(--muted);
  max-width: 600px;
  line-height: 1.45;
}

.assessment-progress {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.assessment-progress__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.assessment-progress__header h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.assessment-progress__toggle {
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 999px;
  transition: background .2s ease, color .2s ease;
}

.assessment-progress__toggle:hover:not([disabled]) {
  background: rgba(10,132,255,.12);
}

.assessment-progress__toggle[disabled] {
  color: var(--muted);
  cursor: default;
}

.assessment-progress[data-collapsed="true"] .assessment-progress__list {
  display: none;
}

.assessment-progress[data-collapsed="false"] .assessment-progress__toggle {
  color: var(--muted);
}

.assessment-progress__list {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0 0 0 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.assessment-progress__list::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 10px;
  bottom: 12px;
  width: 2px;
  background: var(--border);
  border-radius: 999px;
  opacity: .6;
}

.assessment-progress__item {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  font-size: 13.5px;
  line-height: 1.45;
}

.assessment-progress__item:last-child::after {
  content: "";
  position: absolute;
  left: 11px;
  bottom: -14px;
  width: 2px;
  height: 14px;
  background: transparent;
}

.assessment-progress__dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--border);
  box-shadow: 0 0 0 4px rgba(10,132,255,.08);
  transition: background .2s ease, box-shadow .2s ease, transform .2s ease;
  margin-top: 4px;
  z-index: 1;
}

.assessment-progress__content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.assessment-progress__message {
  font-weight: 600;
  color: var(--text);
}

.assessment-progress__time {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .3px;
}

.assessment-progress__item.is-active .assessment-progress__dot {
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(10,132,255,.2);
  transform: scale(1.05);
}

.assessment-progress__item.is-active .assessment-progress__message {
  color: var(--primary);
}

.assessment-progress__item.is-complete .assessment-progress__dot {
  background: rgba(16,185,129,.95);
  box-shadow: 0 0 0 4px rgba(16,185,129,.18);
}

.assessment-progress__item.is-complete .assessment-progress__message {
  color: var(--muted);
  font-weight: 500;
}

.assessment-breakdown {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.assessment-breakdown__item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.assessment-breakdown__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 600;
  color: var(--text);
}

.assessment-breakdown__label {
  font-size: 14px;
}

.assessment-breakdown__value {
  font-size: 13px;
  color: var(--primary);
}

.assessment-breakdown__bar {
  position: relative;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(10,132,255,.12);
  overflow: hidden;
}

.assessment-breakdown__fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--primary);
  transition: width .3s ease;
}

.assessment-breakdown__note {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
}

html[data-theme="dark"] .assessment-breakdown__bar {
  background: rgba(74, 144, 226, .25);
}

html[data-theme="dark"] .assessment-breakdown__fill {
  background: rgba(91,164,255,.95);
}

.assessment-figures {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.assessment-figures__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.assessment-figures__card {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.assessment-figures__label {
  font-size: 11px;
  letter-spacing: .35px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.assessment-figures__value {
  font-size: 16px;
  font-weight: 600;
}

.assessment-figures__note {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
}

.assessment-report {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  /* More internal padding for reading */
  padding: 24px 28px;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text);
  max-width: 100%;
  overflow-wrap: break-word;
  /* Cleaner without the shadow */
  box-shadow: none; 
}

.assessment-report h1,
.assessment-report h2,
.assessment-report h3,
.assessment-report h4 {
  margin-top: 1.4em;
  margin-bottom: .6em;
  font-weight: 600;
  line-height: 1.3;
}
.assessment-report > *:first-child {
  margin-top: 0;
}

.assessment-report h1 { font-size: 1.5em; }
.assessment-report h2 { font-size: 1.3em; }
.assessment-report h3 { font-size: 1.15em; }
.assessment-report h4 { font-size: 1.05em; }

.assessment-report p {
  margin: 0 0 1em;
}

.assessment-report ul {
  padding-left: 18px;
  margin: 0 0 1em;
}
.assessment-report li {
  margin-bottom: 0.4em;
}

.assessment-report a {
  color: var(--primary);
  text-decoration: none;
}

.assessment-report a:hover {
  text-decoration: underline;
}

.assessment-report table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 13px;
}

.assessment-report table th,
.assessment-report table td {
  border: 1px solid var(--border);
  padding: 10px;
  vertical-align: top;
  text-align: left;
  word-break: break-word;
}

.assessment-report table td:nth-child(3) {
  font-family: "Menlo", "Roboto Mono", monospace;
  letter-spacing: 1px;
  white-space: nowrap;
}

.assessment-report table th {
  background: var(--surface-muted);
  font-weight: 600;
}

.assessment-report blockquote {
  margin: 1em 0;
  padding-left: 14px;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

.assessment-report hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.assessment-report code {
  font-family: Menlo, Monaco, monospace;
  font-size: 13px;
  background: var(--surface-muted);
  padding: 2px 5px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.assessment-report pre {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: var(--radius-md);
  overflow: auto;
}

.assessment-report pre code {
  background: none;
  padding: 0;
  border: none;
}

.assessment-history {
  margin-top: 14px;
}

.assessment-history__header h4 {
  font-size: 14px;
  font-weight: 600;
}

.assessment-history__list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.assessment-history__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition: all .2s ease;
}

.assessment-history__item.is-active {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(10,132,255,.15);
}
.assessment-history__item:not(.is-active):hover {
  background: var(--surface-muted);
}

.assessment-history__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.assessment-history__title {
  font-weight: 600;
  font-size: 13px;
}

.assessment-history__timestamp {
  font-size: 12px;
  color: var(--muted);
}

.assessment-history__button {
  border: none;
  background: transparent;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-size: 13px;
}
.assessment-history__button[disabled] {
  color: var(--muted);
  cursor: default;
  text-decoration: none;
}

.assessment-history__button:hover:not([disabled]) {
  text-decoration: underline;
}

.assessment-modal__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  /* Consistent padding */
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.assessment-footer__meta {
  font-size: 12px;
  color: var(--muted);
}

.assessment-footer__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.assessment-footer__actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0; /* Remove old margins */
}

.assessment-loading[hidden],
.assessment-empty[hidden],
.assessment-summary[hidden],
.assessment-figures[hidden],
#assessmentReportContent[hidden],
.assessment-history[hidden],
.assessment-progress[hidden] {
  display: none !important;
}

.assessment-modal__footer .assess-btn__spinner {
  border-color: rgba(255,255,255,.8);
  border-right-color: transparent;
}

#assessmentModal .icon-btn[data-close]{
  color: var(--danger);
  border: 1px solid rgba(var(--danger-rgb), 0.6);
  border-radius: 50%;
}
#assessmentModal .icon-btn[data-close]:hover{
  background: rgba(var(--danger-rgb), 0.08);
  border-color: rgba(var(--danger-rgb), 0.85);
}

@media (max-width: 880px) {
  .assessment-summary {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  #assessmentModal .modal__body--scroll {
    padding: 16px;
  }
  .assessment-modal__header,
  .assessment-modal__footer {
    padding-left: 20px;
    padding-right: 20px;
  }

  .assessment-report {
    padding: 18px 20px;
    font-size: 14px;
  }
}

@media (max-width: 640px) {
  .assessment-modal__close--desktop {
    display: none;
  }
  .assessment-modal__close--mobile {
    display: inline-flex;
  }

  #btnAssessmentDownload {
    display: none;
  }

  #assessmentModal .modal__dialog {
    margin: 1vh auto;
    max-height: 82vh;
  }

  .assessment-modal__header {
    padding: 10px 12px;
    gap: 8px;
  }
  .assessment-modal__title h3 {
    font-size: 1.05rem;
  }
  .assessment-modal__actions {
    gap: 8px;
  }
  .assessment-modal__footer {
    padding: 10px 12px 12px;
  }
  .assessment-footer__actions .btn {
    padding: 6px 10px;
  }

  .assessment-modal__footer {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .assessment-footer__actions {
    justify-content: center;
    width: 100%;
  }
  
  .assessment-footer__meta {
    text-align: center;
  }

  .assessment-progress__header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  
  .assessment-progress__toggle {
    align-self: flex-start;
    padding-left: 0;
  }

  .assessment-modal__header {
    flex-direction: column;
    gap: 12px;
  }
  .assessment-modal__title {
    align-self: flex-start;
    width: 100%;
  }
  .assessment-modal__actions {
    width: 100%;
    justify-content: space-between;
  }

  .assessment-modal__actions select {
    flex: 1;
  }
}
