.assessment-survey-medications {
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border-secondary);
  border-radius: 6px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;

  .expand {
    width: 100%;
  }

  .header {
    display: flex;
    justify-content: space-between;
    align-items: center;

    .title {
      font-size: 18px;
      font-weight: 600;
      line-height: 1.5;

      .description {
        font-size: 14px;
        font-weight: 400;
      }
    }

    .actions {
      display: flex;
      gap: 16px;
      align-items: center;
    }
  }

  .populate-source-label {
    gap: 8px;
    cursor: pointer;
    width: 100%;
  }

  .populate-submit {
    justify-content: center;

    button {
      width: 100%;
    }
  }

  .secondary-text {
    color: var(--color-text-tertiary);
  }

  .missing-fields-row {
    background-color: var(--color-bg-error-primary);
  }

  .medication-info-cell {
    display: flex;
    flex: 2;
    align-items: center;
    justify-content: space-between;
    position: relative;

    .matching-pending-overlay {
      position: absolute;
      inset: 0;
      background: var(--color-bg-primary);
      display: flex;
      align-items: center;
      justify-content: flex-start;
      z-index: 1;
    }

    .name-container {
      max-width: 80%;

      .name {
        line-height: 1.2;
        margin-bottom: 6px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;

        i {
          color: var(--color-text-warning-primary);

          &:hover {
            cursor: pointer;
          }
        }
      }

      .original-name {
        font-size: var(--font-size-xs);
        margin-bottom: 2px;
      }

      .match-indicator {
        font-size: var(--font-size-xs);
        font-weight: 600;
        color: var(--color-danger, #e53e3e);
        margin-bottom: 4px;
      }

      .subline {
        display: flex;
        align-items: center;
        gap: 10px;

        .missing-fields {
          color: var(--color-fg-error-secondary);
        }

        .dot {
          width: 4px;
          height: 4px;
          border-radius: 999px;
          background: var(--color-text-secondary);
          display: inline-block;
        }
      }
    }

    .verified-circle {
      width: 25px;
      height: 25px;

      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;

      i {
        font-weight: bold;
      }

      &.active {
        background-color: var(--color-bg-success-primary);

        i {
          color: var(--color-text-success-primary);
        }
      }

      &.inactive {
        background-color: var(--color-bg-error-primary);

        i {
          color: var(--color-fg-error-secondary);
        }
      }
    }
  }

  .amount-cell {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .date-cell {
    flex: 2;
  }

  .directions-cell {
    flex: 1;
  }

  .route-cell {
    flex: 1;
  }

  .source-cell {
    flex: 1;
  }

  .actions-cell {
    display: flex;
    flex: 0 0 84px;
    gap: 18px;
  }
}

.medication-dosage-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--color-border-secondary);
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 15px;
}

hr.medications-form-divider {
  border: none;
  border-top: 1px solid var(--color-border-secondary);
  margin: 8px 0;
}

.medication-understanding-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.medication-understanding-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.medication-understanding-row + .medication-understanding-row {
  margin-top: -4px;
}

.medication-status-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.medication-status-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.medication-status-row + .medication-status-row {
  margin-top: -4px;
}

.div-table-medications {
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  overflow: auto;
  border: 1px solid var(--color-border-secondary);

  .row {
    border-bottom: 1px solid var(--color-border-secondary);
    font-size: var(--font-size-sm);
    display: flex;
    align-items: center;
    padding: 20px;
    gap: 24px;
    min-width: 0;
    overflow: hidden;

    &.headers {
      position: sticky;
      top: 0;
      background-color: var(--color-bg-quaternary);
      font-weight: 600;
      font-size: 14px;
      padding: 14px 20px;
    }

    &:last-child {
      border-bottom: none;
    }
  }

  .cell {
    min-width: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;

    &.fixed {
      flex-shrink: 0;
      width: 150px;
    }

    &.empty {
      text-align: center;
      flex: 1;
      color: var(--color-text-tertiary);
    }
  }
}

@media (max-width: 1023px) {
  .div-table-medications {
    .row {
      flex-direction: column;
      align-items: flex-start;
      gap: 12px;
      padding: 16px;

      &.headers {
        display: none;
      }
    }

    .cell {
      flex: none;
      width: 100%;
    }
  }
}

@media (max-width: 1023px) {
  .assessment-survey-medications {
    .header {
      flex-direction: column;
      gap: 16px;
      align-items: flex-start;

      .actions {
        width: 100%;
        flex-direction: column-reverse;
        align-items: flex-end;
      }
    }

    .actions-cell {
      justify-content: flex-end;
      flex: none;
    }
  }
}
